/* ==========================================================================
   Asistente de Búsqueda Cloud (Gemini / Claude)
   Diseño conversacional split-screen conforme a GEMINI.md.
   ========================================================================== */

/* ==========================================================================
   Navbar Compacto + Menú Colapsable (Offcanvas) para vista de aplicación
   ========================================================================== */
.navbar-compact-app {
    background-color: #163a5f;
    min-height: 50px;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .navbar-compact-app {
    background-color: #0e1726;
    border-bottom-color: #233550;
}

.navbar-compact-logo {
    max-height: 32px;
    width: auto;
    display: block;
}

.navbar-compact-menu-btn {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    padding: 0.28rem 0.65rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.navbar-compact-menu-btn:hover,
.navbar-compact-menu-btn:focus-visible {
    color: #ffffff;
    background-color: rgba(33, 171, 165, 0.3);
    border-color: #2dd4bf;
}

.portal-nav-offcanvas {
    max-width: 300px;
    background-color: #ffffff;
    color: #1e293b;
}

[data-bs-theme="dark"] .portal-nav-offcanvas {
    background-color: #0e1726;
    color: #e2e8f0;
    border-right: 1px solid #233550;
}

.portal-nav-offcanvas-header {
    background-color: #163a5f;
    border-bottom: 2px solid var(--brand-accent, #21aba5);
    padding: 0.75rem 1rem;
}

[data-bs-theme="dark"] .portal-nav-offcanvas-header {
    background-color: #172338;
    border-bottom-color: #2dd4bf;
}

.portal-offcanvas-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0 0.65rem 0.4rem;
}

[data-bs-theme="dark"] .portal-offcanvas-section-label {
    color: #94a3b8;
}

.portal-offcanvas-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: #1e293b;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.portal-offcanvas-link i {
    font-size: 1rem;
    color: var(--brand-primary, #155d74);
    width: 1.15rem;
    text-align: center;
}

.portal-offcanvas-link:hover {
    background-color: #f1f5f9;
    color: var(--brand-primary, #155d74);
}

.portal-offcanvas-link.active {
    background-color: rgba(21, 93, 116, 0.1);
    color: var(--brand-primary, #155d74);
    font-weight: 600;
    border-left: 3px solid var(--brand-accent, #21aba5);
}

[data-bs-theme="dark"] .portal-offcanvas-link {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .portal-offcanvas-link i {
    color: #2dd4bf;
}

[data-bs-theme="dark"] .portal-offcanvas-link:hover {
    background-color: #172338;
    color: #ffffff;
}

[data-bs-theme="dark"] .portal-offcanvas-link.active {
    background-color: rgba(45, 212, 191, 0.14);
    color: #2dd4bf;
    border-left-color: #2dd4bf;
}

/* Contenedor central de la conversación */
.asistente-chat-container {
    max-width: 860px;
    width: 100%;
    transition: max-width 0.3s ease;
}

/* Hero Banner condensado con arte institucional */
#asistente-hero .hero-banner {
    position: relative;
    background-color: #163a5f;
    background-image: 
        linear-gradient(90deg, rgba(14, 23, 38, 0.88) 0%, rgba(22, 58, 95, 0.68) 30%, rgba(21, 93, 116, 0.52) 50%, rgba(22, 58, 95, 0.68) 70%, rgba(14, 23, 38, 0.88) 100%),
        url('/images/asistente-ia-hero.jpg');
    background-size: cover;
    background-position: center 46%;
    background-repeat: no-repeat;
    border-bottom: 2px solid var(--brand-accent, #21aba5);
    overflow: hidden;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem !important;
}

[data-bs-theme="dark"] #asistente-hero .hero-banner {
    background-image: 
        linear-gradient(90deg, rgba(10, 16, 26, 0.92) 0%, rgba(17, 35, 58, 0.74) 30%, rgba(15, 67, 84, 0.56) 50%, rgba(17, 35, 58, 0.74) 70%, rgba(10, 16, 26, 0.92) 100%),
        url('/images/asistente-ia-hero.jpg');
    border-bottom-color: #2dd4bf;
}

.asistente-hero-thumb-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(45, 212, 191, 0.75);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    background: #0e1726;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.asistente-hero-thumb-wrap:hover {
    transform: scale(1.06);
    border-color: #2dd4bf;
    box-shadow: 0 6px 16px rgba(33, 171, 165, 0.4);
}

.asistente-hero-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asistente-hero-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.asistente-hero-subtitulo {
    max-width: 680px;
    margin: 0 auto;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.82);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Badge institucional del Hero */
.asistente-ai-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.65rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 999px;
    background: rgba(33, 171, 165, 0.28);
    color: #ffffff;
    border: 1px solid rgba(45, 212, 191, 0.5);
}

.asistente-welcome-lead {
    max-width: 520px;
}

/* Badge de IA genérico para tarjetas */
.asistente-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 999px;
    background: rgba(33, 171, 165, 0.12);
    color: #0f766e;
    border: 1px solid rgba(33, 171, 165, 0.3);
}

[data-bs-theme="dark"] .asistente-ai-badge {
    background: rgba(45, 212, 191, 0.15);
    color: #2dd4bf;
    border-color: rgba(45, 212, 191, 0.3);
}

/* Iconos y avatares de bienvenida */
.asistente-welcome-badge {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(33, 171, 165, 0.15);
    color: var(--brand-accent, #21aba5);
    border: 1px solid rgba(33, 171, 165, 0.35);
}

[data-bs-theme="dark"] .asistente-welcome-badge {
    background: rgba(45, 212, 191, 0.12);
    color: #2dd4bf;
    border-color: rgba(45, 212, 191, 0.35);
}

/* Sugerencias clicables iniciales */
.asistente-sugerencia-btn {
    text-align: left;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: #334155;
    font-size: 0.88rem;
    line-height: 1.4;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.asistente-sugerencia-btn:hover {
    border-color: var(--brand-accent, #21aba5);
    background: #f8fafc;
    color: var(--brand-primary, #155d74);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .asistente-sugerencia-btn {
    background: #172338;
    border-color: #233550;
    color: #cbd5e1;
}

[data-bs-theme="dark"] .asistente-sugerencia-btn:hover {
    border-color: #2dd4bf;
    background: #1e2c45;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Tarjeta contenedora de mensajes (Turnos) */
.asistente-card {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

[data-bs-theme="dark"] .asistente-card {
    background: #172338;
    border-color: #233550;
}

/* ==========================================================================
   Turnos de conversación y avatares
   ========================================================================== */
.chat-turn {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    animation: chatFadeIn 0.2s ease-out;
}

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

.chat-turn-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.chat-avatar {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
    flex-shrink: 0 !important;
    border: none !important;
}

.chat-avatar-user {
    background: var(--brand-dark, #163a5f) !important;
    color: #ffffff !important;
}

.chat-avatar-user i {
    color: #ffffff !important;
    font-size: 1rem;
    line-height: 1;
}

.chat-avatar-bot {
    background: var(--brand-primary, #155d74) !important;
    color: #2dd4bf !important;
}

.chat-avatar-bot i {
    color: #2dd4bf !important;
    font-size: 1rem;
    line-height: 1;
}

[data-bs-theme="dark"] .chat-avatar-bot {
    background: rgba(45, 212, 191, 0.15) !important;
    border: 1px solid rgba(45, 212, 191, 0.3) !important;
}

/* Turno del Usuario */
.chat-turn-user {
    align-items: flex-end;
}

.chat-turn-user .chat-turn-header {
    flex-direction: row-reverse;
}

.chat-bubble-user {
    max-width: 82%;
    background: var(--brand-primary, #155d74);
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
    padding: 0.75rem 1.1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(21, 93, 116, 0.2);
    word-break: break-word;
}

[data-bs-theme="dark"] .chat-bubble-user {
    background: #1d566e;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Turno del Asistente Bot */
.chat-turn-bot,
.chat-turn-assistant {
    align-items: flex-start;
}

.chat-card-bot,
.chat-bubble-assistant {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.15rem 1.25rem;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-bs-theme="dark"] .chat-card-bot,
[data-bs-theme="dark"] .chat-bubble-assistant {
    background: #172338;
    border-color: #233550;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    color: #e2e8f0;
}

.chat-turn-meta {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.35rem;
    padding: 0 0.4rem;
}

/* Pills de conceptos clave */
.asistente-concepto {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0 0.4rem 0.4rem 0;
    padding: 0.28rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: rgba(21, 93, 116, 0.08);
    color: var(--brand-primary, #155d74);
    font-size: 0.85rem;
    font-weight: 500;
}

.asistente-concepto small {
    opacity: 0.75;
    font-size: 0.78rem;
}

.asistente-concepto-omitido {
    background: transparent;
    color: #64748b;
    text-decoration: line-through;
    border-color: #cbd5e1;
}

[data-bs-theme="dark"] .asistente-concepto {
    border-color: #233550;
    background: rgba(45, 212, 191, 0.12);
    color: #2dd4bf;
}

[data-bs-theme="dark"] .asistente-concepto-omitido {
    background: transparent;
    color: #94a3b8;
    border-color: #334155;
}

.asistente-concepto-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0 0.4rem 0.4rem 0;
    padding: 0.28rem 0.65rem;
    border-radius: 6px;
    background: rgba(21, 93, 116, 0.08);
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--brand-primary, #155d74);
}

[data-bs-theme="dark"] .asistente-concepto-pill {
    background: rgba(45, 212, 191, 0.12);
    border-color: #233550;
    color: #2dd4bf;
}

/* Botones de materias Koha */
.asistente-materia-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--brand-primary, #155d74);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.asistente-materia-btn:hover {
    background: var(--brand-primary, #155d74);
    color: #ffffff;
    border-color: var(--brand-primary, #155d74);
}

[data-bs-theme="dark"] .asistente-materia-btn {
    background: #0e1726;
    border-color: #334155;
    color: #2dd4bf;
}

[data-bs-theme="dark"] .asistente-materia-btn:hover {
    background: #2dd4bf;
    color: #0e1726;
    border-color: #2dd4bf;
}

/* Tarjetas de libros del catálogo */
.asistente-libro-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    transition: all 0.2s ease;
    margin-bottom: 0.65rem;
}

.asistente-libro-card:hover {
    border-color: var(--brand-accent, #21aba5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

[data-bs-theme="dark"] .asistente-libro-card {
    background: #111b2b;
    border-color: #233550;
}

[data-bs-theme="dark"] .asistente-libro-card:hover {
    border-color: #2dd4bf;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* Portada del libro */
.asistente-libro-portada-wrap {
    flex-shrink: 0;
    width: 54px;
    height: 76px;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.asistente-libro-portada-wrap:hover {
    transform: scale(1.03);
    border-color: var(--brand-accent, #21aba5);
    box-shadow: 0 4px 10px rgba(21, 93, 116, 0.12);
}

[data-bs-theme="dark"] .asistente-libro-portada-wrap {
    background: #111b2b;
    border-color: #233550;
}

[data-bs-theme="dark"] .asistente-libro-portada-wrap:hover {
    border-color: #2dd4bf;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.asistente-libro-portada {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asistente-libro-portada-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary, #155d74);
    font-size: 1.4rem;
    background: rgba(21, 93, 116, 0.08);
}

[data-bs-theme="dark"] .asistente-libro-portada-fallback {
    color: #2dd4bf;
    background: rgba(45, 212, 191, 0.12);
}

/* Metadatos del libro */
.asistente-libro-info {
    flex: 1 1 auto;
    min-width: 0;
}

.asistente-libro-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    min-width: 18px;
}

.asistente-libro-titulo {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    line-height: 1.35;
}

.asistente-libro-titulo:hover {
    color: var(--brand-accent, #21aba5);
}

[data-bs-theme="dark"] .asistente-libro-titulo {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .asistente-libro-titulo:hover {
    color: #2dd4bf;
}

.asistente-libro-autor {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 0.2rem;
}

[data-bs-theme="dark"] .asistente-libro-autor {
    color: #94a3b8;
}

.asistente-libro-meta {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 0.2rem;
}

[data-bs-theme="dark"] .asistente-libro-meta {
    color: #94a3b8;
}

.asistente-libro-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.asistente-badge-signatura {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    letter-spacing: 0.02em;
}

[data-bs-theme="dark"] .asistente-badge-signatura {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.asistente-badge-disponible {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #065f46;
}

[data-bs-theme="dark"] .asistente-badge-disponible {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}

.asistente-badge-prestado {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #92400e;
}

[data-bs-theme="dark"] .asistente-badge-prestado {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.asistente-libro-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-accent, #21aba5);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.asistente-libro-link:hover {
    color: #0f766e;
    text-decoration: underline;
}

[data-bs-theme="dark"] .asistente-libro-link {
    color: #2dd4bf;
}

/* Banner de llamada a la acción hacia Koha */
.asistente-opac-banner {
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    background: rgba(21, 93, 116, 0.08);
    border: 1px solid rgba(21, 93, 116, 0.2);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
}

[data-bs-theme="dark"] .asistente-opac-banner {
    background: rgba(45, 212, 191, 0.08);
    border-color: rgba(45, 212, 191, 0.2);
}

.asistente-opac-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    background: var(--brand-accent, #21aba5);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.asistente-opac-cta-btn:hover {
    background: #0f766e;
    color: #ffffff;
}

/* ==========================================================================
   Dock de Entrada estilo ChatGPT / Claude / Gemini
   ========================================================================== */
.asistente-dock-container {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
}

.asistente-dock {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0.55rem 0.8rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.asistente-dock:focus-within {
    border-color: var(--brand-accent, #21aba5);
    box-shadow: 0 0 0 3px rgba(33, 171, 165, 0.18);
}

[data-bs-theme="dark"] .asistente-dock {
    background: #172338;
    border-color: #233550;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .asistente-dock:focus-within {
    border-color: #2dd4bf;
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.22);
}

.asistente-input-box {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.asistente-textarea {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0.35rem 0.2rem;
    font-size: 0.94rem;
    line-height: 1.5;
    resize: none;
    min-height: 58px;
    max-height: 160px;
    color: inherit;
    width: 100%;
}

.asistente-textarea::placeholder {
    color: #94a3b8;
}

.asistente-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
}

[data-bs-theme="dark"] .asistente-input-actions {
    border-top-color: rgba(35, 53, 80, 0.6);
}

.asistente-contador {
    font-size: 0.72rem;
    color: #94a3b8;
    user-select: none;
}

.asistente-btn-enviar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: var(--brand-accent, #21aba5);
    color: #ffffff;
    font-size: 1.1rem;
    transition: background-color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
}

.asistente-btn-enviar:disabled {
    background-color: #e2e8f0 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

[data-bs-theme="dark"] .asistente-btn-enviar:disabled {
    background-color: #233550 !important;
    color: #64748b !important;
}

.asistente-btn-enviar:not(:disabled):hover {
    background-color: var(--brand-accent-hover, #10948f);
    transform: scale(1.05);
}

.asistente-btn-enviar:not(:disabled):active {
    transform: scale(0.96);
}

.asistente-dock-footer {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 0.35rem;
    line-height: 1.35;
}

/* Scrollbar estético para el feed conversacional */
#asistente-chat-scroll,
.asistente-chat-scroll {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

[data-bs-theme="dark"] #asistente-chat-scroll,
[data-bs-theme="dark"] .asistente-chat-scroll {
    scrollbar-color: #233550 transparent;
}

#asistente-chat-scroll::-webkit-scrollbar,
.asistente-chat-scroll::-webkit-scrollbar {
    width: 6px;
}

#asistente-chat-scroll::-webkit-scrollbar-track,
.asistente-chat-scroll::-webkit-scrollbar-track {
    background: transparent;
}

#asistente-chat-scroll::-webkit-scrollbar-thumb,
.asistente-chat-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

[data-bs-theme="dark"] #asistente-chat-scroll::-webkit-scrollbar-thumb,
[data-bs-theme="dark"] .asistente-chat-scroll::-webkit-scrollbar-thumb {
    background: #233550;
}

/* Distribución de la conversación */
#asistente-main-wrap {
    height: 100%;
    min-height: 0;
}

#asistente-col-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

#asistente-chat-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.4rem;
    min-height: 0;
}

#asistente-col-frame {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.asistente-frame-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    background: #ffffff;
}

[data-bs-theme="dark"] .asistente-frame-card {
    background: #172338;
    border-color: #233550;
}

.asistente-frame-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .asistente-frame-header {
    background: #111b2b;
    border-bottom-color: #233550;
}

.asistente-frame-body {
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    position: relative;
}

.asistente-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Loading overlay para iframe */
.asistente-frame-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 10;
}

[data-bs-theme="dark"] .asistente-frame-loading {
    background: rgba(23, 35, 56, 0.9);
    color: #f1f5f9;
}

/* Footer institucional compacto */
.asistente-footer {
    background-color: #163a5f;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 0.78rem;
    padding: 0.45rem 1rem;
    flex-shrink: 0;
    margin-top: auto;
    z-index: 10;
}

[data-bs-theme="dark"] .asistente-footer {
    background-color: #0e1726;
    border-top: 1px solid #233550;
    color: #cbd5e1;
}

.asistente-footer-logo {
    height: 18px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.asistente-footer-copy {
    font-size: 0.76rem;
    opacity: 0.9;
}

.asistente-footer-nav {
    font-size: 0.76rem;
}

.asistente-footer-link {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: color 0.15s ease;
    background: none;
    border: none;
    padding: 0;
    font-size: 0.76rem;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.asistente-footer-link:hover {
    color: var(--brand-accent, #21aba5);
    text-decoration: none;
}

[data-bs-theme="dark"] .asistente-footer-link {
    color: #94a3b8;
}

[data-bs-theme="dark"] .asistente-footer-link:hover {
    color: #2dd4bf;
}

/* Distribución fija de altura (Desktop y Móvil tipo App) */
#asistente {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.asistente-chat-container {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

#asistente-col-chat {
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#asistente-chat-scroll {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 0.35rem;
    padding-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    #asistente-hero .hero-banner {
        min-height: 0 !important;
        padding: 0.55rem 0.75rem !important;
    }
    .asistente-hero-title,
    #asistente-hero h1 {
        font-size: 1.05rem !important;
        line-height: 1.25;
    }
}

@media (max-width: 767.98px) {
    #asistente-hero .hero-banner {
        min-height: 0 !important;
        padding: 0.45rem 0.65rem !important;
    }
    .asistente-hero-title,
    #asistente-hero h1 {
        font-size: 0.95rem !important;
    }

    /* Barra de selección de fuentes en una sola fila deslizable y limpia */
    .asistente-fuentes-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 0.35rem;
        margin-bottom: 0.25rem;
    }
    .asistente-fuentes-bar::-webkit-scrollbar {
        display: none;
    }
    .asistente-fuentes-label {
        display: none;
    }
    .asistente-fuentes-chips {
        flex-wrap: nowrap;
        gap: 0.3rem;
    }
    .asistente-fuente-chip {
        white-space: nowrap;
        padding: 0.22rem 0.55rem;
        font-size: 0.73rem;
        flex-shrink: 0;
    }

    /* Pestañas de resultados en tira horizontal deslizable sin apilarse */
    .asistente-tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 0.5rem;
        margin-bottom: 0.75rem;
    }
    .asistente-tabs-nav::-webkit-scrollbar {
        display: none;
    }
    .asistente-tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.35rem 0.65rem;
        font-size: 0.76rem;
    }

    /* Simplificar tarjetas y ocultar elementos decorativos/secundarios en móvil */
    .asistente-prompt-card {
        padding: 0.55rem 0.75rem;
    }
    .asistente-opac-cta-box p,
    .asistente-contador {
        display: none !important;
    }
    .asistente-libro-card {
        padding: 0.65rem 0.75rem;
        gap: 0.6rem;
    }
    .asistente-libro-portada-wrap {
        width: 40px;
        height: 54px;
    }
    .chat-card-bot {
        padding: 0.75rem 0.85rem;
    }
    .asistente-dock {
        padding: 0.45rem 0.65rem;
        margin-bottom: 0.25rem !important;
    }
}

@media (max-width: 575.98px) {
    /* En pantallas muy estrechas, ocultar cajas de icono genéricas para dar 100% de ancho al texto del artículo/libro */
    .asistente-libro-portada-wrap:has(.asistente-libro-portada-fallback) {
        display: none;
    }
}

/* ==========================================================================
   Selector Rápido de Fuentes en el Dock y Pestañas Multi-Fuente
   Cumplimiento estricto de GEMINI.md (Paleta #155d74 / #21aba5, Claro/Oscuro)
   ========================================================================== */

/* Selector de fuentes encima del input */
.asistente-fuentes-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px dashed rgba(226, 232, 240, 0.7);
}

[data-bs-theme="dark"] .asistente-fuentes-bar {
    border-bottom-color: rgba(35, 53, 80, 0.65);
}

.asistente-fuentes-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-right: 0.15rem;
    user-select: none;
}

[data-bs-theme="dark"] .asistente-fuentes-label {
    color: #94a3b8;
}

.asistente-fuentes-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.asistente-fuente-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.24rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.asistente-fuente-chip:hover {
    border-color: #21aba5;
    color: #155d74;
    background: #f1f5f9;
}

.asistente-fuente-chip.active {
    background: rgba(21, 93, 116, 0.1);
    border-color: #21aba5;
    color: #155d74;
}

.asistente-fuente-chip.active i {
    color: #21aba5;
}

[data-bs-theme="dark"] .asistente-fuente-chip {
    background: #0e1726;
    border-color: #233550;
    color: #94a3b8;
}

[data-bs-theme="dark"] .asistente-fuente-chip:hover {
    border-color: #2dd4bf;
    color: #e2e8f0;
    background: #172338;
}

[data-bs-theme="dark"] .asistente-fuente-chip.active {
    background: rgba(33, 171, 165, 0.18);
    border-color: #2dd4bf;
    color: #f8fafc;
}

/* Barra compacta de filtros por rango de años e idioma */
.asistente-filtros-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    padding-bottom: 0.45rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

[data-bs-theme="dark"] .asistente-filtros-bar {
    border-bottom-color: rgba(35, 53, 80, 0.75);
}

.asistente-filtro-grupo {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.asistente-filtro-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0;
    user-select: none;
    white-space: nowrap;
}

[data-bs-theme="dark"] .asistente-filtro-label {
    color: #94a3b8;
}

.asistente-filtro-sep {
    font-size: 0.78rem;
    color: #94a3b8;
    user-select: none;
}

.asistente-filtro-anio,
.asistente-filtro-select {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
    line-height: 1.35;
}

.asistente-filtro-anio {
    width: 74px;
    text-align: center;
    -moz-appearance: textfield;
}

.asistente-filtro-anio::-webkit-outer-spin-button,
.asistente-filtro-anio::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.asistente-filtro-select {
    padding-right: 1.5rem;
    cursor: pointer;
}

.asistente-filtro-anio:focus,
.asistente-filtro-select:focus {
    outline: none;
    border-color: var(--brand-accent, #21aba5);
    background: #ffffff;
}

.asistente-filtro-anio.is-active,
.asistente-filtro-select.is-active {
    background: rgba(21, 93, 116, 0.1);
    border-color: #21aba5;
    color: #155d74;
}

[data-bs-theme="dark"] .asistente-filtro-anio,
[data-bs-theme="dark"] .asistente-filtro-select {
    background: #0e1726;
    border-color: #233550;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .asistente-filtro-anio:focus,
[data-bs-theme="dark"] .asistente-filtro-select:focus {
    border-color: #2dd4bf;
    background: #172338;
}

[data-bs-theme="dark"] .asistente-filtro-anio.is-active,
[data-bs-theme="dark"] .asistente-filtro-select.is-active {
    background: rgba(33, 171, 165, 0.18);
    border-color: #2dd4bf;
    color: #f8fafc;
}

.asistente-filtro-clear {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: auto;
}

.asistente-filtro-clear:hover {
    color: #155d74;
    background: #f1f5f9;
    border-color: #cbd5e1;
}

[data-bs-theme="dark"] .asistente-filtro-clear {
    color: #94a3b8;
}

[data-bs-theme="dark"] .asistente-filtro-clear:hover {
    color: #2dd4bf;
    background: #172338;
    border-color: #233550;
}

/* Badge de filtro aplicado en la cabecera de la respuesta */
.asistente-badge-filtro {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(21, 93, 116, 0.08);
    color: #155d74;
    border: 1px solid rgba(33, 171, 165, 0.35);
}

[data-bs-theme="dark"] .asistente-badge-filtro {
    background: rgba(45, 212, 191, 0.12);
    color: #2dd4bf;
    border-color: rgba(45, 212, 191, 0.3);
}

[data-bs-theme="dark"] .asistente-fuente-chip.active i {
    color: #2dd4bf;
}

/* Tarjetas de prompts iniciales */
.asistente-prompt-card {
    text-align: left;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    transition: all 0.18s ease;
    cursor: pointer;
}

.asistente-prompt-card:hover {
    border-color: #21aba5;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(21, 93, 116, 0.08);
}

[data-bs-theme="dark"] .asistente-prompt-card {
    background: #172338;
    border-color: #233550;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .asistente-prompt-card:hover {
    border-color: #2dd4bf;
    background: #1c2b44;
}

/* Indicador de consulta en proceso */
.asistente-thinking-box {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

[data-bs-theme="dark"] .asistente-thinking-box {
    background: #172338;
    border-color: #233550;
    color: #e2e8f0;
}

.asistente-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.asistente-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #21aba5;
    animation: dotPulse 1.2s infinite ease-in-out;
}

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

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1.1); }
}

.asistente-timer-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: #f1f5f9;
    color: #64748b;
}

[data-bs-theme="dark"] .asistente-timer-pill {
    background: #0e1726;
    color: #94a3b8;
}

/* Navegación por pestañas dentro de la respuesta del asistente */
.asistente-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

[data-bs-theme="dark"] .asistente-tabs-nav {
    border-bottom-color: #233550;
}

.asistente-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.8rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.asistente-tab-btn:hover {
    border-color: #21aba5;
    color: #155d74;
    background: #ffffff;
}

.asistente-tab-btn.active {
    background: #155d74;
    border-color: #155d74;
    color: #ffffff;
}

[data-bs-theme="dark"] .asistente-tab-btn {
    background: #0e1726;
    border-color: #233550;
    color: #94a3b8;
}

[data-bs-theme="dark"] .asistente-tab-btn:hover {
    border-color: #2dd4bf;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .asistente-tab-btn.active {
    background: #21aba5;
    border-color: #21aba5;
    color: #ffffff;
}

.asistente-tab-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.08rem 0.42rem;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
}

.asistente-tab-btn.active .asistente-tab-badge {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

[data-bs-theme="dark"] .asistente-tab-badge {
    background: rgba(255, 255, 255, 0.08);
}

.asistente-tab-panel {
    display: none;
}

.asistente-tab-panel.active {
    display: block;
    animation: chatFadeIn 0.15s ease-out;
}

/* Badges de Área Temática, Base de Datos EDS y Motor OA */
.asistente-badge-area {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    background: rgba(21, 93, 116, 0.1);
    border: 1px solid rgba(21, 93, 116, 0.25);
    color: #155d74;
}

[data-bs-theme="dark"] .asistente-badge-area {
    background: rgba(45, 212, 191, 0.14);
    border-color: rgba(45, 212, 191, 0.3);
    color: #2dd4bf;
}

.asistente-badge-db {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.16rem 0.5rem;
    border-radius: 4px;
    background: rgba(22, 58, 95, 0.1);
    border: 1px solid rgba(22, 58, 95, 0.22);
    color: #163a5f;
}

[data-bs-theme="dark"] .asistente-badge-db {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.3);
    color: #7dd3fc;
}

.asistente-badge-oa-motor {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.16rem 0.5rem;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #065f46;
}

[data-bs-theme="dark"] .asistente-badge-oa-motor {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}

/* Grid de portales de Biblioteca Virtual */
.asistente-portales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.asistente-portal-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    transition: all 0.18s ease;
}

.asistente-portal-card:hover {
    border-color: #21aba5;
    box-shadow: 0 4px 12px rgba(21, 93, 116, 0.08);
    transform: translateY(-1px);
}

[data-bs-theme="dark"] .asistente-portal-card {
    background: #111b2b;
    border-color: #233550;
}

[data-bs-theme="dark"] .asistente-portal-card:hover {
    border-color: #2dd4bf;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.asistente-portal-nombre {
    font-size: 0.9rem;
    font-weight: 700;
    color: #155d74;
}

[data-bs-theme="dark"] .asistente-portal-nombre {
    color: #f1f5f9;
}

.asistente-portal-org {
    font-size: 0.74rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.35rem;
}

[data-bs-theme="dark"] .asistente-portal-org {
    color: #94a3b8;
}

.asistente-portal-desc {
    font-size: 0.8rem;
    line-height: 1.45;
    color: #475569;
    margin-bottom: 0.5rem;
}

[data-bs-theme="dark"] .asistente-portal-desc {
    color: #94a3b8;
}

.asistente-portal-btn {
    padding: 0.28rem 0.65rem;
    font-size: 0.76rem;
}

.asistente-base-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 2px;
    flex-shrink: 0;
}

/* Secciones complementarias de resultados */
.asistente-libros-titulo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.asistente-libros-titulo {
    font-size: 0.88rem;
    font-weight: 700;
    color: #155d74;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

[data-bs-theme="dark"] .asistente-libros-titulo {
    color: #2dd4bf;
}

.asistente-opac-cta-box {
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-top: 0.75rem;
}

[data-bs-theme="dark"] .asistente-opac-cta-box {
    background: #0e1726;
    border-color: #233550;
}

.asistente-etiqueta {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

[data-bs-theme="dark"] .asistente-etiqueta {
    color: #94a3b8;
}

.asistente-consulta-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.4rem;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

[data-bs-theme="dark"] .asistente-consulta-wrapper {
    background: #0e1726;
    border-color: #233550;
}

.asistente-consulta {
    font-size: 0.8rem;
    color: #155d74;
    word-break: break-all;
}

[data-bs-theme="dark"] .asistente-consulta {
    color: #2dd4bf;
}

.asistente-btn-copiar {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .asistente-btn-copiar {
    background: #172338;
    border-color: #334155;
    color: #e2e8f0;
}

