/* ======================================
   GAIABOT - CSS RESPONSIVE CON FULLSCREEN
   ====================================== */

/* ======================================
   VARIABLES CSS
   ====================================== */
:root {
    --gaia-primary: #133D70;
    --gaia-secondary: #1F5AA0;
    --gaia-light: #f8f9fa;
    --gaia-dark: #212529;
    --gaia-border: #dee2e6;
    --gaia-shadow: rgba(19, 61, 112, 0.15);

    /* Dimensiones responsive */
    --modal-width-mobile: 100vw;
    --modal-height-mobile: 100vh;
    --modal-width-tablet: 420px;
    --modal-height-tablet: 600px;
    --modal-width-desktop: 420px;
    --modal-height-desktop: 650px;
    --modal-width-fullscreen: min(800px, 90vw);
    --modal-height-fullscreen: 90vh;
}

/* ======================================
   ESTILOS BASE - Solo para elementos del chatbot
   ====================================== */
/* Box-sizing solo para contenedores principales, no para todo */
#gaiabot-widget,
#gaiabot-widget > *,
.gaiabot-modal,
.gaiabot-modal > *,
.gaiabot-invite,
.gaiabot-button,
.gaiabot-header,
.gaiabot-toolbar,
.gaiabot-messages,
.gaiabot-input-container,
.gaiabot-header-actions,
.chat-selector,
.chat-selector-overlay {
    box-sizing: border-box;
}

/* Font-family para contenedores principales */
#gaiabot-widget,
.gaiabot-modal,
.gaiabot-invite {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ======================================
   WIDGET CONTAINER
   ====================================== */
#gaiabot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
}

/* ======================================
   BOTÓN FLOTANTE
   ====================================== */
.gaiabot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gaia-primary) 0%, var(--gaia-secondary) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--gaia-shadow), 0 2px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    position: relative;
}

.gaiabot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(19, 61, 112, 0.3), 0 3px 10px rgba(0,0,0,0.15);
}

.gaiabot-button:active {
    transform: scale(0.95);
}

/* Badge de notificaciones (opcional) */
.gaiabot-button::after {
    content: attr(data-unread);
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

.gaiabot-button[data-unread]:not([data-unread="0"])::after {
    display: block;
}

/* ======================================
   MODAL DEL CHAT
   ====================================== */
.gaiabot-modal {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: var(--modal-width-desktop);
    height: var(--modal-height-desktop);
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0) scale(1);
    overflow: hidden;
}

.gaiabot-modal.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Modo Pantalla Completa */
.gaiabot-modal.fullscreen {
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%);
    width: var(--modal-width-fullscreen) !important;
    height: var(--modal-height-fullscreen) !important;
    max-height: var(--modal-height-fullscreen);
    border-radius: 20px;
}

.gaiabot-modal.fullscreen.hidden {
    transform: translate(50%, 50%) scale(0.95);
    opacity: 0;
}

/* ======================================
   HEADER
   ====================================== */
