/* Estilos generales — modo claro: grises + acentos amarillos / modo oscuro (navy + cian) */

:root {
    /* Fondos — modo claro: grises suaves */
    --bg-color: #d9d9df;
    --chat-bg: #efeff2;
    --faq-bg: #efeff2;
    --fondo-img: #e0e0e6;
    --header-bg: #d6d6dd;
    --list-item-bg: #e6e6eb;
    /* Texto */
    --text-color: #27272a;
    --text-muted: #71717a;
    --text-message-bot: #3f3f46;
    /* Acentos y bordes (amarillo / ámbar, no azul) */
    --accent: #b45309;
    --accent-hover: #92400e;
    --input-border: #c4c4cc;
    --input-bg: #ebebef;
    --faq-border: #c4c4cc;
    /* Botones y burbujas usuario: amarillo */
    --btn-bg: linear-gradient(90deg, #fef08a, #fde047);
    --btn-hover: linear-gradient(90deg, #fde047, #facc15);
    --btn-text: #292524;
    --btn-disabled: #b4b4bc;
    --user-msg: linear-gradient(90deg, #fef9c3, #fde047);
    --user-msg-text: #292524;
    /* Mensaje bot — gris un poco más oscuro que el fondo */
    --bot-msg: #dadde3;
    /* Sombras y notas */
    --shadow-card: 0 4px 20px rgba(24, 24, 27, 0.07);
    --audit-bg: rgba(239, 239, 242, 0.94);
    /* Aviso “primera pregunta”: tono cálido, distinto de usuario (amarillo) y bot (gris) */
    --tip-bubble-bg: linear-gradient(145deg, #ea580c 0%, #c2410c 100%);
    --tip-bubble-text: #fffaf0;
    --tip-tail-gradient: linear-gradient(135deg, #ea580c 0%, #9a3412 100%);
    --tip-bubble-ring: rgba(234, 88, 12, 0.45);
    --tip-bubble-glow: rgba(234, 88, 12, 0.22);
}

[data-theme="dark"] {
    /* Base alineada al fondo cósmico (estrellas + banner) */
    --bg-color: #030512;
    --chat-bg: #111827;
    --faq-bg: #111827;
    --fondo-img: transparent;
    --header-bg: #1f2937;
    --list-item-bg: #1f2937;
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --text-message-bot: #e5e7eb;
    --accent: #22d3ee;
    --accent-hover: #06b6d4;
    --input-border: #374151;
    --input-bg: #1f2937;
    --faq-border: #374151;
    --btn-bg: linear-gradient(90deg, #3b82f6, #8b5cf6);
    --btn-hover: linear-gradient(90deg, #2563eb, #7c3aed);
    --btn-disabled: #4b5563;
    --user-msg: linear-gradient(90deg, #3b82f6, #8b5cf6);
    --user-msg-text: #ffffff;
    --btn-text: #ffffff;
    --bot-msg: #1f2937;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.45);
    --audit-bg: rgba(17, 24, 39, 0.85);
    --tip-bubble-bg: linear-gradient(145deg, #fb923c 0%, #ea580c 55%, #c2410c 100%);
    --tip-bubble-text: #1c1917;
    --tip-tail-gradient: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
    --tip-bubble-ring: rgba(251, 191, 36, 0.55);
    --tip-bubble-glow: rgba(251, 146, 60, 0.35);
}
[data-theme="dark"] html {
    background-color: #020510;
}

html {
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    color: var(--text-color);
    transition: background-color 0.25s ease, color 0.25s ease;
    position: relative;
}

/* Modo oscuro: fondo fijo con arte cósmico (estrellas + neón) y velos para legibilidad */
[data-theme="dark"] body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: #020510;
    background-image:
        radial-gradient(ellipse 100% 55% at 50% 18%, rgba(0, 242, 255, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse 90% 80% at 50% 100%, rgba(8, 25, 48, 0.75) 0%, transparent 55%),
        linear-gradient(180deg, rgba(2, 5, 16, 0.45) 0%, rgba(2, 6, 18, 0.2) 42%, rgba(1, 3, 12, 0.82) 100%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0%, transparent 18%, transparent 82%, rgba(0, 0, 0, 0.35) 100%),
        url("../img/cosmic-bg.png");
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, cover;
    background-position: center, center, center, center, center;
    background-repeat: no-repeat;
}

/* Capa extra de “bokeh” estelar suave encima del arte (solo oscuro) */
[data-theme="dark"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.55;
    background-image:
        radial-gradient(circle at 8% 22%, rgba(255, 255, 255, 0.55) 0.6px, transparent 1.6px),
        radial-gradient(circle at 18% 78%, rgba(180, 240, 255, 0.45) 0.55px, transparent 1.5px),
        radial-gradient(circle at 92% 16%, rgba(255, 255, 255, 0.5) 0.5px, transparent 1.35px),
        radial-gradient(circle at 72% 88%, rgba(200, 250, 255, 0.4) 0.55px, transparent 1.45px),
        radial-gradient(circle at 42% 12%, rgba(255, 255, 255, 0.42) 0.45px, transparent 1.2px),
        radial-gradient(circle at 55% 62%, rgba(255, 255, 255, 0.38) 0.5px, transparent 1.3px),
        radial-gradient(circle at 28% 48%, rgba(220, 252, 255, 0.48) 0.4px, transparent 1.1px),
        radial-gradient(circle at 84% 44%, rgba(255, 255, 255, 0.44) 0.45px, transparent 1.2px),
        radial-gradient(circle at 12% 92%, rgba(255, 255, 255, 0.35) 0.45px, transparent 1.2px),
        radial-gradient(circle at 66% 28%, rgba(0, 242, 255, 0.35) 0.8px, transparent 2px),
        radial-gradient(circle at 38% 82%, rgba(255, 255, 255, 0.32) 0.4px, transparent 1.1px),
        radial-gradient(circle at 95% 72%, rgba(255, 255, 255, 0.4) 0.5px, transparent 1.3px);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    animation: cosmic-drift 18s ease-in-out infinite alternate;
}

@keyframes cosmic-drift {
    0% {
        opacity: 0.42;
        transform: scale(1);
    }
    100% {
        opacity: 0.62;
        transform: scale(1.02);
    }
}
/* Contenedor principal: chat compacto + columna derecha (FAQ + logo) */
.main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(96%, calc(100vw - 24px));
    max-width: min(1680px, calc(100vw - 24px));
    margin: 16px auto;
    position: relative;
    z-index: 2;
    gap: clamp(10px, 1.5vw, 16px);
    flex-wrap: nowrap;
    box-sizing: border-box;
    min-height: calc(100vh - 32px);
}

.sidebar-right {
    flex: 0 1 clamp(168px, 14vw, 220px);
    width: clamp(168px, 14vw, 220px);
    min-width: 0;
    max-width: min(220px, 32vw);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    align-self: center;
    position: sticky;
    top: 16px;
    min-height: min(82vh, 680px);
    max-height: min(82vh, 680px);
    height: min(82vh, 680px);
    overflow: hidden;
    box-sizing: border-box;
}

/* Bloque superior derecho: no roba altura al FAQ */
.sidebar-right .right-section {
    flex: 0 0 auto;
}

.sidebar-right .corner-image {
    max-height: 96px;
    width: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
}

/* Contenedor del chat: mismo alto útil que la barra derecha */
.chat-wrapper {
    position: relative;
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

/* Aviso “primera pregunta”: nube desde la izquierda, se oculta sola */
.first-question-tip {
    position: absolute;
    z-index: 25;
    left: 0;
    top: 50%;
    width: min(300px, calc(100% - 12px));
    max-width: 92%;
    pointer-events: none;
    transform: translate(calc(-100% - 24px), -50%);
    opacity: 0;
    transition:
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.4s ease;
}

.first-question-tip.first-question-tip--visible {
    transform: translate(8px, -50%);
    opacity: 1;
}

.first-question-tip.first-question-tip--exit {
    transform: translate(calc(-100% - 24px), -50%);
    opacity: 0;
    transition:
        transform 0.45s ease-in,
        opacity 0.35s ease;
}

.first-question-tip__bubble {
    position: relative;
    padding: 12px 16px 12px 18px;
    background: var(--tip-bubble-bg);
    color: var(--tip-bubble-text);
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: left;
    border-radius: 8px 22px 22px 22px;
    font-weight: 600;
    box-shadow:
        0 4px 20px var(--tip-bubble-glow),
        0 0 0 1px var(--tip-bubble-ring),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.first-question-tip__bubble::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    background: var(--tip-tail-gradient);
    border-radius: 2px;
    transform: rotate(45deg);
    z-index: 0;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .first-question-tip__bubble {
    box-shadow:
        0 4px 26px rgba(0, 0, 0, 0.55),
        0 0 0 1px var(--tip-bubble-ring),
        0 0 28px var(--tip-bubble-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

[data-theme="dark"] .first-question-tip__bubble::before {
    box-shadow:
        -2px 2px 12px rgba(0, 0, 0, 0.5),
        0 0 12px var(--tip-bubble-glow);
}

body:not([data-theme="dark"]) .first-question-tip__bubble {
    box-shadow:
        0 4px 22px var(--tip-bubble-glow),
        0 0 0 1px var(--tip-bubble-ring),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

@media (prefers-reduced-motion: reduce) {
    .first-question-tip {
        transition: opacity 0.25s ease;
    }

    .first-question-tip.first-question-tip--exit {
        transition: opacity 0.25s ease;
    }

    [data-theme="dark"] .header-titi-frame::before {
        animation: none;
        opacity: 0.72;
    }

    [data-theme="dark"] .header-titi-frame::after {
        animation: none;
        opacity: 0.42;
    }

    [data-theme="dark"] .header::before {
        animation: none;
        opacity: 0.68;
    }

    [data-theme="dark"] .header::after {
        animation: none;
        opacity: 0.38;
    }

    .chat-container {
        animation: none;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .chat-container:hover,
    .chat-container:focus-within {
        transform: none;
    }

    .chat-container:hover .title-image {
        transform: none;
    }

    .title-image {
        transition: none;
    }

    .message {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .loading-indicator {
        animation: none;
    }

    #user-input:focus {
        transform: none;
    }

    #send-btn:hover:not(:disabled),
    #send-btn:active:not(:disabled) {
        transform: none;
        box-shadow: none;
    }

    [data-theme="dark"] body::after {
        animation: none;
        opacity: 0.5;
        transform: none;
    }
}


/* Imagen en la esquina superior izquierda */
.corner-image-container {
    position: relative;
    margin-bottom: 20px;
}

.corner-image {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    margin-bottom: 0;
    align-self: center;
    box-sizing: border-box;
    border: none;
    background: transparent;
    box-shadow: none;
    filter: none;
}

/* Ajustar el contenedor principal del chat */
.chat-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    background: var(--chat-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--input-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: 50% 40%;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.15, 0.64, 1),
        box-shadow 0.35s ease,
        border-color 0.25s ease;
    animation: chatCardAppear 0.55s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

.chat-container:hover {
    transform: translateY(-4px) scale(1.008);
    box-shadow:
        0 12px 36px rgba(24, 24, 27, 0.12),
        0 4px 12px rgba(24, 24, 27, 0.06);
}

[data-theme="dark"] .chat-container:hover {
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(34, 211, 238, 0.18);
    border-color: rgba(34, 211, 238, 0.35);
}

.chat-container:focus-within {
    transform: translateY(-2px) scale(1.004);
    box-shadow:
        0 10px 32px rgba(24, 24, 27, 0.1),
        0 0 0 3px rgba(202, 138, 4, 0.18);
}

[data-theme="dark"] .chat-container:focus-within {
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.45),
        0 0 0 2px rgba(34, 211, 238, 0.22);
}

@keyframes chatCardAppear {
    from {
        opacity: 0.94;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Encabezado TiTi: más compacto para dejar más área al hilo de mensajes */
.header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 1.2vh, 14px) clamp(8px, 1.2vw, 14px);
    background: var(--fondo-img);
    width: 100%;
    flex: 0 1 24%;
    min-height: clamp(88px, 15vh, 200px);
    max-height: min(28vh, 220px);
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    color: var(--text-color);
    z-index: 3;
    box-sizing: border-box;
}

.header-image {
    max-width: 100%; /* Asegura que la imagen no exceda el ancho del contenedor */
    height: 100%; /* Asegura que la imagen ocupe toda la altura del encabezado */
    object-fit: cover; /* Ajusta la imagen para que cubra todo el espacio sin distorsionarla */
    object-position: center; /* Centra la imagen dentro del contenedor */
}

.header-titi-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

/* Modo claro: cielo celeste muy suave y nubes solo en la parte externa del encabezado (el marco TiTi no se modifica visualmente) */
body:not([data-theme="dark"]) .header {
    isolation: isolate;
    background: linear-gradient(
        185deg,
        #b9c9d6 0%,
        #aec2d2 38%,
        #a3b8ca 72%,
        #9aafc2 100%
    );
    border-bottom: 1px solid rgba(90, 120, 145, 0.18);
}

body:not([data-theme="dark"]) .header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    /* Nubes más visibles: masas elípticas superpuestas + pequeños “pomos” de nube */
    background-image:
        radial-gradient(ellipse 130% 88% at 4% 52%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.12) 42%, transparent 58%),
        radial-gradient(ellipse 75% 48% at 14% 58%, rgba(248, 252, 255, 0.5) 0%, transparent 55%),
        radial-gradient(ellipse 65% 42% at 2% 62%, rgba(255, 255, 255, 0.42) 0%, transparent 50%),
        radial-gradient(ellipse 105% 72% at 22% 74%, rgba(240, 248, 255, 0.48) 0%, rgba(255, 255, 255, 0.08) 45%, transparent 56%),
        radial-gradient(ellipse 88% 58% at 30% 82%, rgba(255, 255, 255, 0.38) 0%, transparent 52%),
        radial-gradient(ellipse 118% 82% at 88% 36%, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0.1) 40%, transparent 54%),
        radial-gradient(ellipse 72% 50% at 96% 44%, rgba(245, 250, 255, 0.45) 0%, transparent 48%),
        radial-gradient(ellipse 100% 70% at 76% 68%, rgba(236, 244, 252, 0.46) 0%, transparent 52%),
        radial-gradient(ellipse 85% 56% at 68% 78%, rgba(255, 255, 255, 0.36) 0%, transparent 50%),
        radial-gradient(ellipse 140% 100% at 48% 18%, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0.06) 48%, transparent 62%),
        radial-gradient(ellipse 95% 62% at 56% 28%, rgba(255, 255, 255, 0.28) 0%, transparent 48%),
        radial-gradient(ellipse 92% 58% at 34% 88%, rgba(255, 255, 255, 0.4) 0%, transparent 46%),
        radial-gradient(ellipse 78% 50% at 94% 82%, rgba(242, 248, 255, 0.42) 0%, transparent 44%),
        radial-gradient(ellipse 70% 46% at 40% 44%, rgba(255, 255, 255, 0.22) 0%, transparent 42%),
        radial-gradient(ellipse 55% 38% at 50% 92%, rgba(255, 255, 255, 0.32) 0%, transparent 45%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

body:not([data-theme="dark"]) .header::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.92;
    /* Segunda capa: velos más grandes y suaves para volumen */
    background-image:
        radial-gradient(ellipse 160% 120% at 10% 32%, rgba(255, 255, 255, 0.32) 0%, transparent 58%),
        radial-gradient(ellipse 120% 95% at 52% 52%, rgba(230, 240, 250, 0.38) 0%, transparent 54%),
        radial-gradient(ellipse 100% 78% at 85% 22%, rgba(255, 255, 255, 0.28) 0%, transparent 50%),
        radial-gradient(ellipse 90% 65% at 18% 88%, rgba(248, 252, 255, 0.3) 0%, transparent 48%),
        radial-gradient(ellipse 110% 80% at 72% 12%, rgba(255, 255, 255, 0.22) 0%, transparent 52%),
        radial-gradient(ellipse 85% 55% at 38% 58%, rgba(255, 255, 255, 0.18) 0%, transparent 44%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

/* Modo claro: marco TiTi con toque amarillo (sin cian/azul) */
body:not([data-theme="dark"]) .header-titi-frame {
    position: relative;
    z-index: 1;
    padding: clamp(10px, 1.8vh, 20px) clamp(12px, 2vw, 28px);
    border-radius: clamp(14px, 1.6vw, 22px);
    background: linear-gradient(165deg, rgba(250, 204, 21, 0.22), rgba(255, 255, 255, 0.45));
    border: 1px solid rgba(202, 138, 4, 0.35);
    box-shadow: 0 2px 14px rgba(24, 24, 27, 0.06);
    min-width: 0;
    width: min(100%, 340px);
    max-width: 100%;
    margin: 0 auto;
}

/* TiTi: escala con el recuadro grande (mismo tamaño claro/oscuro) */
.title-image {
    display: block;
    width: auto;
    height: clamp(72px, 11vh, 140px);
    max-height: min(140px, 22vh);
    max-width: min(100%, 300px);
    object-fit: contain;
    object-position: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.15, 0.64, 1);
}

.chat-container:hover .title-image {
    transform: scale(1.04);
}

/* Modo oscuro: mismo logo; solo marco y brillo (sin cambiar dimensiones) */
[data-theme="dark"] .header {
    isolation: isolate;
    background:
        radial-gradient(ellipse 85% 90% at 50% 40%, rgba(34, 211, 238, 0.14) 0%, transparent 55%),
        rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(34, 211, 238, 0.22);
}

/* Estrellas en la zona externa del encabezado (todo el ancho, detrás del recuadro TiTi) */
[data-theme="dark"] .header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 4% 22%, rgba(255, 255, 255, 0.75) 0.45px, transparent 1.2px),
        radial-gradient(circle at 11% 68%, rgba(200, 245, 255, 0.5) 0.5px, transparent 1.3px),
        radial-gradient(circle at 18% 38%, rgba(255, 255, 255, 0.55) 0.4px, transparent 1.1px),
        radial-gradient(circle at 3% 88%, rgba(255, 255, 255, 0.45) 0.45px, transparent 1.2px),
        radial-gradient(circle at 28% 12%, rgba(220, 252, 255, 0.65) 0.4px, transparent 1.1px),
        radial-gradient(circle at 33% 82%, rgba(255, 255, 255, 0.5) 0.5px, transparent 1.3px),
        radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.8) 0.45px, transparent 1.2px),
        radial-gradient(circle at 91% 44%, rgba(200, 235, 255, 0.55) 0.5px, transparent 1.3px),
        radial-gradient(circle at 96% 78%, rgba(255, 255, 255, 0.6) 0.4px, transparent 1.1px),
        radial-gradient(circle at 72% 8%, rgba(255, 255, 255, 0.5) 0.35px, transparent 1px),
        radial-gradient(circle at 68% 92%, rgba(230, 252, 255, 0.55) 0.45px, transparent 1.2px),
        radial-gradient(circle at 48% 6%, rgba(255, 255, 255, 0.48) 0.4px, transparent 1.1px),
        radial-gradient(circle at 52% 94%, rgba(180, 240, 255, 0.42) 0.45px, transparent 1.2px),
        radial-gradient(circle at 22% 52%, rgba(255, 255, 255, 0.42) 0.35px, transparent 1px),
        radial-gradient(circle at 78% 58%, rgba(255, 255, 255, 0.52) 0.45px, transparent 1.2px),
        radial-gradient(circle at 42% 72%, rgba(255, 255, 255, 0.4) 0.4px, transparent 1.1px),
        radial-gradient(circle at 58% 28%, rgba(220, 245, 255, 0.58) 0.45px, transparent 1.2px),
        radial-gradient(circle at 14% 8%, rgba(255, 255, 255, 0.62) 0.4px, transparent 1.1px),
        radial-gradient(circle at 86% 12%, rgba(255, 255, 255, 0.45) 0.4px, transparent 1.1px),
        radial-gradient(circle at 38% 48%, rgba(255, 255, 255, 0.38) 0.35px, transparent 1px),
        radial-gradient(circle at 62% 68%, rgba(200, 250, 255, 0.48) 0.45px, transparent 1.2px),
        radial-gradient(circle at 7% 48%, rgba(255, 255, 255, 0.5) 0.45px, transparent 1.2px),
        radial-gradient(circle at 93% 28%, rgba(255, 255, 255, 0.55) 0.4px, transparent 1.1px),
        radial-gradient(circle at 45% 88%, rgba(255, 255, 255, 0.42) 0.4px, transparent 1.1px),
        radial-gradient(circle at 55% 22%, rgba(240, 250, 255, 0.5) 0.45px, transparent 1.2px),
        radial-gradient(circle at 1% 12%, rgba(255, 255, 255, 0.4) 0.35px, transparent 1px),
        radial-gradient(circle at 99% 62%, rgba(220, 245, 255, 0.48) 0.45px, transparent 1.2px),
        radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.44) 0.4px, transparent 1.1px),
        radial-gradient(circle at 64% 42%, rgba(255, 255, 255, 0.5) 0.4px, transparent 1.1px);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    animation: titi-stars-twinkle 6.2s ease-in-out infinite;
}

[data-theme="dark"] .header::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image:
        radial-gradient(circle at 8% 40%, rgba(34, 211, 238, 0.3) 1px, transparent 2.4px),
        radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.28) 0.9px, transparent 2px),
        radial-gradient(circle at 92% 55%, rgba(34, 211, 238, 0.26) 1px, transparent 2.3px),
        radial-gradient(circle at 70% 75%, rgba(255, 255, 255, 0.26) 0.85px, transparent 2px),
        radial-gradient(circle at 15% 85%, rgba(200, 250, 255, 0.22) 0.75px, transparent 1.9px),
        radial-gradient(circle at 50% 15%, rgba(34, 211, 238, 0.2) 0.9px, transparent 2.1px),
        radial-gradient(circle at 88% 22%, rgba(255, 255, 255, 0.24) 0.8px, transparent 1.9px),
        radial-gradient(circle at 40% 60%, rgba(34, 211, 238, 0.18) 1px, transparent 2.2px);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    animation: titi-stars-twinkle-slow 9.5s ease-in-out infinite reverse;
}

[data-theme="dark"] .header-titi-frame {
    position: relative;
    z-index: 1;
    overflow: hidden;
    padding: clamp(10px, 1.8vh, 20px) clamp(12px, 2vw, 28px);
    border-radius: clamp(14px, 1.6vw, 22px);
    background: linear-gradient(165deg, rgba(34, 211, 238, 0.14), rgba(249, 250, 251, 0.06));
    border: 1px solid rgba(34, 211, 238, 0.5);
    box-shadow:
        0 0 22px rgba(34, 211, 238, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    min-width: 0;
    width: min(100%, 340px);
    max-width: 100%;
    margin: 0 auto;
}

/* Estrellas sutiles dentro del recuadro TiTi (solo modo oscuro) */
[data-theme="dark"] .header-titi-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    border-radius: inherit;
    background-image:
        radial-gradient(circle at 8% 14%, rgba(255, 255, 255, 0.92) 0.5px, transparent 1.4px),
        radial-gradient(circle at 24% 72%, rgba(200, 245, 255, 0.65) 0.55px, transparent 1.5px),
        radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.85) 0.45px, transparent 1.2px),
        radial-gradient(circle at 74% 86%, rgba(255, 255, 255, 0.55) 0.5px, transparent 1.3px),
        radial-gradient(circle at 44% 38%, rgba(220, 252, 255, 0.75) 0.4px, transparent 1.1px),
        radial-gradient(circle at 14% 46%, rgba(255, 255, 255, 0.5) 0.55px, transparent 1.4px),
        radial-gradient(circle at 58% 64%, rgba(255, 255, 255, 0.88) 0.45px, transparent 1.2px),
        radial-gradient(circle at 92% 54%, rgba(200, 235, 255, 0.58) 0.5px, transparent 1.3px),
        radial-gradient(circle at 32% 90%, rgba(255, 255, 255, 0.68) 0.45px, transparent 1.2px),
        radial-gradient(circle at 68% 26%, rgba(255, 255, 255, 0.52) 0.4px, transparent 1px),
        radial-gradient(circle at 50% 10%, rgba(240, 250, 255, 0.62) 0.5px, transparent 1.3px),
        radial-gradient(circle at 6% 62%, rgba(255, 255, 255, 0.58) 0.45px, transparent 1.2px),
        radial-gradient(circle at 78% 42%, rgba(255, 255, 255, 0.48) 0.55px, transparent 1.4px),
        radial-gradient(circle at 26% 24%, rgba(220, 245, 255, 0.78) 0.4px, transparent 1.1px),
        radial-gradient(circle at 54% 84%, rgba(255, 255, 255, 0.62) 0.5px, transparent 1.3px),
        radial-gradient(circle at 84% 76%, rgba(200, 250, 255, 0.52) 0.45px, transparent 1.2px),
        radial-gradient(circle at 18% 30%, rgba(255, 255, 255, 0.42) 0.35px, transparent 1px),
        radial-gradient(circle at 64% 8%, rgba(255, 255, 255, 0.72) 0.45px, transparent 1.2px),
        radial-gradient(circle at 38% 56%, rgba(230, 252, 255, 0.68) 0.4px, transparent 1.1px),
        radial-gradient(circle at 96% 36%, rgba(255, 255, 255, 0.48) 0.5px, transparent 1.3px),
        radial-gradient(circle at 12% 88%, rgba(180, 240, 255, 0.45) 0.45px, transparent 1.2px),
        radial-gradient(circle at 70% 58%, rgba(255, 255, 255, 0.55) 0.4px, transparent 1.1px);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    animation: titi-stars-twinkle 5.5s ease-in-out infinite;
}

