/* =============================================================
   components.css — Componentes específicos del sistema
   Depende de theme.css (tokens).
   ============================================================= */

/* ============================================================
   1. APP SHELL (sidebar oscuro + main content)
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-app);
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   2. SIDEBAR moderno (oscuro, indigo activo)
   ============================================================ */
.app-sidebar,
.sidebar.bg-light {
    background-color: var(--bg-sidebar) !important;
    color: var(--text-on-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding: 0 !important;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.bg-light { /* override de la clase bootstrap original */
    width: var(--sidebar-w);
}

/* Header del sidebar (logo + nombre del sistema) */
.app-sidebar__header {
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: #fff;
}
.app-sidebar__header .sidebar-toggle-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-on-sidebar-muted) !important;
    padding: 4px 6px !important;
    border-radius: var(--r-md) !important;
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease),
                background var(--duration-fast) var(--ease);
    flex-shrink: 0;
    box-shadow: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.app-sidebar__header .sidebar-toggle-btn:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}
body.sidebar-collapsed .app-sidebar__header .sidebar-toggle-btn {
    color: #fff !important;
}
.app-sidebar__brand {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: var(--fw-bold);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    flex-shrink: 0;
}
.app-sidebar__title {
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-md);
    color: #fff;
    letter-spacing: -0.015em;
    white-space: nowrap;
}

/* Sección con título */
.app-sidebar__section {
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.app-sidebar__section-title {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-on-sidebar-muted);
    font-weight: var(--fw-semibold);
    padding: 0 var(--sp-3);
    margin-bottom: var(--sp-2);
}

/* Items de navegación */
.app-sidebar .nav-link,
.sidebar.bg-light .nav-link {
    color: var(--text-on-sidebar) !important;
    font-size: var(--fs-sm) !important;
    font-weight: var(--fw-medium) !important;
    padding: 0.55rem 0.85rem !important;
    margin: 2px var(--sp-2);
    border-radius: var(--r-md) !important;
    display: flex !important;
    align-items: center;
    gap: var(--sp-3);
    transition: all var(--duration-fast) var(--ease);
    text-decoration: none;
    position: relative;
}

.app-sidebar .nav-link i,
.sidebar.bg-light .nav-link i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    color: var(--text-on-sidebar-muted);
    flex-shrink: 0;
    transition: color var(--duration-fast) var(--ease);
}

.app-sidebar .nav-link:hover,
.sidebar.bg-light .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #fff !important;
}
.app-sidebar .nav-link:hover i,
.sidebar.bg-light .nav-link:hover i {
    color: #fff;
}

.app-sidebar .nav-link.active,
.sidebar.bg-light .nav-link.active {
    background-color: var(--bg-sidebar-active) !important;
    color: #fff !important;
    box-shadow: inset 2px 0 0 var(--indigo-400);
}
.app-sidebar .nav-link.active i,
.sidebar.bg-light .nav-link.active i {
    color: var(--indigo-400);
}

/* Sub-menú colapsable */
.app-sidebar .collapse .nav-link,
.sidebar.bg-light .collapse .nav-link {
    font-size: var(--fs-sm) !important;
    padding-left: 2.5rem !important;
    color: var(--text-on-sidebar-muted) !important;
}
.app-sidebar .collapse .nav-link.active,
.sidebar.bg-light .collapse .nav-link.active {
    background-color: var(--bg-sidebar-active) !important;
    color: #fff !important;
}

/* Chevron del submenú */
.sidebar .nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    position: absolute;
    right: 0.75rem;
    font-size: 0.75rem;
    transition: transform var(--duration-base) var(--ease);
    color: var(--text-on-sidebar-muted);
}
.sidebar .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
    color: var(--indigo-400);
}

