/* ==========================================================================
   VARIABLES DE TEMA
   ========================================================================== */
:root {
    --primary-color: #0B516E;
    --primary-light: #0d82af;
    --accent-color: #00a8ff;
    --bg-body: #f8f9fa;
    --card-bg: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --navbar-bg: #ffffff;
    --navbar-border: rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 35px rgba(11, 81, 110, 0.15);
}

/* ==========================================================================
   MODO OSCURO / NOCTURNO (AJUSTADO EXACTAMENTE A LA CAPTURA)
   ========================================================================== */
[data-theme="dark"],
html[data-theme="dark"] {
    --primary-color: #00a8ff;
    --primary-light: #38bdf8;
    --accent-color: #00a8ff;
    --bg-body: #060b17;
    --card-bg: #0c162c;
    --text-dark: #f1f5f9;
    --text-muted: #8fa0ba;
    --white: #0c162c;
    --navbar-bg: #08101e;
    --navbar-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 15px 35px rgba(0, 102, 204, 0.25);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-dark);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

[data-theme="dark"] body,
[data-theme="dark"] body.bg-light {
    background-color: #060b17 !important;
    color: #f1f5f9 !important;
}

/* ANIMACIONES */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.6s ease backwards;
}

/* ==========================================================================
   NAVBAR (MODO CLARO Y MODO OSCURO)
   ========================================================================== */
.navbar {
    background: #ffffff !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1050 !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand-logo-text {
    color: #0B516E;
    font-weight: 800;
    font-size: 1.25rem;
}

.navbar .nav-link {
    color: #0B516E !important;
    font-weight: 500;
    transition: var(--transition);
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #0d82af !important;
}

.user-greeting-link {
    color: #0B516E;
    font-size: 0.95rem;
}

.nav-notification-btn {
    color: #0B516E;
    transition: var(--transition);
}

.theme-toggle {
    color: #0B516E;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: var(--transition);
}

.theme-toggle:hover {
    transform: scale(1.15);
}

/* NAVBAR EN MODO OSCURO */
[data-theme="dark"] .navbar {
    background: #08101e !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    z-index: 1050 !important;
}

[data-theme="dark"] .brand-logo-text {
    color: #ffffff !important;
}

[data-theme="dark"] .navbar .nav-link {
    color: #38bdf8 !important;
}

[data-theme="dark"] .navbar .nav-link:hover,
[data-theme="dark"] .navbar .nav-link.active {
    color: #7dd3fc !important;
}

[data-theme="dark"] .user-greeting-link {
    color: #ffffff !important;
}

[data-theme="dark"] .nav-notification-btn {
    color: #ffffff !important;
}

[data-theme="dark"] .theme-toggle i {
    color: #facc15 !important; /* Sol dorado brillante */
}

[data-theme="dark"] .theme-toggle i.fa-moon:before {
    content: "\f185" !important; /* fa-sun icon */
}

/* Botones Login y Registro en Navbar */
.btn-login-nav,
.navbar .btn-outline-light {
    border: 1.5px solid #0B516E !important;
    color: #0B516E !important;
    background: transparent !important;
    transition: var(--transition);
}

.btn-login-nav:hover,
.navbar .btn-outline-light:hover {
    background-color: #0B516E !important;
    color: #ffffff !important;
}

.btn-register-nav {
    background: #0066cc !important;
    color: #ffffff !important;
    border: none !important;
    transition: var(--transition);
}

.btn-register-nav:hover {
    background: #0052a3 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

[data-theme="dark"] .btn-login-nav,
[data-theme="dark"] .navbar .btn-outline-light {
    border: 1.5px solid #38bdf8 !important;
    color: #ffffff !important;
    background: transparent !important;
}

[data-theme="dark"] .btn-login-nav:hover,
[data-theme="dark"] .navbar .btn-outline-light:hover {
    background-color: #38bdf8 !important;
    color: #08101e !important;
}

[data-theme="dark"] .btn-register-nav {
    background: #0066cc !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-register-nav:hover {
    background: #0052a3 !important;
    color: #ffffff !important;
}

/* ==========================================================================
   HERO / BUSCADOR SECTION (MODO OSCURO EXACTO A LA IMAGEN)
   ========================================================================== */
.search-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 50px 30px;
    border-radius: 28px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.03);
    margin: 30px 0 40px 0;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.hero-title {
    font-size: 2.5rem;
    color: #0B516E;
    font-weight: 800;
}