[data-theme="dark"] .header-titi-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    border-radius: inherit;
    opacity: 0.55;
    background-image:
        radial-gradient(circle at 30% 20%, rgba(34, 211, 238, 0.35) 1px, transparent 2.2px),
        radial-gradient(circle at 75% 35%, rgba(255, 255, 255, 0.35) 0.8px, transparent 2px),
        radial-gradient(circle at 20% 80%, rgba(34, 211, 238, 0.28) 1px, transparent 2.4px),
        radial-gradient(circle at 85% 70%, rgba(255, 255, 255, 0.3) 0.9px, transparent 2.1px),
        radial-gradient(circle at 52% 48%, rgba(200, 250, 255, 0.25) 0.7px, transparent 1.8px);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    animation: titi-stars-twinkle-slow 8s ease-in-out infinite reverse;
}

@keyframes titi-stars-twinkle {
    0%,
    100% {
        opacity: 0.55;
    }
    35% {
        opacity: 0.95;
    }
    65% {
        opacity: 0.7;
    }
}

@keyframes titi-stars-twinkle-slow {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 0.75;
    }
}

[data-theme="dark"] .title-image {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.65)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

/* Área de mensajes: crece entre cabecera TiTi y barra de búsqueda */
.chat-box {
    flex: 1 1 28%;
    min-height: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: clamp(10px, 1.2vw, 16px);
    width: 100%;
    box-sizing: border-box;
    align-items: center;
}