/* Footer del sidebar (usuario + logout) */
.app-sidebar__footer {
    margin-top: auto;
    padding: var(--sp-4) var(--sp-3);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
}
.app-sidebar__user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
}
.app-sidebar__user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-pill);
    background: linear-gradient(135deg, var(--indigo-400), var(--indigo-700));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    flex-shrink: 0;
}
.app-sidebar__user-info {
    overflow: hidden;
    flex: 1;
}
.app-sidebar__user-name {
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-sidebar__user-role {
    color: var(--text-on-sidebar-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Estado colapsado */
body.sidebar-collapsed .app-sidebar,
body.sidebar-collapsed .sidebar.bg-light {
    width: var(--sidebar-w-collapsed) !important;
    min-width: var(--sidebar-w-collapsed);
}
body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .app-sidebar__title,
body.sidebar-collapsed .app-sidebar__section-title,
body.sidebar-collapsed .app-sidebar__user-info {
    display: none !important;
}
body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.55rem 0.5rem !important;
}
body.sidebar-collapsed .nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    display: none;
}

/* El contenido ocupa EXACTAMENTE el ancho que deja el sidebar.
   (El sidebar mide var(--sidebar-w) fijo, pero el <main> traía col-lg-10 /
   col-md-9 = 83% / 75% del ancho total → la suma superaba el 100% y las
   tarjetas de la derecha quedaban fuera de pantalla.) */
#sidebarMenu ~ main,
#sidebarMenu ~ [class*="col-"] {
    flex: 1 1 0% !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0;          /* permite encoger aunque haya tablas anchas dentro */
    margin-left: 0 !important;
}

/* Cuando el sidebar colapsa, el main content se expande al ancho restante */
body.sidebar-collapsed .container-fluid .row.flex-nowrap > [class*="col-"]:last-child {
    flex: 1 1 0% !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Mobile: drawer */
@media (max-width: 991.98px) {
    .app-sidebar__header .sidebar-toggle-btn {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1050;
        background: var(--bg-surface) !important;
        color: var(--text-primary) !important;
        border: 1px solid var(--border-default) !important;
        box-shadow: var(--shadow-xs) !important;
        padding: 6px 10px !important;
    }
    .app-sidebar,
    .sidebar.bg-light {
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform var(--duration-slow) var(--ease-emphasized);
        width: var(--sidebar-w) !important;
        height: 100vh;
        height: 100dvh;
    }
    body.sidebar-mobile-show .app-sidebar,
    body.sidebar-mobile-show .sidebar.bg-light {
        transform: translateX(0);
        box-shadow: var(--shadow-2xl);
    }
    body.sidebar-mobile-show::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(24, 24, 27, 0.5);
        z-index: 1039;
        backdrop-filter: blur(2px);
    }
}

/* ============================================================
   3. TOPBAR (header superior moderno)
   ============================================================ */
.app-topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    padding: var(--sp-3) var(--sp-6);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
}

.app-topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    text-decoration: none;
}
.app-topbar__brand:hover { color: var(--text-primary); }

.app-topbar__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.app-topbar__spacer { flex: 1; }

.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.app-topbar__action {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease);
    cursor: pointer;
    position: relative;
}
.app-topbar__action:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}
.app-topbar__action .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-500);
    border: 2px solid var(--bg-surface);
}

.app-topbar__user {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
}
.app-topbar__user:hover { background: var(--bg-surface-2); }
.app-topbar__avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--r-pill);
    background: linear-gradient(135deg, var(--indigo-400), var(--indigo-700));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-xs);
    flex-shrink: 0;
}
.app-topbar__user-name {
    font-size: var(--fs-sm);
    color: var(--text-primary);
    font-weight: var(--fw-medium);
}

/* Botón hamburguesa (mobile) */
.app-topbar__menu-toggle {
    display: none;
}
@media (max-width: 991.98px) {
    .app-topbar__menu-toggle {
        display: inline-flex;
    }
}

/* ============================================================
   4. KPI CARDS (estadísticas del dashboard)
   ============================================================ */
.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    transition: all var(--duration-base) var(--ease);
    position: relative;
    overflow: hidden;
}

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

.kpi-card__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: var(--sp-3);
}
.kpi-card__icon--indigo  { background: var(--indigo-50);  color: var(--indigo-700); }
.kpi-card__icon--success { background: var(--success-50); color: var(--success-700); }
.kpi-card__icon--warning { background: var(--warning-50); color: var(--warning-700); }
.kpi-card__icon--danger  { background: var(--danger-50);  color: var(--danger-700); }
.kpi-card__icon--info    { background: var(--info-50);    color: var(--info-700); }

.kpi-card__label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--sp-2);
}