.hero-title span {
    color: #00a8ff;
}

/* MODO OSCURO HERO SECTION */
[data-theme="dark"] .search-container {
    background: linear-gradient(135deg, #09264c 0%, #061833 100%) !important;
    border: 1px solid rgba(56, 189, 248, 0.22) !important;
    border-radius: 28px !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .hero-title {
    color: #ffffff !important;
}

[data-theme="dark"] .hero-title span {
    color: #00a8ff !important;
}

/* Barra de Búsqueda Rediseñada */
.search-input-group {
    background: #ffffff !important;
    border: none !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    padding: 4px 6px 4px 18px;
    display: flex;
    align-items: center;
}

.search-input-group .search-icon-box {
    background: transparent !important;
    border: none !important;
    color: #0066cc !important;
    font-size: 1.15rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.search-input-group input.search-field {
    background: transparent !important;
    border: none !important;
    color: #1e293b !important;
    font-size: 1.05rem;
    box-shadow: none !important;
}

.search-input-group input.search-field::placeholder {
    color: #64748b !important;
    font-size: 1rem;
}

.btn-search-hero {
    background: #0066cc !important;
    color: #ffffff !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    padding: 10px 28px !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.3) !important;
    transition: var(--transition);
}

.btn-search-hero:hover {
    background: #0052a3 !important;
    color: #ffffff !important;
    transform: scale(1.02);
}

/* ==========================================================================
   BANNER: CONTINUAR LEYENDO (FONDO BLANCO EN MODO OSCURO SEGÚN IMAGEN)
   ========================================================================== */
.continue-reading-card {
    background: #ffffff !important;
    border-radius: 24px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
    border: none !important;
    transition: var(--transition);
}

.continue-reading-card .continue-title {
    color: #0f172a !important;
    font-weight: 800 !important;
    font-size: 1.2rem;
}

.continue-reading-card .continue-subtitle {
    color: #64748b !important;
    font-size: 0.9rem;
}

.continue-reading-card .badge-continue {
    background-color: #0066cc !important;
    color: #ffffff !important;
    letter-spacing: 0.5px;
    font-size: 0.72rem;
    padding: 6px 14px;
}

.continue-reading-card .btn-open-book {
    background-color: #005bb5 !important;
    color: #ffffff !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    padding: 9px 24px !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 91, 181, 0.3) !important;
    transition: var(--transition);
}

.continue-reading-card .btn-open-book:hover {
    background-color: #00448a !important;
    color: #ffffff !important;
    transform: translateY(-2px);
}

/* ==========================================================================
   SECCIÓN: ESPECIAL PARA (CARRERA)
   ========================================================================== */
.career-badge-icon {
    background-color: #0066cc;
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.career-section-title {
    color: #1e293b;
    font-weight: 700;
}

[data-theme="dark"] .career-section-title {
    color: #ffffff !important;
}

.career-highlight {
    color: #00a8ff !important;
    font-weight: 700;
}

/* ==========================================================================
   TARJETAS DE LIBROS (RECOMENDADOS Y CATÁLOGO DESTACADO)
   ========================================================================== */
.book-card,
.book-card-small {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.05);
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.book-card:hover,
.book-card-small:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(11, 81, 110, 0.15) !important;
}

.book-card .card-img-top,
.book-card-small .card-img-top {
    object-fit: cover !important;
    padding: 0 !important;
    background: #f0f2f5;
    transition: transform 0.5s ease;
}

.book-card .card-img-top {
    height: 300px !important;
}

.book-card-small .card-img-top {
    height: 220px !important;
}

.book-card:hover .card-img-top,
.book-card-small:hover .card-img-top {
    transform: scale(1.04);
}

.book-card .card-title,
.book-card-small .card-title {
    color: #0B516E;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.35;
}

.card-author {
    color: #64748b;
    font-size: 0.85rem;
}

/* TARJETAS EN MODO OSCURO (EXACTO A LA IMAGEN) */
[data-theme="dark"] .book-card,
[data-theme="dark"] .book-card-small {
    background-color: #0c162c !important;
    border: 1px solid rgba(56, 189, 248, 0.12) !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35) !important;
}

[data-theme="dark"] .book-card:hover,
[data-theme="dark"] .book-card-small:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 35px rgba(0, 102, 204, 0.25) !important;
    border-color: rgba(56, 189, 248, 0.32) !important;
}

[data-theme="dark"] .book-card .card-img-top,
[data-theme="dark"] .book-card-small .card-img-top {
    background-color: #08101e !important;
}

[data-theme="dark"] .book-card .card-title,
[data-theme="dark"] .book-card-small .card-title {
    color: #0099ff !important;
    font-weight: 700 !important;
}

[data-theme="dark"] .book-card .card-author,
[data-theme="dark"] .book-card-small .card-author {
    color: #8fa0ba !important;
}

/* OVERLAY CON GLASSMORPHISM */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 38, 76, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 10;
}

