/* ═══════════════════════════════════════════════════════════════
   Biblioteca Virtual — Emerald Design System v3
   Paleta: Teal + Emerald + Warm Slate — Premium Library Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* ── Primary: Teal/Emerald ── */
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #2dd4bf;
    --primary-50: #f0fdfa;
    --primary-100: #ccfbf1;
    --primary-200: #99f6e4;
    --primary-900: #134e4a;

    /* ── Accent: Amber warm ── */
    --accent: #e67e22;
    --accent-light: #f0a54b;
    --accent-50: #fffbeb;

    /* ── Semantic ── */
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #ca8a04;
    --warning-bg: #fef9c3;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;

    /* ── Surfaces ── */
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --bg-muted: #f3f4f6;
    --bg-hover: #f0fdfa;

    /* ── Sidebar (light) ── */
    --sidebar-bg: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
    --sidebar-border: #e5e7eb;
    --sidebar-width: 260px;

    /* ── Text ── */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-white: #ffffff;

    /* ── Borders ── */
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    /* ── Shadows (Premium Soft Diffusion) ── */
    --shadow-xs: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-sm: 0 4px 12px rgba(0,0,0,0.03);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.04);
    --shadow-lg: 0 16px 32px rgba(0,0,0,0.05);
    --shadow-xl: 0 24px 48px rgba(0,0,0,0.06);
    --shadow-primary: 0 4px 14px rgba(13,148,136,0.2);

    /* ── Radius ── */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* ── Motion ── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 150ms;
    --dur-base: 250ms;
    --dur-slow: 350ms;
}

/* ══════ RESET ══════ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.008em;
}

::selection { background: var(--primary-100); color: var(--primary-900); }
a { color: var(--primary); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--primary-hover); }

/* ══════ BOOTSTRAP PRIMARY OVERRIDE ══════ */
.bg-primary { background-color: var(--primary) !important; }
.bg-opacity-10.bg-primary { background-color: rgba(13,148,136,0.1) !important; }
.text-primary { color: var(--primary) !important; }
.btn-primary {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: 0 6px 20px rgba(13,148,136,0.3);
    transform: translateY(-1px);
}
.btn-outline-primary {
    color: var(--primary) !important;
    border-color: var(--primary-200) !important;
}
.btn-outline-primary:hover {
    background: var(--primary-50) !important;
    border-color: var(--primary) !important;
    color: var(--primary-dark) !important;
}
/* Estado activo de toggles segmentados (btn-check) — usar el teal del tema, no el azul de Bootstrap */
.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary,
.btn-outline-primary.active,
.btn-outline-primary:active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}
.btn-check:focus-visible + .btn-outline-primary {
    box-shadow: 0 0 0 0.25rem rgba(13,148,136,0.25) !important;
}
.border-primary { border-color: var(--primary) !important; }
.badge.bg-primary { background: var(--primary) !important; color: #fff !important; }
.badge.bg-primary.bg-opacity-10 { background: var(--primary-100) !important; color: var(--primary-dark) !important; }

/* Paginación alineada al tema (Bootstrap trae azul por defecto) */
.pagination .page-link {
    color: var(--primary);
}
.pagination .page-link:hover {
    color: var(--primary-dark);
    background-color: var(--primary-50);
    border-color: var(--primary-200);
}
.pagination .page-link:focus {
    color: var(--primary-dark);
    background-color: var(--primary-50);
    box-shadow: 0 0 0 0.25rem rgba(13,148,136,0.25);
}
.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    color: var(--text-muted, #9ca3af);
}

/* ══════ SIDEBAR (Light Theme) ══════ */
#sidebar-wrapper {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    min-height: 100vh;
    background: #ffffff;
    border-right: none;
    box-shadow: 4px 0 24px rgba(0,0,0,0.02);
    transition: margin-left var(--dur-slow) var(--ease);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

body.modo-gestion-activo #sidebar-wrapper {
    top: 44px;
    height: calc(100vh - 44px);
    min-height: calc(100vh - 44px);
}

#sidebar-wrapper::-webkit-scrollbar { width: 3px; }
#sidebar-wrapper::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }
#wrapper.toggled #sidebar-wrapper { margin-left: calc(var(--sidebar-width) * -1); }

.sidebar-heading {
    padding: 1.15rem 1.15rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-heading .brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(13,148,136,0.25);
    transition: transform var(--dur-base) var(--ease);
}

.sidebar-heading:hover .brand-icon { transform: scale(1.05) rotate(-2deg); }

.sidebar-heading .brand-text {
    font-size: 0.92rem; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-heading .brand-sub {
    font-size: 0.62rem; color: var(--text-muted);
    letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
}

#sidebar-wrapper .nav { padding: 0.5rem 0.65rem; }

#sidebar-wrapper .nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--dur-fast) var(--ease);
    margin-bottom: 1px;
    display: flex; align-items: center;
    position: relative;
}

#sidebar-wrapper .nav-link i {
    font-size: 1rem; min-width: 22px;
    color: var(--text-muted);
    transition: all var(--dur-fast) var(--ease);
}

#sidebar-wrapper .nav-link:hover {
    color: var(--primary);
    background: var(--primary-50);
}

#sidebar-wrapper .nav-link:hover i { color: var(--primary); transform: scale(1.08); }

#sidebar-wrapper .nav-link.active {
    background: var(--primary-100);
    color: var(--primary-dark);
    font-weight: 600;
}

#sidebar-wrapper .nav-link.active i { color: var(--primary); }

