/* === WIDGET FLOTANTE (Vapi nativo) === */
/* El widget flotante se renderiza automáticamente por Vapi SDK */

/* === Tipografía: valor por defecto en el CSS; el plugin sobreescribe --vapi-font-family desde Ajustes === */
:root {
    --vapi-font-family: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --vapi-font-size-base: 16px;
    --vapi-line-height-base: 1.45;
}

/* El widget de Vapi y el chat embebido no deben heredar la tipografía del tema */
vapi-widget,
vapi-widget *,
.vapi-widget-wrapper,
.vapi-widget-wrapper *,
.vapi-landing-page,
.vapi-landing-page *,
.vapi-chatbot-container,
.vapi-chatbot-container * {
    font-family: var(--vapi-font-family) !important;
    line-height: var(--vapi-line-height-base);
}

.vapi-landing-page,
.vapi-chatbot-container,
vapi-widget {
    font-size: var(--vapi-font-size-base) !important;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ocultar botón "End Chat" del SDK de Vapi que no respeta la personalización */
button.text-red-600.text-sm.font-medium.px-2.py-1.border.border-transparent.hover\:border-red-600.rounded-md.transition-colors {
    display: none !important;
    visibility: hidden !important;
}

/* Alternativa: ocultar cualquier botón con texto "End Chat" o "End Call" */
button[class*="text-red-600"]:has(svg),
button[class*="text-red"]:has(svg) {
    display: none !important;
}

/* Si quieres que el botón aparezca pero en español, descomenta esto y añade tu texto:
button.text-red-600::after {
    content: "Finalizar Chat";
    color: #dc2626;
}
*/

/* === ADAPTACIÓN RESPONSIVE PARA MÓVILES === */
/* Hacer que el widget de Vapi ocupe el 100% del ancho en móviles */
@media (max-width: 768px) {
    /* Widget flotante de Vapi SDK */
    vapi-widget {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 1rem 1rem 0 0 !important;
    }
    
    /* Contenedor del iframe del widget */
    vapi-widget iframe,
    vapi-widget [class*="container"],
    vapi-widget [class*="wrapper"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Ajustar el shadow-root del widget si es posible */
    vapi-widget::part(container) {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* === LANDING PAGE === */
.vapi-landing-page {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

.vapi-landing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .vapi-landing-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .vapi-landing-page {
        margin: 20px auto;
        padding: 0 10px;
    }
}

/* === CHAT WIDGET EMBEBIDO === */
.vapi-chatbot-container {
    max-width: 100%;
}

.vapi-chat-widget {
    background: rgba(30, 41, 59, 0.95);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .vapi-chat-widget {
        border-radius: 0.5rem;
    }
}

.vapi-chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(71, 85, 105, 0.5);
}

@media (max-width: 768px) {
    .vapi-chat-header {
        padding: 0.75rem;
        gap: 0.75rem;
    }
}

.vapi-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color, #14B8A6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.vapi-chat-avatar svg {
    width: 20px;
    height: 20px;
}

.vapi-chat-title {
    flex: 1;
}

.vapi-chat-title h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
}

@media (max-width: 768px) {
    .vapi-chat-title h3 {
        font-size: 1rem;
    }
}

.vapi-chat-status {
    margin: 0;
    font-size: 0.875rem;
    color: #94a3b8;
}

.vapi-chat-reset {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.vapi-chat-reset:hover {
    color: white;
}

.vapi-chat-reset svg {
    width: 20px;
    height: 20px;
}

.vapi-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 400px;
}

@media (max-width: 768px) {
    .vapi-chat-messages {
        padding: 0.75rem;
        gap: 0.75rem;
        min-height: 300px;
    }
}

.vapi-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.vapi-chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.vapi-chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-color, #14B8A6);
    border-radius: 3px;
}

.vapi-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .vapi-message {
        max-width: 90%;
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
    }
}

.vapi-message-user {
    align-self: flex-end;
    background: var(--accent-color, #14B8A6);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.vapi-message-assistant {
    align-self: flex-start;
    background: rgba(51, 65, 85, 0.8);
    color: #e2e8f0;
    border-bottom-left-radius: 0.25rem;
}

.vapi-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: rgba(51, 65, 85, 0.8);
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    width: fit-content;
}

.vapi-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: vapi-typing 1.4s ease-in-out infinite;
}

.vapi-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.vapi-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes vapi-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

.vapi-chat-input-container {
    padding: 1rem;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(71, 85, 105, 0.5);
}

@media (max-width: 768px) {
    .vapi-chat-input-container {
        padding: 0.75rem;
    }
}

.vapi-chat-form {
    position: relative;
}

