:root {
    /* Nueva Paleta "Biblioteca Universitaria Seria" */
    --primary-color: #0c2461;
    /* Azul Marino Profundo - Institucional */
    --secondary-color: #1e3799;
    /* Azul Real - Interacción */
    --accent-color: #4a69bd;
    /* Azul Acero - Detalles */
    --success-color: #079992;
    /* Verde Profesional */
    --danger-color: #b71540;
    /* Rojo Intenso */
    --warning-color: #e58e26;
    /* Naranja Quemado */

    /* Variables de Tema Defaults (Light) */
    --bg-body: #f1f2f6;
    --bg-card: #ffffff;
    --bg-navbar: #ffffff;
    --text-main: #2f3542;
    --text-muted: #747d8c;
    --border-color: rgba(0, 0, 0, 0.1);

    --sidebar-bg: #0a3d62;
    /* Sidebar Admin */
    --sidebar-text: #dfe4ea;

    /* Sombras y Efectos */
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0 10px 20px rgba(12, 36, 97, 0.15);
    --gradient-primary: linear-gradient(135deg, #0c2461 0%, #1e3799 100%);
    --gradient-header: linear-gradient(135deg, #0a3d62 0%, #3c6382 100%);
}

/* Variables para Modo Oscuro */
body.dark-mode {
    --primary-color: #4a69bd;
    /* Ajustado para mejor contraste en dark */
    --secondary-color: #6a89cc;

    --bg-body: #1e272e;
    --bg-card: #2f3542;
    --bg-navbar: #2f3542;
    --text-main: #f1f2f6;
    --text-muted: #a4b0be;
    --border-color: rgba(255, 255, 255, 0.1);

    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --hover-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);

    /* Sidebar mantiene tono pero ajusta */
    --sidebar-bg: #0c2461;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    /* Ajuste para navbar fixed */
    padding-top: 70px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =========================================
   COMPONENTES GLOBALES
   ========================================= */

/* Botones */
.btn-primary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

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

.btn-outline-primary {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-outline-primary:hover {
    background-color: var(--secondary-color);
    color: white;
}

/* Navbar Pública */
/* Navbar Pública */
.navbar {
    background: var(--bg-navbar) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 0.8rem 0;
    transition: background-color 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    font-size: 1.4rem;
}

.nav-link {
    color: var(--text-main) !important;
    font-weight: 500;
    margin: 0 5px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--secondary-color) !important;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}

body.dark-mode .nav-link:hover,
body.dark-mode .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Cards Generales */
.card {
    border: none;
    background-color: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

body.dark-mode .text-muted {
    color: var(--text-muted) !important;
}

/* =========================================
   PANEL ADMINISTRATIVO (Sidebar & Layout)
   ========================================= */
.admin-container {
    display: flex;
    min-height: calc(100vh - 70px);
    /* Restar navbar si existe topbar pública */
    margin-top: -70px;
    /* Reset si el body tiene padding */
    padding-top: 0 !important;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 25px;
    background-color: rgba(0, 0, 0, 0.1);
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-left-color: var(--accent-color);
}

.sidebar-menu i {
    width: 25px;
    /* Alineación de iconos */
}

.main-content {
    flex-grow: 1;
    background-color: var(--light-bg);
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Evita desborde en tablas */
}

.top-navbar {
    background: #fff;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
    height: 70px;
}

.content-wrapper {
    padding: 30px;
    flex-grow: 1;
}

/* Tablas Admin */
.table-responsive {
    background: #fff;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    /* Para bordes redondeados */
}

.table thead {
    background-color: #f8f9fa;
}

.table th {
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid #e9ecef;
}

/* =========================================
   PERFIL DE USUARIO
   ========================================= */
.profile-header {
    background: var(--gradient-header);
    height: 180px;
    margin-bottom: 70px;
    position: relative;
}

.profile-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.avatar-container {
    width: 140px;
    height: 140px;
    background: #fff;
    border-radius: 50%;
    padding: 4px;
    margin: -70px auto 20px;
    /* Subir sobre el header */
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
}

.avatar-upload-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--secondary-color);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid #fff;
    transition: background 0.3s;
}

.avatar-upload-btn:hover {
    background: var(--primary-color);
}

/* =========================================
   REPORTES
   ========================================= */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    text-align: center;
    border-bottom: 4px solid var(--accent-color);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.section-title {
    color: var(--primary-color);
    font-weight: 700;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    margin-bottom: 25px;
    margin-top: 40px;
}

/* Logs */
.nivel-log {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.nivel-log.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.nivel-log.warning {
    background-color: #fff3cd;
    color: #856404;
}

.nivel-log.error {
    background-color: #f8d7da;
    color: #721c24;
}

.nivel-log.critical {
    background-color: #343a40;
    color: #fff;
}

/* =========================================
   LOGIN / AUTH
   ========================================= */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    padding: 20px;
    margin-top: -70px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.auth-header {
    background: transparent;
    padding: 30px 30px 10px;
    text-align: center;
}

.auth-logo {
    width: 70px;
    height: 70px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    color: #fff;
    font-size: 1.8rem;
}

.auth-body {
    padding: 0 40px 40px;
}

.btn-auth {
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    padding: 12px;
}

.btn-auth:hover {
    background: var(--secondary-color);
    color: #fff;
}



/* Auth Inputs Improvement */
.auth-card .form-floating>.form-control {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}

.auth-card .form-floating>.form-control:focus {
    background-color: #fff;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(30, 55, 153, 0.1);
}

.auth-card .form-floating>label {
    padding-left: 1rem;
    color: var(--text-muted);
}

/* =========================================
   EXTRAS (Index, Libros)
   ========================================= */
.book-card {
    height: 100%;
    border: 1px solid #f0f0f0;
}

.book-card:hover {
    border-color: transparent;
    box-shadow: var(--hover-shadow);
    transform: translateY(-5px);
}

.hero-section {
    background: var(--gradient-primary);
    color: #fff;
    padding: 60px 0;
    margin-bottom: 40px;
    border-bottom-right-radius: 50px;
    /* Toque moderno pero sutil */
}

.search-btn {
    background: var(--accent-color);
}

/* =========================================
   Book Details & PDF Viewer
   ========================================= */
.detail-card {
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.detail-cover-wrapper {
    background: #f8f9fa;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #efefef;
}

.detail-cover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    max-height: 400px;
}

.pdf-viewer-container {
    height: 85vh;
    /* Taller as requested */
    min-height: 600px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Footer Styles */
footer {
    background-color: var(--secondary-color);
    /* Usar el color oscuro del tema */
    color: #ecf0f1;
    padding-top: 3rem;
    padding-bottom: 3rem;
    margin-top: auto;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
}

footer a {
    text-decoration: none;
    transition: all 0.3s ease;
}

footer a:hover {
    color: var(--accent-color) !important;
    padding-left: 5px;
    /* Efecto de desplazamiento */
}

.footer-title {
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 1.5rem;
    color: #fff;
    position: relative;
    padding-bottom: 10px;
}

.footer-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 3px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

.copyright-section {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1.5rem 0;
    margin-top: 2rem;
}

.footer-link {
    color: #ffffff;
    /* Blanco puro */
    display: block;
    padding: 4px 0;
    opacity: 0.85;
    /* Ligera transparencia pero muy legible */
}

.footer-link:hover {
    opacity: 1;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.social-btn {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    transition: all 0.3s ease;
}

.social-btn:hover {
    background: var(--accent-color);
    transform: translateY(-3px);
    color: white;
}