.input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: clamp(10px, 1.4vw, 14px) clamp(10px, 1.6vw, 16px);
    width: 100%;
    background: var(--input-bg);
    border-top: 1px solid var(--input-border);
    flex-shrink: 0;
    box-sizing: border-box;
}

#user-input {
    flex: 1 1 200px;
    min-width: 0;
    padding: 11px 14px;
    border: 2px solid var(--input-border);
    background: var(--input-bg);
    border-radius: 10px;
    margin-right: 0;
    font-size: clamp(14px, 1vw, 16px);
    color: var(--text-color);
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease,
        transform 0.25s cubic-bezier(0.34, 1.15, 0.64, 1);
}

#user-input:focus {
    border-color: var(--accent);
    outline: none;
    transform: translateY(-1px);
}

body:not([data-theme="dark"]) #user-input:focus {
    box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.28);
}

[data-theme="dark"] #user-input:focus {
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.22);
}

#send-btn {
    padding: 11px 22px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.94rem;
    transition:
        background 0.2s ease,
        transform 0.2s cubic-bezier(0.34, 1.15, 0.64, 1),
        box-shadow 0.2s ease;
    flex-shrink: 0;
}

#send-btn:disabled {
    background: var(--btn-disabled);
    color: var(--text-muted);
    cursor: not-allowed;
    filter: none;
    transform: none;
}