#sidebar-wrapper .nav-link.active::before {
    content: '';
    position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-section-label {
    color: var(--text-muted);
    font-size: 0.62rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 1.1rem 0.8rem 0.3rem; margin: 0;
}

.sidebar-user-footer {
    border-top: 1px solid var(--border);
    padding: 0.8rem 1rem;
    background: var(--bg-muted);
}

.sidebar-user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; color: #fff;
    flex-shrink: 0;
}

/* ══════ PAGE CONTENT ══════ */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--dur-slow) var(--ease);
    min-height: 100vh;
    background: var(--bg-body);
}

#wrapper.toggled #page-content-wrapper { margin-left: 0; }

/* ══════ TOP NAVBAR ══════ */
.top-navbar {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: none;
    box-shadow: 0 4px 24px rgba(0,0,0,0.03);
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px;
}

.top-navbar .btn-toggle {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--dur-fast) var(--ease);
    cursor: pointer;
}

.top-navbar .btn-toggle:hover {
    background: var(--primary-50);
    color: var(--primary);
    border-color: var(--primary-200);
}

.top-navbar .nav-date {
    font-size: 0.78rem; color: var(--text-muted);
    font-weight: 500;
}

/* ══════ BREADCRUMB ══════ */
.breadcrumb { background: transparent; padding: 0; margin: 0; font-size: 0.78rem; }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ══════ CARDS ══════ */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    transition: all var(--dur-slow) var(--ease);
}

.card:hover { 
    box-shadow: var(--shadow-md); 
    transform: translateY(-2px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.card-footer {
    background: var(--bg-muted);
    border-top: 1px solid var(--border-light);
    padding: 0.7rem 1.25rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.kpi-card { border: 1px solid var(--border); transition: all var(--dur-base) var(--ease); }
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-200);
}

/* ══════ TABLES ══════ */
.table-admin { font-size: 0.84rem; }

.table-admin thead th {
    background: var(--bg-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding: 0.65rem 1rem;
    white-space: nowrap;
}

.table-admin tbody td {
    vertical-align: middle;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table-admin tbody tr { transition: background var(--dur-fast) var(--ease); }
.table-admin tbody tr:hover { background: var(--bg-hover); }

/* ══════ BADGES ══════ */
.badge {
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    padding: 0.3em 0.65em;
    border-radius: var(--radius-full);
}

/* ══════ BUTTONS ══════ */
.btn {
    font-weight: 600;
    font-size: 0.84rem;
    border-radius: var(--radius-sm);
    transition: all var(--dur-fast) var(--ease);
    padding: 0.48rem 1rem;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}
.btn-outline-secondary:hover {
    background: var(--bg-muted);
    border-color: var(--text-muted);
}

/* ══════ FORM CONTROLS ══════ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    font-size: 0.875rem;
    padding: 0.55rem 0.85rem;
    transition: all var(--dur-fast) var(--ease);
    background: #fff;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

.form-label {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.input-group-text {
    border-color: var(--border);
    background: var(--bg-muted);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

/* ══════ PAGE HEADER ══════ */
.page-header { margin-bottom: 1.5rem; }

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.page-header p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.15rem; }

/* ══════ ALERTS ══════ */
.alert {
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.8rem 1.1rem;
}

.alert-success { background: var(--success-bg); color: #14532d; border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-bg); color: #7f1d1d; border-left: 4px solid var(--danger); }
.alert-primary { background: var(--primary-50); color: var(--primary-900); border-left: 4px solid var(--primary); }

/* ══════ LOGIN ══════ */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(rgba(15, 23, 42, 0.5), rgba(15, 23, 42, 0.7)), url('../img/fondologin.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
}

.login-card {
    width: 100%; max-width: 420px;
    margin: auto; z-index: 10;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 60px rgba(13,148,136,0.1);
    overflow: hidden;
    animation: card-enter 0.5s var(--ease);
}

@keyframes card-enter {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(13,148,136,0.3);
    margin: 0 auto 1rem;
}

/* ══════ PROGRESS ══════ */
.progress {
    border-radius: var(--radius-full);
    background: var(--border-light);
    height: 6px;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width var(--dur-slow) var(--ease);
}

/* ══════ NOTIFICATIONS ══════ */
.notif-badge { position: relative; }
.notif-badge .notif-count {
    position: absolute; top: -4px; right: -6px;
    min-width: 18px; height: 18px;
    font-size: 0.6rem; font-weight: 700;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(220,38,38,0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ══════ UTILITIES ══════ */
.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon-circle {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
}

.icon-circle-sm {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
}

.container-fluid { padding: 1.5rem 2rem; }

.fade-in { animation: fadeIn 0.3s var(--ease); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.list-group-flush .list-group-item {
    border-color: var(--border-light);
    transition: background var(--dur-fast) var(--ease);
}
.list-group-flush .list-group-item:hover { background: var(--bg-muted); }

/* ══════ SCROLLBAR ══════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════ RESPONSIVE ══════ */
@media (max-width: 992px) {
    #sidebar-wrapper { margin-left: calc(var(--sidebar-width) * -1); }
    #wrapper.toggled #sidebar-wrapper { margin-left: 0; }
    #page-content-wrapper { margin-left: 0; }
    .container-fluid { padding: 1rem; }
}

@media (max-width: 576px) {
    .page-header h1 { font-size: 1.15rem; }
    .login-card { margin: 1rem; max-width: none; }
}

@media print {
    #sidebar-wrapper, .top-navbar, .btn, .form-check { display: none !important; }
    #page-content-wrapper { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}