.book-card:hover .card-overlay,
.book-card-small:hover .card-overlay {
    opacity: 1;
}

.card-overlay .btn {
    transform: translateY(15px);
    transition: all 0.35s ease;
}

.book-card:hover .card-overlay .btn,
.book-card-small:hover .card-overlay .btn {
    transform: translateY(0);
}

/* SECCIONES Y ENCABEZADOS EN MODO OSCURO */
[data-theme="dark"] .section-title-destacados {
    color: #ffffff !important;
}

[data-theme="dark"] .section-title-destacados .highlight-word {
    color: #00a8ff !important;
}

[data-theme="dark"] .section-subtitle-destacados {
    color: #8fa0ba !important;
}

[data-theme="dark"] .border-bottom {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   DROPDOWNS, NOTIFICACIONES Y SUGERENCIAS EN MODO OSCURO
   ========================================================================== */
[data-theme="dark"] .dropdown-menu {
    background-color: #0c162c !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .dropdown-menu .list-group-item {
    background-color: #0c162c !important;
    color: #f1f5f9 !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .dropdown-menu .list-group-item:hover {
    background-color: #13223f !important;
}

[data-theme="dark"] .dropdown-menu .list-group-item h6 {
    color: #ffffff !important;
}

[data-theme="dark"] .dropdown-menu .bg-light {
    background-color: #08101e !important;
}

/* Autocomplete Container */
[data-theme="dark"] #sugerenciasContainer {
    background: rgba(12, 22, 44, 0.98) !important;
    border-color: rgba(56, 189, 248, 0.25) !important;
}

[data-theme="dark"] #sugerenciasContainer .list-group-item {
    background-color: transparent !important;
    color: #f1f5f9 !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] #sugerenciasContainer .list-group-item:hover {
    background-color: #13223f !important;
}

[data-theme="dark"] #sugerenciasContainer .text-dark {
    color: #ffffff !important;
}

/* ==========================================================================
   FORMULARIOS Y PÁGINAS GENERALES (SOLICITAR, PERFIL, LOGIN)
   ========================================================================== */