#send-btn:hover:not(:disabled) {
    background: var(--btn-hover);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 16px rgba(24, 24, 27, 0.12);
}

#send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

/* Estilos para los mensajes */
.message {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    max-width: 82%;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    animation: messagePopIn 0.42s cubic-bezier(0.34, 1.15, 0.64, 1) forwards;
}

@keyframes messagePopIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    background: var(--user-msg);
    color: var(--user-msg-text);
    align-self: flex-end;
    align-items: baseline;
}

.bot-message {
    background: var(--bot-msg);
    color: var(--text-message-bot);
    align-self: flex-start;
    border: 1px solid var(--input-border);
}

.loading-indicator {
    text-align: center;
    color: var(--accent);
    font-style: italic;
    font-size: 13px;
    margin-top: 8px;
    display: none;
    flex-shrink: 0;
    width: 100%;
    animation: loadingPulse 1.1s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%,
    100% {
        opacity: 0.55;
    }
    50% {
        opacity: 1;
    }
}

/*spline estilos*/
.spline-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.spline-background spline-viewer {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* PANEL DE PREGUNTAS FRECUENTES: ocupa solo el espacio sobrante bajo logo/tema */
.faq-panel {
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    min-width: 0;
    background-color: var(--faq-bg);
    padding: 10px 8px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-card);
    border-radius: 12px;
    border: 1px solid var(--input-border);
    position: relative;
    top: auto;
}