.gaiabot-header {
    background: linear-gradient(135deg, var(--gaia-primary) 0%, var(--gaia-secondary) 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.gaiabot-header-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gaiabot-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.gaiabot-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.gaiabot-disclaimer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.disclaimer-text {
    font-size: 10px;
    opacity: 0.75;
    font-style: italic;
}

.disclaimer-icon {
    display: inline-flex;
    align-items: center;
    cursor: help;
    opacity: 0.75;
    transition: opacity 0.2s ease;
}

.disclaimer-icon:hover {
    opacity: 1;
}

.disclaimer-icon svg {
    vertical-align: middle;
}

.gaiabot-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Botones del header */
.gaiabot-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.gaiabot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.gaiabot-header-btn:active {
    transform: scale(0.95);
}

.gaiabot-close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.gaiabot-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ======================================
   TOOLBAR (Controles del chat)
   ====================================== */
.gaiabot-toolbar {
    background: var(--gaia-light);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gaia-border);
    flex-shrink: 0;
}

.gaiabot-toolbar-left,
.gaiabot-toolbar-right {
    display: flex;
    gap: 8px;
}

.toolbar-btn {
    background: white;
    border: 1px solid var(--gaia-border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    color: var(--gaia-dark);
}

.toolbar-btn:hover {
    background: var(--gaia-light);
    border-color: var(--gaia-primary);
    color: var(--gaia-primary);
}

.toolbar-btn svg {
    width: 14px;
    height: 14px;
}

/* ======================================
   ÁREA DE MENSAJES
   ====================================== */
.gaiabot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Scrollbar personalizado con colores de CRESTA */
.gaiabot-messages::-webkit-scrollbar {
    width: 6px;
}

.gaiabot-messages::-webkit-scrollbar-track {
    background: #f0f4f8;
}

.gaiabot-messages::-webkit-scrollbar-thumb {
    background: var(--gaia-secondary);
    border-radius: 3px;
    opacity: 0.6;
}

.gaiabot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gaia-primary);
}

/* ======================================
   MENSAJES
   ====================================== */
.gaiabot-message {
    display: flex;
    gap: 10px;
    animation: gaiabotMessageSlideIn 0.3s ease;
    box-sizing: border-box;
}

.gaiabot-message * {
    box-sizing: border-box;
}

@keyframes gaiabotMessageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--gaia-light);
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--gaia-primary) 0%, var(--gaia-secondary) 100%);
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: #f0f7ff;
    color: var(--gaia-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid #e3f2fd;
    box-shadow: 0 1px 2px rgba(19, 61, 112, 0.05);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--gaia-primary) 0%, var(--gaia-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Formato de mensajes */
.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content a {
    color: var(--gaia-secondary);
    text-decoration: underline;
    font-weight: 500;
}

.message-content a:hover {
    color: var(--gaia-primary);
}

.user-message .message-content a {
    color: white;
    text-decoration: underline;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

/* Estilos para Markdown renderizado */
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
    color: var(--gaia-primary);
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4, .message-content h5, .message-content h6 { font-size: 1em; }

.message-content code {
    background: rgba(19, 61, 112, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
    color: var(--gaia-primary);
}

.message-content pre {
    background: rgba(19, 61, 112, 0.06);
    border: 1px solid rgba(19, 61, 112, 0.15);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.message-content blockquote {
    border-left: 3px solid var(--gaia-secondary);
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(31, 90, 160, 0.05);
    color: #555;
    font-style: italic;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 0.9em;
}

.message-content th {
    background: var(--gaia-primary);
    color: white;
    padding: 8px;
    text-align: left;
    font-weight: 600;
}

.message-content td {
    border: 1px solid var(--gaia-border);
    padding: 6px 8px;
}

.message-content tr:nth-child(even) {
    background: rgba(19, 61, 112, 0.03);
}

.message-content hr {
    border: none;
    border-top: 2px solid var(--gaia-border);
    margin: 12px 0;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gaia-primary);
    animation: gaiabotTypingBounce 1.4s infinite;
}

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

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

@keyframes gaiabotTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ======================================
   INPUT CONTAINER
   ====================================== */
.gaiabot-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid var(--gaia-border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.gaiabot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gaia-border);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    resize: none;
    max-height: 120px;
}

.gaiabot-input:focus {
    border-color: var(--gaia-primary);
    box-shadow: 0 0 0 3px rgba(19, 61, 112, 0.1);
}

/* Estado de procesamiento - Input deshabilitado */
.gaiabot-input:disabled,
.gaiabot-input.processing {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #d0d0d0;
}

.gaiabot-input.processing::placeholder {
    color: #999;
}

.gaiabot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gaia-primary) 0%, var(--gaia-secondary) 100%);
    border: none;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.gaiabot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(19, 61, 112, 0.3);
}