.kpi-card__value {
    font-family: var(--font-display);
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
}

.kpi-card__delta {
    margin-top: var(--sp-3);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-pill);
}
.kpi-card__delta--up   { background: var(--success-50); color: var(--success-700); }
.kpi-card__delta--down { background: var(--danger-50);  color: var(--danger-700); }
.kpi-card__delta--flat { background: var(--zinc-100);   color: var(--zinc-700); }

/* Auto-aplicar al patrón existente de admin/panel.php */
.card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--indigo-50) !important;
    color: var(--indigo-700) !important;
}
.card .card-title {
    font-size: var(--fs-xs) !important;
    color: var(--text-tertiary) !important;
    font-weight: var(--fw-semibold) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-1) !important;
}
.card .card-text,
.card .h4,
.card .h2 {
    font-family: var(--font-display);
    color: var(--text-primary) !important;
    font-weight: var(--fw-bold) !important;
    font-size: var(--fs-3xl) !important;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   5. LOGIN — Split screen elegante
   ============================================================ */
.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--bg-surface);
}

@media (min-width: 992px) {
    .login-shell {
        grid-template-columns: 1fr 1fr;
    }
}

.login-shell__hero {
    display: none;
    background: linear-gradient(135deg, var(--indigo-700) 0%, var(--indigo-900) 50%, var(--zinc-900) 100%);
    color: #fff;
    padding: var(--sp-12) var(--sp-10);
    position: relative;
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
}

@media (min-width: 992px) {
    .login-shell__hero { display: flex; }
}

/* Patrón decorativo */
.login-shell__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(165, 180, 252, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.login-shell__hero-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}
.login-shell__hero-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.login-shell__hero-content {
    position: relative;
    z-index: 1;
}
.login-shell__hero-title {
    font-family: var(--font-display);
    font-size: var(--fs-4xl);
    font-weight: var(--fw-bold);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: var(--sp-4);
}
.login-shell__hero-subtitle {
    font-size: var(--fs-md);
    color: rgba(255, 255, 255, 0.75);
    line-height: var(--lh-relaxed);
    max-width: 32rem;
}
.login-shell__hero-footer {
    position: relative;
    z-index: 1;
    font-size: var(--fs-xs);
    color: rgba(255, 255, 255, 0.5);
}

.login-shell__form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--sp-8) var(--sp-6);
    background: var(--bg-surface);
}

@media (min-width: 768px) {
    .login-shell__form { padding: var(--sp-12) var(--sp-10); }
}

.login-form-card {
    max-width: 24rem;
    width: 100%;
    margin: 0 auto;
}

.login-form-card__brand {
    text-align: center;
    margin-bottom: var(--sp-8);
}
.login-form-card__brand img {
    max-height: 60px;
    max-width: 200px;
    object-fit: contain;
}
.login-form-card__title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: var(--sp-2);
}
.login-form-card__subtitle {
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-6);
}

/* ============================================================
   6. PAGE HEADER (encabezado de las páginas internas)
   ============================================================ */
.page-header {
    padding: var(--sp-6) 0 var(--sp-4);
    margin-bottom: var(--sp-6);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-4);
}

.page-header__title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.page-header__subtitle {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin: var(--sp-1) 0 0;
}

.page-header__actions {
    display: flex;
    gap: var(--sp-2);
}

/* Breadcrumbs */
.breadcrumb {
    font-size: var(--fs-sm) !important;
    margin: 0 0 var(--sp-2);
    color: var(--text-tertiary);
}
.breadcrumb a { color: var(--text-tertiary); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-item.active { color: var(--text-secondary) !important; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-disabled); }

/* ============================================================
   7. EMPTY STATES
   ============================================================ */
.empty-state {
    padding: var(--sp-12) var(--sp-6);
    text-align: center;
    color: var(--text-tertiary);
}
.empty-state__icon {
    font-size: 3rem;
    color: var(--zinc-300);
    margin-bottom: var(--sp-4);
}
.empty-state__title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}
.empty-state__description {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    max-width: 24rem;
    margin: 0 auto var(--sp-4);
}

/* ============================================================
   8. RELOJ DIGITAL (mobile/index.php) — versión premium
   ============================================================ */
