/* ============================================================
   Escala de breakpoints del proyecto :
     <= 580px   movil
     <= 900px   tablet vertical / ventana a media pantalla
     <= 1200px  portatil
     >  1200px  escritorio
   Las reglas son max-width: el ORDEN importa — un bloque de rango
   mas ancho (900px) debe declararse ANTES que uno mas estrecho
   (580px), o pisaria a este en el rango <=580px.
   admin-estilos.css usa hoy 600/640/700/960/1100: unificar contra
   esta escala al tocar cada bloque, no en una pasada global.
   ============================================================ */

:root {
    /* Light Theme (Default) */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --warning: #f59e0b;
    --warning-hover: #d97706;

    /* Alpha / glow variants — usados en fondos y bordes de estados */
    --primary-glow: rgba(59, 130, 246, 0.1);
    --primary-alpha-08: rgba(59, 130, 246, 0.08);
    --primary-alpha-15: rgba(59, 130, 246, 0.15);
    --primary-alpha-20: rgba(59, 130, 246, 0.2);
    --error-glow: rgba(239, 68, 68, 0.1);
    --error-alpha-08: rgba(239, 68, 68, 0.08);
    --error-alpha-20: rgba(239, 68, 68, 0.2);
    --accent-alpha-12: rgba(16, 185, 129, 0.12);
    --accent-alpha-20: rgba(16, 185, 129, 0.2);
    --warning-glow: rgba(245, 158, 11, 0.1);

    /* Variantes claras para estados (badges, pills, chips) */
    --accent-light: #34d399;
    --error-light: #f87171;
    --warning-light: #fbbf24;
    --error-dark: #dc2626;

    /* Grises semanticos */
    --border-color: #6b7280;
    --white-alpha-06: rgba(255, 255, 255, 0.06);
    --dark-overlay: rgba(14, 14, 18, 0.7);

    /* Backgrounds */
    --bg-main: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;

    /* Glassmorphism / Surfaces */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-blur: blur(12px);
    --shadow-main: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);

    /* Text */
    --text-main: #111827;
    --text-sub: #4b5563;
    --text-muted: #9ca3af;
    --title-gradient: linear-gradient(135deg, #1f2937 0%, #4b5563 100%);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index scale — unica fuente de verdad para toda la app */
    --z-base:       0;
    --z-raised:     1;
    --z-dropdown:   10;
    --z-sticky:     50;
    --z-overlay:    200;
    --z-modal:      1000;
    --z-modal-top:  1001;
    --z-status:     2000;
    --z-toast:      9999;
    --z-confirm:    10000;
    --z-confirm-top:10001;
}

/* ============================================================
   UTILIDADES — reemplazan inline styles frecuentes
   ============================================================ */
.hidden       { display: none !important; }
.flex-row     { display: flex; flex-direction: row; }
.flex-col     { display: flex; flex-direction: column; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-xs  { gap: 4px; }
.gap-sm  { gap: 8px; }
.gap-md  { gap: 12px; }
.gap-lg  { gap: 16px; }
.gap-xl  { gap: 24px; }
.mt-sm   { margin-top: 8px; }
.mt-md   { margin-top: 12px; }
.mt-lg   { margin-top: 16px; }
.w-full  { width: 100%; }
.text-muted  { color: var(--text-muted); }
.text-error  { color: var(--error); }
.text-accent { color: var(--accent); }
.text-sm     { font-size: 0.82rem; }
.text-xs     { font-size: 0.72rem; }
.fw-600      { font-weight: 600; }

/* Estilos de botones antiguos eliminados para unificacion */

.imagenes-contexto div::-webkit-scrollbar {
    height: 4px;
}

/* Lightbox & Image Wrapper */
.img-wrapper {
    height: 120px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    cursor: zoom-in;
}

.img-wrapper img {
    height: 100%;
    width: auto;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.img-wrapper:hover img {
    transform: scale(1.1);
}

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-overlay.active img {
    transform: scale(1);
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.close-lightbox:hover {
    color: var(--primary);
    transform: scale(1.2);
}

[data-theme='dark'] {
    /* Dark Theme */
    --bg-main: #050505;
    --bg-surface: #101010;
    --bg-card: #2f2f2f;
    --bg-input: #1b1b1b;

    --glass-bg: #2f2f2f;
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-main: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);

    --text-main: #f8f9fa;
    --text-sub: #9ca3af;
    --text-muted: #ffffff;
    --title-gradient: linear-gradient(135deg, #ffffff 0%, #9ca3af 100%);
}

/* Bot Message Utility Actions (Top-Right) */
.top-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 8px;
    z-index: 10;
}

/* Base style for all Bot Buttons (Utility and Feedback) */
.btn-action,
.btn-feedback {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover,
.btn-feedback:hover {
    background: var(--glass-bg);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-action svg,
.btn-feedback svg {
    width: 16px;
    height: 16px;
}

.btn-audio.playing {
    animation: pulse-accent 1.5s infinite;
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-feedback.active-like {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: var(--accent);
}

.btn-feedback.active-dislike {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
}

/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    max-height: 100vh;
    width: 100vw;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Scrollbar Modernization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.35);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.65);
}

/* Layout Components */

/* Header */
.header {
    height: 70px;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.header h2 {
    font-size: 1.25rem;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    font-weight: 700;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-sub);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(128, 128, 128, 0.1);
    color: var(--primary);
}

/* Boton Salir */
.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sub);
    border: 1px solid var(--glass-border);
    padding: 6px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Chat layout: sidebar + main */
.chat-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Chat Area */
#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.msg {
    max-width: 85%;
    position: relative;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Page Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-main);
    position: relative;
    overflow: hidden;
}