.gaiabot-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.gaiabot-send-btn:disabled,
.gaiabot-send-btn.processing {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

/* Indicador visual adicional: animación de pulso en el botón cuando está procesando */
.gaiabot-send-btn.processing {
    animation: gaiabotProcessingPulse 1.5s ease-in-out infinite;
}

@keyframes gaiabotProcessingPulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.3;
    }
}

/* ======================================
   SELECTOR DE CONVERSACIONES
   ====================================== */
.chat-selector-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-selector-overlay.active {
    display: block;
    opacity: 1;
}

.chat-selector {
    position: absolute;
    top: 65px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 11;
    display: none;
    flex-direction: column;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.chat-selector.active {
    display: flex;
    transform: translateY(0);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--gaia-border);
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover {
    background: var(--gaia-light);
}

.chat-item.active {
    background: rgba(19, 61, 112, 0.05);
    border-left: 3px solid var(--gaia-primary);
}

.chat-item-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-info {
    font-size: 12px;
    color: #666;
}

.chat-item-delete {
    background: transparent;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-item-delete:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* ======================================
   RESPONSIVE - TABLET
   ====================================== */
@media (max-width: 768px) and (min-width: 481px) {
    #gaiabot-widget {
        bottom: 15px;
        right: 15px;
    }

    .gaiabot-modal {
        width: var(--modal-width-tablet);
        height: var(--modal-height-tablet);
        bottom: 80px;
        right: 15px;
    }

    .gaiabot-modal.fullscreen {
        width: calc(100vw - 40px) !important;
        height: calc(100vh - 40px) !important;
    }
}

/* ======================================
   RESPONSIVE - MOBILE
   ====================================== */
@media (max-width: 480px) {
    #gaiabot-widget {
        bottom: 10px;
        right: 10px;
    }

    .gaiabot-button {
        width: 56px;
        height: 56px;
    }

    /* IMPORTANTE: Modal ocupa toda la pantalla pero con espacio para cerrar */
    .gaiabot-modal {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height (mejor para móviles) */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        z-index: 99999;
    }

    /* Modo fullscreen en móvil también ocupa toda la pantalla */
    .gaiabot-modal.fullscreen {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        transform: none;
        border-radius: 0;
    }

    /* Header más compacto pero siempre visible */
    .gaiabot-header {
        padding: 12px 15px;
        border-radius: 0;
        flex-shrink: 0;
        min-height: 60px;
    }

    .gaiabot-header h3 {
        font-size: 16px;
    }

    .gaiabot-subtitle {
        font-size: 11px;
    }

    /* Botones del header más grandes para mejor touch target */
    .gaiabot-header-btn,
    .gaiabot-close-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .gaiabot-toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .toolbar-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .gaiabot-messages {
        padding: 15px 12px;
        /* Asegurar que el área de mensajes no se expanda más allá */
        max-height: calc(100vh - 200px);
        max-height: calc(100dvh - 200px);
    }

    .message-content {
        max-width: 85%;
        font-size: 13px;
    }

    .gaiabot-input-container {
        padding: 12px 15px;
        flex-shrink: 0;
    }

    .gaiabot-input {
        font-size: 16px; /* Evita zoom en iOS */
    }

    /* Ocultar botón flotante cuando modal está abierto en mobile */
    .gaiabot-button.modal-open {
        display: none;
    }

    /* Asegurar que el mensaje de invitación no interfiera */
    .gaiabot-invite {
        max-width: 200px;
        bottom: 70px;
        right: -5px;
    }
}

/* ======================================
   AJUSTES ADICIONALES PARA iOS SAFARI
   ====================================== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari específico */
    @media (max-width: 480px) {
        .gaiabot-modal {
            height: -webkit-fill-available !important;
        }

        .gaiabot-messages {
            max-height: calc(-webkit-fill-available - 200px);
        }
    }
}

/* ======================================
   LANDSCAPE MOBILE
   ====================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .gaiabot-modal {
        height: 100vh !important;
    }

    .gaiabot-messages {
        padding: 10px;
    }
}

/* ======================================
   ACCESIBILIDAD
   ====================================== */