.reloj-digital,
.clock-display {
    background: linear-gradient(135deg, var(--indigo-700) 0%, var(--indigo-900) 100%) !important;
    color: #fff !important;
    border-radius: var(--r-xl) !important;
    padding: var(--sp-6) !important;
    text-align: center;
    box-shadow: var(--shadow-lg) !important;
    margin-bottom: var(--sp-5) !important;
    position: relative;
    overflow: hidden;
}
.reloj-digital::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
    pointer-events: none;
}
.reloj-hora {
    font-family: var(--font-mono);
    font-size: clamp(2.5rem, 8vw, 3.5rem) !important;
    font-weight: var(--fw-bold);
    color: #fff !important;
    letter-spacing: 0.05em !important;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
    margin-bottom: var(--sp-2) !important;
    line-height: 1;
}
.reloj-fecha {
    font-size: var(--fs-sm) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    text-transform: capitalize;
    font-weight: var(--fw-medium) !important;
}
.reloj-segundos {
    color: var(--indigo-200) !important;
}

/* ============================================================
   9. BOTTOM NAV (mobile)
   ============================================================ */
.bottom-nav,
.mobile-bottom-nav {
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border-default) !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.04) !important;
    padding: var(--sp-2) var(--sp-2) calc(var(--sp-2) + var(--sa-bottom)) !important;
    backdrop-filter: blur(10px);
}
.bottom-nav .nav-item {
    color: var(--text-tertiary) !important;
    font-size: var(--fs-2xs) !important;
    font-weight: var(--fw-medium);
    padding: 0.4rem 0.5rem !important;
    border-radius: var(--r-md);
    transition: all var(--duration-fast) var(--ease);
}
.bottom-nav .nav-item i {
    font-size: 1.3rem !important;
    margin-bottom: 0.15rem;
}
.bottom-nav .nav-item.active {
    color: var(--indigo-700) !important;
}
.bottom-nav .nav-item:not(.active):hover {
    color: var(--text-secondary) !important;
    background: var(--bg-surface-2);
}

/* ============================================================
   10. STAT CARD ALT (mobile/index.php)
   ============================================================ */
.stat-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--r-lg) !important;
    padding: var(--sp-4) !important;
    box-shadow: var(--shadow-xs) !important;
    margin-bottom: var(--sp-3) !important;
    transition: all var(--duration-base) var(--ease);
}
.stat-card:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
}
.stat-icon {
    width: 40px !important;
    height: 40px !important;
    border-radius: var(--r-md) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* ============================================================
   11. BTN ACTION (mobile)
   ============================================================ */
.btn-action {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--r-lg) !important;
    padding: var(--sp-4) !important;
    box-shadow: var(--shadow-xs) !important;
    text-decoration: none;
    color: var(--text-primary) !important;
    display: block;
    transition: all var(--duration-base) var(--ease);
}
.btn-action:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
    border-color: var(--border-strong) !important;
    color: var(--text-primary) !important;
}
.btn-action:active { transform: translateY(0); }

/* ============================================================
   12. MOBILE HEADER
   ============================================================ */
.mobile-header {
    background: linear-gradient(135deg, var(--indigo-700) 0%, var(--indigo-900) 100%) !important;
    padding: calc(var(--sp-4) + var(--sa-top)) var(--sp-4) var(--sp-4) !important;
    box-shadow: var(--shadow-md) !important;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ============================================================
   13. PHOTO CAPTURE CARD (registrar.php)
   ============================================================ */
.video-container,
#contenedorCamara {
    background: var(--zinc-900) !important;
    border-radius: var(--r-xl) !important;
    overflow: hidden;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--zinc-800);
}

/* ============================================================
   14. CONFIRMATION DIALOGS (SweetAlert override)
   ============================================================ */
.swal2-popup {
    border-radius: var(--r-xl) !important;
    box-shadow: var(--shadow-2xl) !important;
    font-family: var(--font-sans) !important;
    border: 1px solid var(--border-default);
    padding: var(--sp-5) !important;
}
.swal2-title { font-family: var(--font-display); font-weight: var(--fw-semibold); color: var(--text-primary); }
.swal2-html-container { color: var(--text-secondary); }
.swal2-styled.swal2-confirm {
    background-color: var(--indigo-600) !important;
    border-radius: var(--r-md) !important;
    box-shadow: var(--shadow-xs) !important;
}
.swal2-styled.swal2-cancel {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--r-md) !important;
}