.faq-panel h2 {
    font-size: 1.2em;
    color: var(--accent);
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
}

.faq-panel ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.faq-panel li {
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--input-border);
    font-size: 0.85em;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.faq-panel li:hover {
    background-color: var(--accent);
    color: #fff;
    transform: translateX(2px);
    border-radius: 5px;
}

.faq-panel li:last-child {
    border-bottom: none;
}

.tabs{
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--accent);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.tab:hover,
.tab.active {
    border-bottom: 2px solid var(--accent);
    color: var(--accent-hover);
}

.tab-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: var(--faq-bg);
    border-radius: 0 0 8px 8px;
}

.tab-content.active {
    max-height: 1000px; /* Valor suficientemente grande */
    transition: max-height 0.5s ease-in;
}

.tab-title {
    padding: 15px 20px;
    margin: 0;
    font-size: 1.1em;
    color: var(--text-color);
    cursor: pointer;
    background-color: var(--header-bg);
    border-radius: 8px 8px 0 0;
}

.tab-content ul{
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.tab-content ul li {
    background: var(--list-item-bg);
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: none; /* Oculta las preguntas inicialmente */
}

.tab-content.active ul li {
    display: block; /* Muestra solo las preguntas de la categoría activa */
}

.tab-content ul li:hover {
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
}

.questions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: all 0.5s ease-in-out;
}