@media (prefers-reduced-motion: reduce) {
    #gaiabot-widget,
    #gaiabot-widget *,
    #gaiabot-widget *::before,
    #gaiabot-widget *::after,
    .gaiabot-modal,
    .gaiabot-modal *,
    .gaiabot-modal *::before,
    .gaiabot-modal *::after,
    .gaiabot-invite,
    .gaiabot-invite *,
    .gaiabot-invite *::before,
    .gaiabot-invite *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ======================================
   FORZAR MODO CLARO (sin dark mode)
   ====================================== */
/* Se removió el dark mode automático para mantener
   siempre el fondo blanco con colores de CRESTA */

/* ======================================
   UTILIDADES - Solo para elementos del chatbot
   ====================================== */
#gaiabot-widget .hidden,
.gaiabot-modal .hidden,
.gaiabot-invite.hidden {
    display: none !important;
}

#gaiabot-widget .loading,
.gaiabot-modal .loading {
    pointer-events: none;
    opacity: 0.6;
}

#gaiabot-widget .fade-in,
.gaiabot-modal .fade-in {
    animation: gaiabotFadeIn 0.3s ease;
}

@keyframes gaiabotFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ======================================
   MENSAJE DE INVITACIÓN
   ====================================== */
.gaiabot-invite {
    position: absolute;
    bottom: 75px;
    right: 0;
    background: white;
    border-radius: 12px;
    border: 1px solid rgba(19, 61, 112, 0.1);
    box-shadow: 0 4px 16px rgba(19, 61, 112, 0.12), 0 2px 6px rgba(0,0,0,0.06);
    padding: 12px 16px;
    max-width: 260px;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    animation: gaiabotInviteSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) 2s forwards;
    pointer-events: none;
}

.gaiabot-invite.visible {
    pointer-events: auto;
}

.gaiabot-invite.hidden {
    animation: gaiabotInviteSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.gaiabot-invite-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 20px;
}

.gaiabot-invite-emoji {
    font-size: 24px;
    line-height: 1;
    animation: gaiabotWave 3s ease-in-out infinite;
    flex-shrink: 0;
}

.gaiabot-invite-text {
    flex: 1;
}

.gaiabot-invite-text strong {
    display: block;
    color: var(--gaia-primary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1.3;
}

.gaiabot-invite-text p {
    color: #666;
    font-size: 12px;
    margin: 0;
    line-height: 1.3;
}

.gaiabot-invite-close {
    position: absolute;
    top: 6px;
    right: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.gaiabot-invite-close:hover {
    background: rgba(0,0,0,0.05);
    color: #666;
}

/* Flecha apuntando al botón */
.gaiabot-invite::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-right: 1px solid rgba(19, 61, 112, 0.1);
    border-bottom: 1px solid rgba(19, 61, 112, 0.1);
}

/* Animaciones */
@keyframes gaiabotInviteSlideIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes gaiabotInviteSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
        pointer-events: none;
    }
}

@keyframes gaiabotWave {
    0%, 100% {
        transform: rotate(0deg);
    }
    10%, 30% {
        transform: rotate(12deg);
    }
    20%, 40% {
        transform: rotate(-8deg);
    }
    50% {
        transform: rotate(10deg);
    }
    60%, 100% {
        transform: rotate(0deg);
    }
}

/* Responsive para tablets */
@media (max-width: 1024px) {
    .gaiabot-invite {
        max-width: 240px;
        padding: 12px 14px;
    }

    .gaiabot-invite-text strong {
        font-size: 13px;
    }

    .gaiabot-invite-text p {
        font-size: 11px;
    }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .gaiabot-invite {
        max-width: 220px;
        bottom: 70px;
        right: -5px;
        padding: 10px 12px;
    }

    .gaiabot-invite-content {
        gap: 8px;
        padding-right: 18px;
    }

    .gaiabot-invite-emoji {
        font-size: 22px;
    }

    .gaiabot-invite-text strong {
        font-size: 13px;
    }

    .gaiabot-invite-text p {
        font-size: 11px;
    }

    .gaiabot-invite::after {
        right: 22px;
        width: 10px;
        height: 10px;
        bottom: -5px;
    }
}