/* ============================================================
   15. SCROLLBARS REFINADOS para sidebar
   ============================================================ */
.app-sidebar::-webkit-scrollbar,
.sidebar.bg-light::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb,
.sidebar.bg-light::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================================
   16. CHIPS (filtros)
   ============================================================ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
}
.chip:hover {
    border-color: var(--indigo-300);
    color: var(--text-primary);
    background: var(--indigo-50);
}

html[data-theme="dark"] .chip:hover {
    background: var(--bg-surface-2);
    border-color: var(--indigo-600);
    color: var(--text-primary);
}
.chip.is-active {
    background: var(--indigo-600);
    border-color: var(--indigo-600);
    color: #fff;
}

/* ============================================================
   17. TABS pill style
   ============================================================ */
.nav-pills .nav-link {
    color: var(--text-secondary) !important;
    font-weight: var(--fw-medium);
    font-size: var(--fs-sm);
    padding: 0.45rem 0.85rem !important;
    border-radius: var(--r-md);
    background: transparent !important;
}
.nav-pills .nav-link:hover {
    background: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
}
.nav-pills .nav-link.active {
    background: var(--bg-surface) !important;
    color: var(--indigo-700) !important;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-default);
}

/* ============================================================
   18. TIMELINE (historial)
   ============================================================ */
.timeline {
    position: relative;
    padding-left: var(--sp-6);
}
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-default);
}
.timeline-item {
    position: relative;
    padding-bottom: var(--sp-4);
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--indigo-600);
}

/* ============================================================
   19. THEME TOGGLE (light/dark switch)
   ============================================================ */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
}
.theme-toggle:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}
.theme-toggle .bi-moon-fill { display: none; }
.theme-toggle .bi-sun-fill { display: inline-block; }
html[data-theme="dark"] .theme-toggle .bi-sun-fill { display: none; }
html[data-theme="dark"] .theme-toggle .bi-moon-fill { display: inline-block; }

/* ============================================================
   ENCABEZADO + MENÚ LATERAL UNIFICADOS (includes/header.php + sidebar.php)
   - El encabezado ocupa todo el ancho y mide var(--header-h).
   - Su zona izquierda mide lo mismo que el menú lateral, así el logo
     y la línea divisoria quedan alineados con el menú.
   - El menú se pega debajo del encabezado y desplaza su propio
     contenido: nunca queda cortado fuera de la pantalla.
   ============================================================ */
.navbar.app-header {
    height: var(--header-h);
    min-height: var(--header-h) !important;
    padding: 0 !important;
    flex-wrap: nowrap;
    z-index: 1030;
}
.app-header__inner {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    padding-right: 1.5rem;
    min-width: 0;
}
.app-header__start {
    display: flex;
    align-items: center;
    gap: 10px;
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100%;
    padding-left: 22px;
    padding-right: 12px;
    border-right: 1px solid var(--border-default);
    min-width: 0;
    transition: width var(--duration-fast) var(--ease);
}
.app-header__menu {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.app-header__menu:hover,
.app-header__menu:focus-visible {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}
.navbar.app-header .app-header__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    min-width: 0;
    color: var(--text-primary) !important;
    text-decoration: none;
}
.app-header__brand .system-logo { max-height: 28px; max-width: 110px; object-fit: contain; flex-shrink: 0; }
.app-header__glyph {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--indigo-600);
    color: #fff;
    font-size: 15px;
}
/* El nombre puede ocupar dos líneas para no cortarse junto al logo */
.navbar.app-header .app-header__brand .system-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    line-height: 1.15;
    font-size: 13px !important;
    max-width: 130px;
}
.app-header__end {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    min-width: 0;
}
.app-header__user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding-left: 12px;
    border-left: 1px solid var(--border-default);
}
.app-header__avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}
.app-header__user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.navbar.app-header .app-header__user-name {
    padding: 0;
    font-size: 13px !important;
    font-weight: 500;
    color: var(--text-primary) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.app-header__user-role { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.navbar.app-header .app-header__logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    height: 34px;
}
.navbar.app-header .theme-toggle { width: 34px; height: 34px; flex-shrink: 0; }

/* Menú colapsado: el encabezado ya no reserva el ancho completo */
body.sidebar-collapsed .app-header__start {
    width: auto;
    padding-left: 18px;
    padding-right: 20px;
}

/* Menú lateral: pegado bajo el encabezado y con desplazamiento propio */
#sidebarMenu.app-sidebar {
    position: sticky;
    top: var(--header-h);
    align-self: flex-start;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}