.login-background {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: var(--primary);
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.7;
    animation: move 20s infinite alternate ease-in-out;
}

[data-theme='dark'] .blob {
    opacity: 0.7;
    filter: blur(120px);
}

.blob-1 {
    top: -10%;
    left: -10%;
    background: var(--primary);
    animation-duration: 25s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    background: var(--accent);
    animation-duration: 30s;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 300px;
    height: 300px;
    background: #ffffff;
    animation-duration: 20s;
    animation-delay: -10s;
}

@keyframes move {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(100px, 50px) scale(1.1);
    }

    66% {
        transform: translate(-50px, 120px) scale(0.9);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    padding: 3rem;
    border-radius: 32px;
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-main);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.login-card h2 {
    font-size: 2rem;
    margin: 1.5rem 0 0.5rem;
}

.login-card p.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.login-card input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.login-card input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.02);
}

.login-card button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1.1rem;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.login-card button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 16px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: var(--transition);
}

.btn-google:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

#error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 1.5rem;
    min-height: 1.2em;
}

.msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    font-size: 0.95rem;
}

.msg.bot {
    align-self: flex-start;
    background: var(--bg-card);
    width: 100%;
    max-width: 900px;
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    position: relative;
}

.bot-content {
    line-height: 1.7;
    font-size: 0.95rem;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform-origin: center;
    display: inline-block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Input Area - Capsule Design */
.input-area {
    padding: 24px 32px 32px;
    background: linear-gradient(0deg, var(--bg-main) 0%, transparent 100%);
    display: flex;
    justify-content: center;
}

.input-capsule {
    max-width: 900px;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    transition: var(--transition);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.input-capsule:focus-within {
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Custom Select Styles */
.custom-select-container {
    position: relative;
    user-select: none;
    margin-right: 8px;
}

.custom-select {
    position: relative;
    width: 140px;
}

.select-trigger {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0 12px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.select-trigger:hover {
    border-color: var(--primary);
    background: var(--glass-bg);
}

.select-options {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--shadow-main);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.select-options.show {
    display: flex;
}

.option-item {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-item:hover {
    background: var(--primary);
    color: white;
}

.option-item.selected {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.input-capsule input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0 20px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
}

.input-capsule button {
    background: var(--text-main);
    color: var(--bg-main);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: bold;
}

.input-capsule button:hover {
    transform: scale(1.05);
    background: var(--primary);
    color: white;
}

.input-capsule button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Sources & Footers */
.fuentes {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--glass-border);
}

.fuente-item {
    margin-bottom: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.latencia-info {
    font-size: 0.8rem;
}

.fuente-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sub);
    transition: var(--transition);
}

.fuente-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.fuente-content {
    display: none;
    padding: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-muted);
    background: var(--bg-input);
    border-top: 1px solid var(--glass-border);
}

/* ── Fuente de video ──────────────────────────────────── */
.fuente-item-video {
    border-color: rgba(99, 102, 241, 0.3);
}
.fuente-item-video .fuente-header {
    background: rgba(99, 102, 241, 0.05);
}
.fuente-item-video .fuente-header:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* ── Video player wrapper ─────────────────────────────── */
.video-player-wrap {
    background: #000;
    border-bottom: 1px solid var(--glass-border);
    overflow: hidden;
}

/* ── Split layout: player | transcript ───────────────── */
.video-split {
    display: flex;
    min-height: 260px;
    max-height: 380px;
}

.video-split-left {
    flex: 0 0 62%;
    display: flex;
    flex-direction: column;
    background: #000;
    min-width: 0;
}

.video-split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
    min-width: 0;
}

.video-fragment-player {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
    background: #000;
}

.video-fragment-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.7);
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ── Transcript panel (karaoke) ───────────────────────── */
.vt-panel {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: 4px 0;
    scroll-behavior: smooth;
}
.vt-panel::-webkit-scrollbar { width: 3px; }
.vt-panel::-webkit-scrollbar-track { background: transparent; }
.vt-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.vt-loading {
    display: flex; align-items: center; gap: 8px;
    padding: 20px 14px;
    color: var(--text-muted);
    font-size: .75rem;
}
.vt-empty {
    padding: 20px 14px;
    font-size: .78rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Chunk item ───────────────────────────────────────── */
.vt-chunk {
    padding: 7px 12px;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: background .1s, border-color .1s;
    user-select: none;
}
.vt-chunk:hover {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: rgba(99, 102, 241, 0.35);
}
.vt-chunk--active {
    background: rgba(99, 102, 241, 0.13) !important;
    border-left-color: #6366f1 !important;
}
.vt-chunk-head {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 2px;
}
.vt-chunk-time {
    font-size: .65rem; font-weight: 700;
    color: rgba(99, 102, 241, 0.85);
    font-family: monospace;
    min-width: 36px;
    flex-shrink: 0;
}
.vt-chunk-speaker {
    font-size: .65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    opacity: .85;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vt-chunk-text {
    font-size: .76rem; line-height: 1.5;
    color: rgba(255, 255, 255, 0.45);
    transition: color .1s;
}
.vt-chunk--active .vt-chunk-text {
    color: rgba(255, 255, 255, 0.88);
}

/* ── Auto-scroll button ──────────────────────────────── */
.vt-autoscroll-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 7px; border-radius: 5px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer; font-size: .62rem; font-weight: 600;
    transition: all .15s;
    margin-left: auto;
    white-space: nowrap;
}
.vt-autoscroll-btn:hover { border-color: rgba(99, 102, 241, 0.4); }
.vt-autoscroll-active {
    border-color: rgba(99, 102, 241, 0.5) !important;
    color: #a5b4fc !important;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Badges de timestamp y hablante */
.video-ts-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: .68rem; font-weight: 600;
    color: #a5b4fc;
    background: rgba(99, 102, 241, .15);
    border: 1px solid rgba(99, 102, 241, .3);
    border-radius: 5px; padding: 2px 7px;
    white-space: nowrap;
}
.video-speaker-badge {
    display: inline-flex; align-items: center;
    font-size: .68rem; font-weight: 600;
    color: #34d399;
    background: rgba(16, 185, 129, .1);
    border: 1px solid rgba(16, 185, 129, .25);
    border-radius: 5px; padding: 2px 7px;
    white-space: nowrap;
}

/* Responsive: apilar en pantallas estrechas */
/*— select nativo de coleccion  */
.categoria-select {
    border: none;
    background: transparent;
    color: var(--text-sub);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 4px;
    border-radius: 8px;
    cursor: pointer;
    max-width: 220px;
}
.categoria-select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.categoria-select option {
    color: initial;
}

/*  Tablet / ventana a media pantalla: el split de video a dos columnas
   deja menos de 400px por columna y ni el reproductor ni la transcripcion
   son usables. Por debajo de 900px se apila: video arriba, transcripcion
   abajo con altura acotada. DEBE ir ANTES del bloque de 580px (ver escala
   en cabecera). */
@media (max-width: 900px) {
    .video-split {
        flex-direction: column;
    }
    .video-split-left,
    .video-split-right {
        width: 100%;
        min-width: 0;          /* permite encoger dentro del flex */
    }
    .video-split-right {
        max-height: 40vh;      /* la transcripcion no debe empujar el chat */
        overflow-y: auto;
    }
    .vt-entity-index {
        max-height: 5.5rem;
        overflow-y: auto;
    }
}

@media (max-width: 580px) {
    .video-split { flex-direction: column; max-height: none; }
    .video-split-left { flex: none; }
    .video-split-right { height: 200px; border-left: none;
        border-top: 1px solid rgba(255,255,255,0.07); }
}

/* ── Graph Intelligence — 5 features ───────────────────────────────── */

/* F1: Resaltado de entidades por tipo */
.vt-ent {
    border-radius: 2px;
    padding: 0 2px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity .15s, filter .15s;
}
.vt-ent:hover { filter: brightness(1.25); }
.vt-ent--SISTEMA      { background: rgba(59, 130, 246, .22);  color: #93c5fd; }
.vt-ent--MODULO       { background: rgba(6, 182, 212, .22);  color: #67e8f9; }
.vt-ent--PANTALLA     { background: rgba(99, 102, 241, .22); color: #a5b4fc; }
.vt-ent--USUARIO      { background: rgba(52, 211, 153, .22); color: #6ee7b7; }
.vt-ent--ROL          { background: rgba(59, 130, 246, .22);  color: #93c5fd; }
.vt-ent--FILTRO       { background: rgba(236, 72, 153, .22);  color: #f9a8d4; }
.vt-ent--INDICADOR    { background: rgba(249, 115, 22, .22);  color: #fdba74; }
.vt-ent--NORMA        { background: rgba(168, 85, 247, .22);  color: #c4b5fd; }
.vt-ent--OBJETIVO     { background: rgba(20, 184, 166, .22);  color: #5eead4; }
.vt-ent--DOCUMENTO    { background: rgba(107, 114, 128, .22); color: #d1d5db; }
.vt-ent--PARAMETRO    { background: rgba(217, 70, 239, .22);  color: #f0abfc; }
.vt-ent--ORGANIZACION { background: rgba(34, 197, 94, .22);   color: #86efac; }
.vt-ent--HERRAMIENTA  { background: rgba(234, 179, 8, .22);   color: #fde047; }
.vt-ent--PROCESO      { background: rgba(16, 185, 129, .2);   color: #6ee7b7; }
.vt-ent--CONCEPTO     { background: rgba(245, 158, 11, .2);   color: #fcd34d; }

/* F2: Tooltip de entidad */
.vt-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 150px;
    max-width: 230px;
    font-size: .8rem;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .45);
}
.vt-tooltip-type {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 5px;
}
.vt-tooltip-name  { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; word-break: break-word; }
.vt-tooltip-stats { display: flex; gap: 10px; color: var(--text-muted); font-size: .74rem; }

/* F3: Timeline de entidad rastreada */
.vt-timeline {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, .07);
    border-radius: 3px;
    margin: 4px 0 6px;
}
.vt-timeline-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 12px;
    background: var(--primary);
    border-radius: 2px;
    cursor: pointer;
    transform: translateX(-50%);
    transition: background .2s;
}
.vt-timeline-marker:hover { background: #a5b4fc; }

/* F3: Chunk rastreado */
.vt-chunk--tracked {
    border-left: 3px solid var(--primary) !important;
    padding-left: 9px !important;
}

/* F4: Chunk con coincidencia de query */
.vt-chunk--query-match {
    background: rgba(99, 102, 241, .07) !important;
}
.vt-why-badge {
    font-size: .68rem;
    color: var(--primary);
    background: rgba(99, 102, 241, .14);
    border-radius: 10px;
    padding: 1px 7px;
    display: inline-block;
    margin-bottom: 4px;
}

/* F5: Indice de entidades */
.vt-entity-index {
    padding: 6px 8px 5px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.vt-ent-idx-label {
    font-size: .65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-right: 2px;
    white-space: nowrap;
}
.vt-ent-pill {
    font-size: .71rem;
    padding: 2px 7px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: filter .15s, border-color .15s;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vt-ent-pill sup { font-size: .6rem; margin-left: 2px; opacity: .65; }
.vt-ent-pill:hover { filter: brightness(1.2); }
.vt-ent-pill--active { border-color: currentColor !important; filter: brightness(1.25); }

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    z-index: 1000;
}

.modal-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    width: 90%;
    max-width: 550px;
    border-radius: 28px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1001;
    overflow: hidden;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-body {
    padding: 32px;
}

.modal-body p {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 12px;
}

textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    resize: none;
    margin-bottom: 24px;
    transition: var(--transition);
}

textarea:focus {
    border-color: var(--primary);
}

.chip {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-sub);
    margin: 0 8px 8px 0;
    transition: var(--transition);
}

.chip:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Boton de Audio Estilizado */
.audio-player-container {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    padding: 8px 16px;
    border-radius: 12px;
    width: fit-content;
    animation: fadeIn 0.5s ease;
}

/* Estilo base de .btn-audio ahora heredado de .btn-action */

.btn-audio:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
}

.audio-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Outfit', sans-serif;
}

/* Animacion de ondas unificada con .btn-audio.playing arriba */

@keyframes pulse-accent {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Feedback Buttons in Chat */
.feedback-container {
    display: flex;
    gap: 8px;
    margin-top: 1rem;
}

/* Markdown Styling */
.bot-content p {
    margin-bottom: 1rem;
}

.bot-content code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
}

.bot-content pre {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    overflow-x: auto;
    margin: 1rem 0;
}

/* --- ESTILOS PARA EL RENDERIZADO MARKDOWN DE LA IA --- */

.bot-content {
    line-height: 1.6;
}

.bot-content p {
    margin-bottom: 1rem;
}

/* Estilos base para las listas */
.bot-content ul,
.bot-content ol {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    /* Sangria izquierda */
}

/* Vinetas para listas no numeradas */
.bot-content ul {
    list-style-type: disc;
}

/* Numeros para listas numeradas */
.bot-content ol {
    list-style-type: decimal;
}

/* Espaciado entre los elementos de la lista */
.bot-content li {
    margin-bottom: 0.5rem;
}

/* Ajuste para listas anidadas (listas dentro de listas) */
.bot-content ul ul,
.bot-content ol ol,
.bot-content ul ol,
.bot-content ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0;
    /* Evita doble margen abajo */
    list-style-type: circle;
    /* Cambia el punto relleno por un circulo vacio en el subnivel */
}

/* Estilo para las negritas de la IA */
.bot-content strong {
    color: var(--text-main);
    font-weight: 700;
}

/* --- EFECTO DE AUDIO SONANDO (AZUL) --- */
.btn-feedback.playing {
    background: rgba(59, 130, 246, 0.15);
    /* Fondo azul suave */
    color: var(--primary);
    /* Color azul primario para el icono */
    border-color: var(--primary);
    animation: pulse-blue 1.5s infinite;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* ================================================================
   THREAD SIDEBAR
   ================================================================ */
.thread-sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease;
}

.thread-sidebar.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
}

.thread-sidebar-header {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.thread-sidebar-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.thread-list-empty {
    padding: 24px 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
}

.thread-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.thread-item:hover {
    background: rgba(59, 130, 246, 0.07);
    border-color: rgba(59, 130, 246, 0.15);
}

.thread-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
}

.thread-item-title {
    font-size: 0.82rem;
    color: var(--text-main);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.thread-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ================================================================
   INJECTION WARNING BANNER
   ================================================================ */
.injection-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
    flex-shrink: 0;
}

/* ================================================================
   DYNAMIC STATUS MESSAGES (bot loading)
   ================================================================ */
.status-rotating {
    display: inline-block;
    animation: fadeInText 0.4s ease;
}

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

/* ================================================================
   SOURCE ACCORDION: smooth open/close
   ================================================================ */
.fuente-content {
    transition: none;
}

.fuente-content.open {
    display: block !important;
    animation: fadeIn 0.2s ease;
}

/* ================================================================
   PROMPT HISTORY HINT
   ================================================================ */
.input-history-hint {
    position: absolute;
    right: 60px;
    bottom: calc(100% + 4px);
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 3px 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

/* ============================================================
   ACCESIBILIDAD — Movimiento reducido
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .spinner {
        animation-duration: 0.8s !important;
        animation-iteration-count: infinite !important;
    }
}
#btn-admin-panel:hover { background: rgba(59,130,246,0.2) !important; }