[data-theme="dark"] .card:not(.continue-reading-card) {
    background-color: #0c162c !important;
    border: 1px solid rgba(56, 189, 248, 0.12) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .card-header.bg-primary {
    background-color: #0066cc !important;
}

[data-theme="dark"] .form-control:not(.search-field),
[data-theme="dark"] .form-control.bg-light,
[data-theme="dark"] .form-select {
    background-color: #101c36 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .form-control:not(.search-field):focus,
[data-theme="dark"] .form-select:focus {
    background-color: #132242 !important;
    border-color: #00a8ff !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(0, 168, 255, 0.2) !important;
}

[data-theme="dark"] .form-label,
[data-theme="dark"] .form-floating label {
    color: #8fa0ba !important;
}

[data-theme="dark"] .text-dark {
    color: #ffffff !important;
}

/* ==========================================================================
   PAGINACIÓN
   ========================================================================== */
.page-link {
    border-radius: 10px !important;
    margin: 0 3px;
    border: none;
    color: #0B516E;
    font-weight: 500;
}

.page-item.active .page-link {
    background-color: #0066cc;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 102, 204, 0.3);
}

[data-theme="dark"] .page-link {
    background-color: #0c162c;
    color: #38bdf8;
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: #0066cc;
    color: #ffffff;
}

/* ==========================================================================
   FOOTER PREMIUM
   ========================================================================== */
.footer-premium {
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

[data-theme="dark"] .footer-premium {
    background-color: #08101e !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #8fa0ba !important;
}

[data-theme="dark"] .footer-premium .text-muted,
[data-theme="dark"] .footer-premium a {
    color: #8fa0ba !important;
}

[data-theme="dark"] .footer-premium a:hover {
    color: #00a8ff !important;
}

/* ==========================================================================
   VISTA DE DETALLE DEL LIBRO (LIBRO.PHP) Y MODO NOCTURNO
   ========================================================================== */
/* Migas de Pan (Breadcrumb) */
.breadcrumb-item a {
    color: #0B516E;
    font-weight: 500;
}

.breadcrumb-item.active {
    color: #64748b;
    font-weight: 500;
}

[data-theme="dark"] .breadcrumb-item a {
    color: #38bdf8 !important;
}

[data-theme="dark"] .breadcrumb-item.active {
    color: #f1f5f9 !important; /* Texto del libro 100% visible en modo oscuro */
}

[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: #8fa0ba !important;
}

/* Botón de Favorito Flotante */
.btn-favorito {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
    outline: none;
    z-index: 15 !important;
}

.btn-favorito i {
    font-size: 1.35rem;
    color: #ef4444;
    transition: transform 0.2s ease, color 0.2s ease;
}

.btn-favorito:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .btn-favorito {
    background: #0f1c38 !important;
    border: 1px solid rgba(56, 189, 248, 0.25) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .btn-favorito:hover {
    border-color: rgba(255, 77, 109, 0.5) !important;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35) !important;
}

[data-theme="dark"] .btn-favorito i {
    color: #ff4d6d !important; /* Rojo luminoso sobre fondo oscuro */
}

/* Sidebar de Información del Libro */
.book-detail-card {
    z-index: 10 !important;
}
[data-theme="dark"] .book-cover-wrapper {
    background-color: #08101e !important;
}

[data-theme="dark"] .book-detail-body {
    background-color: #0c162c !important;
}

[data-theme="dark"] .badge-recurso {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
}

[data-theme="dark"] .book-title-main {
    color: #ffffff !important;
}

[data-theme="dark"] .book-author-label {
    color: #8fa0ba !important;
}

[data-theme="dark"] .book-author-name {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .btn-download-pdf {
    border-color: #38bdf8 !important;
    color: #38bdf8 !important;
}

[data-theme="dark"] .btn-download-pdf:hover {
    background-color: #38bdf8 !important;
    color: #08101e !important;
}

[data-theme="dark"] .share-label {
    color: #8fa0ba !important;
}

[data-theme="dark"] .btn-copy-link {
    background-color: #0f1c38 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

/* Header del Visor PDF (Lectura Online) */
.pdf-viewer-header {
    background: #ffffff;
    transition: var(--transition);
}

[data-theme="dark"] .pdf-viewer-header {
    background-color: #0c162c !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .pdf-viewer-header h5 {
    color: #ffffff !important; /* Texto 'Lectura Online' legible en modo oscuro */
}

[data-theme="dark"] .pdf-viewer-header .btn-group {
    border-color: rgba(255, 255, 255, 0.15) !important;
}

[data-theme="dark"] .pdf-viewer-header .btn-group .btn {
    background-color: #101c36 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .pdf-viewer-header .btn-group .btn:hover {
    background-color: #16264a !important;
}

/* Caja de Sinopsis / Descripción */
.synopsis-box {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.06) !important;
}

[data-theme="dark"] .synopsis-box {
    background-color: #0c162c !important;
    border-color: rgba(56, 189, 248, 0.12) !important;
}

[data-theme="dark"] .synopsis-title {
    color: #ffffff !important;
}

[data-theme="dark"] .synopsis-text {
    color: #cbd5e1 !important;
}

/* Material sugerido para tu carrera */
[data-theme="dark"] .related-title {
    color: #ffffff !important;
    border-color: #00a8ff !important;
}

[data-theme="dark"] .card-hover {
    background-color: #0c162c !important;
    border: 1px solid rgba(56, 189, 248, 0.12) !important;
}

[data-theme="dark"] .related-book-title {
    color: #0099ff !important;
}

[data-theme="dark"] .related-book-author {
    color: #8fa0ba !important;
}