.app-sidebar__nav { padding: var(--sp-2) 0 var(--sp-5); }
.app-sidebar__nav .app-sidebar__section { padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.app-sidebar__nav .app-sidebar__section:first-child { padding-top: var(--sp-2); }
.app-sidebar__nav .app-sidebar__section-title { padding: 0 var(--sp-3); margin-bottom: 2px; }
.app-sidebar__nav .nav-link { min-height: 36px; }
.app-sidebar__nav .nav-link .bi-chevron-down { margin-left: auto; font-size: 12px; transition: transform var(--duration-fast) var(--ease); }
.app-sidebar__nav .nav-link[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* Tableta / móvil: el menú es un cajón que abre bajo el encabezado */
@media (max-width: 991.98px) {
    .app-header__start { width: auto; border-right: 0; padding-left: 12px; }
    .app-header__inner { padding-right: 12px; }
    #sidebarMenu.app-sidebar {
        position: fixed !important;
        top: var(--header-h);
        height: calc(100vh - var(--header-h));
        height: calc(100dvh - var(--header-h));
    }
    body.sidebar-mobile-show::after { top: var(--header-h); }
}
@media (max-width: 767.98px) {
    .app-header__user-info { display: none; }
    .app-header__user { padding-left: 8px; }
}
@media (max-width: 575.98px) {
    .app-header__logout-text { display: none; }
    .navbar.app-header .app-header__logout { width: 34px; padding: 0 !important; justify-content: center; }
    .app-header__end { gap: 8px; }
    .app-header__inner { padding-right: 8px; }
    .app-header__start { padding-left: 6px; gap: 6px; }
    .app-header__user { border-left: 0; padding-left: 0; }
    /* Con logo, el logo ya identifica al sistema: se oculta el nombre */
    .app-header__brand .system-logo ~ .system-name { display: none !important; }
    .app-header__brand .system-logo { max-width: 96px; }
}

/* ============================================================
   SELECT CON BUSCADOR (recursos/js/select_buscable.js)
   <select data-buscable> → botón + panel con campo de búsqueda.
   ============================================================ */
.sb { position: relative; }
.sb__nativo {
    position: absolute !important;
    left: 0; bottom: 0;
    width: 100% !important; height: 1px !important;
    opacity: 0 !important;
    pointer-events: none;
    padding: 0 !important; border: 0 !important;
}
.sb__boton {
    display: block;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.sb__boton.is-placeholder { color: var(--text-secondary) !important; }
.sb.is-open .sb__boton,
.sb__boton:focus-visible {
    border-color: var(--indigo-500) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo-500) 22%, transparent) !important;
    outline: 0;
}
.sb.is-invalid .sb__boton { border-color: var(--danger-500, #dc3545) !important; }
.sb__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    z-index: 1060;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}
html[data-theme="dark"] .sb__panel { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
.sb__busqueda {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid var(--border-default);
}
.sb__busqueda .bi-search {
    position: absolute;
    left: 20px; top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-secondary);
    pointer-events: none;
}
.sb__busqueda .sb__input { padding-left: 32px !important; }
.sb__lista {
    list-style: none;
    margin: 0;
    padding: 4px;
    max-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.sb__opcion {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.3;
    color: var(--text-primary);
    cursor: pointer;
}
.sb__opcion:hover,
.sb__opcion.is-active { background: var(--bg-surface-2); }
.sb__opcion.is-selected { font-weight: 600; color: var(--indigo-600); }
html[data-theme="dark"] .sb__opcion.is-selected { color: var(--indigo-400); }
.sb__opcion.is-disabled { opacity: .45; cursor: default; }
.sb__vacio { padding: 14px; text-align: center; font-size: 13px; color: var(--text-secondary); }