.vapi-chat-input {
    width: 100%;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 1.5rem;
    padding: 0.75rem 3rem 0.75rem 1rem;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.vapi-chat-input:focus {
    border-color: var(--accent-color, #14B8A6);
}

.vapi-chat-input::placeholder {
    color: #64748b;
}

.vapi-send-button {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--accent-color, #14B8A6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.vapi-send-button:hover {
    transform: translateY(-50%) scale(1.05);
}

.vapi-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vapi-send-button svg {
    width: 20px;
    height: 20px;
}

/* === SIDEBAR (Reservas/Productos) === */
.vapi-landing-sidebar {
    background: rgba(30, 41, 59, 0.95);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .vapi-landing-sidebar {
        border-radius: 0.5rem;
        padding: 1rem;
    }
}

.vapi-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .vapi-sidebar-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1rem;
    }
}

.vapi-sidebar-header h3 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
}

@media (max-width: 768px) {
    .vapi-sidebar-header h3 {
        font-size: 1.125rem;
    }
}

.vapi-personas-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vapi-personas-selector label {
    color: #94a3b8;
    font-size: 0.875rem;
}

.vapi-personas-selector select {
    background: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 0.5rem;
    color: white;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.vapi-slots-list,
.vapi-products-list {
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.vapi-slots-list::-webkit-scrollbar,
.vapi-products-list::-webkit-scrollbar {
    width: 6px;
}

.vapi-slots-list::-webkit-scrollbar-track,
.vapi-products-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.vapi-slots-list::-webkit-scrollbar-thumb,
.vapi-products-list::-webkit-scrollbar-thumb {
    background: var(--accent-color, #14B8A6);
    border-radius: 3px;
}

.vapi-slot-item,
.vapi-product-item {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

@media (max-width: 768px) {
    .vapi-slot-item,
    .vapi-product-item {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
}

.vapi-slot-item:hover,
.vapi-product-item:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: var(--accent-color, #14B8A6);
    transform: translateY(-2px);
}

.vapi-slot-item.selected,
.vapi-product-item.selected {
    border-color: var(--accent-color, #14B8A6);
    background: rgba(20, 184, 166, 0.1);
}

.vapi-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.vapi-sidebar-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.vapi-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.vapi-sidebar-empty h3 {
    color: white;
    margin: 0 0 0.5rem 0;
}

.vapi-sidebar-empty p {
    margin: 0;
    color: #94a3b8;
}

/* === MEJORAS ADICIONALES PARA MÓVILES === */

/* Ajustar scrollbars en móviles */
@media (max-width: 768px) {
    .vapi-chat-messages::-webkit-scrollbar,
    .vapi-slots-list::-webkit-scrollbar,
    .vapi-products-list::-webkit-scrollbar {
        width: 4px;
    }
    
    .vapi-slots-list,
    .vapi-products-list {
        max-height: 400px;
    }
}

/* Optimización para pantallas muy pequeñas */
@media (max-width: 480px) {
    .vapi-chat-avatar {
        width: 36px;
        height: 36px;
    }
    
    .vapi-chat-avatar svg {
        width: 18px;
        height: 18px;
    }
    
    .vapi-chat-title h3 {
        font-size: 0.9375rem;
    }
    
    .vapi-chat-status {
        font-size: 0.8125rem;
    }
    
    .vapi-chat-reset {
        padding: 0.375rem;
    }
    
    .vapi-chat-reset svg {
        width: 18px;
        height: 18px;
    }
    
    .vapi-message {
        max-width: 92%;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .vapi-chat-input {
        font-size: 16px; /* Evita zoom en iOS */
        padding: 0.625rem 2.75rem 0.625rem 0.875rem;
    }
    
    .vapi-send-button {
        width: 2.25rem;
        height: 2.25rem;
    }
    
    .vapi-send-button svg {
        width: 18px;
        height: 18px;
    }
}

/* Forzar adaptación del widget flotante de Vapi en móviles */
@media (max-width: 768px) {
    /* Intentar sobrescribir los estilos del SDK de Vapi */
    body vapi-widget,
    body > vapi-widget {
        position: fixed !important;
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
    }
    
    /* Si el widget tiene clases específicas */
    vapi-widget[class*="bottom-right"],
    vapi-widget[class*="bottom-left"] {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Ajustes extra para móviles pequeños */
@media (max-width: 480px) {
    .vapi-landing-page {
        margin: 10px auto;
        padding: 0 5px;
    }
    
    .vapi-landing-grid {
        gap: 1rem;
    }
    
    .vapi-sidebar-header h3 {
        font-size: 1rem;
    }
    
    .vapi-personas-selector {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .vapi-personas-selector select {
        width: 100%;
    }
}

/* === MEJORA v1.1.5: Width 100% en móviles para el widget de Vapi === */
@media (max-width: 768px) {
    /* Cambiar width de 28rem a 100% en el div principal del widget */
    .vapi-widget-wrapper > div > div[style*="width"] {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 8px !important;
    }
}