.questions-list li {
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.3s;
    border-top: 1px solid var(--input-border);
    background: var(--faq-bg);
    color: var(--text-color);
    font-size: 0.85em;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.questions-list ul li {
    padding: 10px 15px;
    border-top: 1px solid var(--input-border);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
}

.questions-list li:hover {
    background: var(--btn-bg);
    color: var(--btn-text);
}

.questions-list li:last-child {
    border-bottom: none;
}

.theme-button {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease;
    box-shadow: var(--shadow-card);
    width: 100%;
    box-sizing: border-box;
}

.theme-button:hover {
    background: var(--btn-hover);
}

.logo-and-theme-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 0;
}

/* Logo UTB + tema (arriba en la columna derecha) */
.right-section {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.tab-btn {
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    background: var(--header-bg);
    border: none;
    color: var(--text-color);
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn:hover,
.tab-btn.active {
    background: var(--accent);
    color: #fff;
}

.welcome-message {
    padding: 20px;
    text-align: center;
    color: var(--text-color);
}

.welcome-message .example {
    font-style: italic;
    color: var(--text-muted);
    margin-top: 10px;
}

.category {
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--header-bg);
}

.category-title {
    padding: 10px 12px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s;
}

.category-title::after {
    content: '+';
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.category.active .category-title::after {
    content: '-';
    transform: rotate(180deg);
}

.category-title:hover {
    background-color: var(--accent);
    color: #fff;
}

.category.active .questions-list {
    max-height: min(2000px, 70vh);
    transition: max-height 0.5s ease-in;
}

.chat-section {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: min(720px, 100%);
    align-self: center;
    min-height: 0;
    height: min(82vh, 680px);
    max-height: min(82vh, 680px);
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    align-items: stretch;
    padding: 0 4px 0 0;
    box-sizing: border-box;
}

.audit-note {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    color: var(--text-color);
    background-color: var(--audit-bg);
    padding: 6px 10px;
    border-radius: 8px;
    z-index: 999;
    border: 1px solid var(--input-border);
    transition: background-color 0.3s ease, color 0.3s ease;
}

@media (max-width: 900px) {
    .main-container {
        flex-wrap: wrap;
    }

    .sidebar-right {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        position: static;
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: visible;
        flex-direction: column;
    }

    .chat-wrapper {
        height: min(78vh, 720px);
        max-height: 78vh;
    }

    .chat-section {
        padding: 0;
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }
}

   /* RESPONSIVE DESIGN */
@media (max-width: 768px) {
  /* Ocultar logos que interfieren */
  .logo-container,
  .logo,
  .monkey-logo {
    display: none !important;
  }
   .faq-panel {
    display: block !important;
    position: static !important; /* evita superposiciones */
    width: 100%;
    margin-top: 20px;
    z-index: auto !important; /* neutraliza cualquier z-index anterior */
  }

  /* Centrar y ajustar el ancho del contenedor principal */
  .main-container{
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .chat-container {
    width: 100%;
  }

  /* Asegurar que el contenido se ordene verticalmente */
  .main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Ajustar lista de preguntas */
  .question-list {
    width: 100%;
  }

  /* Ajustar el área de chat */
  .chat-box,
  .chat-messages {
    width: 100% !important;
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Asegurar que el input y botón no se desborden */
  .input-container,
  .chat-input {
    width: 100%;
    box-sizing: border-box;
  }

  /* Botón enviar ajustado */
  .send-button {
    width: 100%;
    margin-top: 5px;
  }

  /* Evitar desbordes horizontales en general */
  body {
    overflow-x: hidden;
  }
  .first-question-tip {
    width: min(280px, calc(100% - 16px));
    top: auto;
    bottom: 88px;
    transform: translate(calc(-100% - 20px), 0);
  }

  .first-question-tip.first-question-tip--visible {
    transform: translate(8px, 0);
  }

  .first-question-tip.first-question-tip--exit {
    transform: translate(calc(-100% - 20px), 0);
  }

  .corner-image {
      display: none;
  }
  .chat-section {
      width: 100%;
      max-width: 100%;
      height: auto;
      max-height: none;
  }

  .chat-wrapper {
      height: min(65vh, 560px);
      max-height: 65vh;
  }
  .audit-note {
    bottom: 5px;
    right: 50%;
    transform: translateX(50%);
    font-size: 0.65rem;
    padding: 5px 8px;
    max-width: 90%;
    text-align: center;
}
}