/* Responsive para móviles pequeños */
@media (max-width: 480px) {
    .gaiabot-invite {
        max-width: 200px;
        bottom: 70px;
        right: -5px;
        padding: 10px 12px;
    }

    .gaiabot-invite-emoji {
        font-size: 20px;
    }

    .gaiabot-invite-text strong {
        font-size: 12px;
    }

    .gaiabot-invite-text p {
        font-size: 10px;
    }
}

/* ==========================================
   SISTEMA DE FEEDBACK
   ========================================== */

/* Ajuste para mensajes del bot con feedback */
.bot-message {
    flex-direction: column;
    align-items: flex-start;
}

.bot-message > .message-wrapper {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Contenedor de feedback */
.gaiabot-feedback {
    margin-top: 8px;
    margin-left: 46px; /* Alineado con el contenido del mensaje (avatar 36px + gap 10px) */
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 46px);
    max-width: 75%;
}

/* Botones de feedback (thumbs up/down) */
.feedback-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.feedback-btn {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #666;
}

.feedback-btn svg {
    stroke: currentColor;
}

.feedback-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #bbb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.feedback-btn.active.feedback-positive {
    background: #d4edda;
    border-color: #28a745;
    color: #28a745;
}

.feedback-btn.active.feedback-negative {
    background: #f8d7da;
    border-color: #dc3545;
    color: #dc3545;
}

.feedback-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Follow-up de feedback negativo */
.feedback-followup {
    display: none;
}

.feedback-negative-form {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-label {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #495057;
}

.feedback-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.feedback-option {
    background: white;
    border: 1px solid #ced4da;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.feedback-option:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.feedback-option.selected {
    background: #133D70;
    color: white;
    border-color: #133D70;
}

.feedback-comment {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 50px;
    margin-bottom: 8px;
}

.feedback-comment:focus {
    outline: none;
    border-color: #133D70;
    box-shadow: 0 0 0 2px rgba(19, 61, 112, 0.1);
}

.feedback-submit-btn {
    background: #133D70;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.feedback-submit-btn:hover {
    background: #0f2f56;
}

.feedback-thanks {
    font-size: 12px;
    color: #28a745;
    font-style: italic;
    display: inline-block;
    padding: 4px 0;
}

/* Acciones rápidas de contacto */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    padding: 0 46px;
}

.quick-action-btn {
    background: white;
    border: 1px solid #133D70;
    color: #133D70;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.quick-action-btn svg {
    stroke: currentColor;
}

.quick-action-btn:hover {
    background: #133D70;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(19, 61, 112, 0.2);
}

/* Acciones de handoff (intervención por frustración) */
.handoff-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
    padding: 0 46px;
}

.handoff-btn {
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
}

.handoff-btn.primary {
    background: #133D70;
    color: white;
}

.handoff-btn.primary:hover {
    background: #0f2f56;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(19, 61, 112, 0.3);
}

.handoff-btn.secondary {
    background: white;
    border: 2px solid #133D70;
    color: #133D70;
}

.handoff-btn.secondary:hover {
    background: #f0f4f8;
}

.handoff-btn.tertiary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.handoff-btn.tertiary:hover {
    background: #e9ecef;
}

/* Responsive para feedback */
@media (max-width: 480px) {
    .gaiabot-feedback {
        margin-left: 12px;
        width: calc(100% - 12px);
        max-width: 85%;
    }

    .quick-actions,
    .handoff-actions {
        padding: 0 12px;
    }

    .quick-action-btn {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .feedback-options {
        gap: 4px;
    }

    .feedback-option {
        font-size: 11px;
        padding: 5px 10px;
    }

    .feedback-comment {
        font-size: 12px;
    }
}
