/**
 * Sistema de Facturación — Academix
 * Bootstrap 5 + estilos propios del panel admin
 */

:root {
    --sidebar-width: 250px;
    --topbar-height: 60px;
    --accent: #0e7490;
    --accent-dark: #0c5f77;
}

body { background: #f5f7fa; font-family: 'Segoe UI', Tahoma, sans-serif; color: #1e293b; }

/* min-width:0 en un hijo flex evita que texto/tablas anchas empujen el
   layout y produzcan scroll horizontal en celulares. */
.app-content { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Sidebar ──
   Mobile-first: drawer propio con position:fixed, oculto fuera de pantalla
   (translateX -100%) hasta que se le agrega .is-open (ver assets/js/app.js).
   A partir de 992px vuelve a ser una columna normal, fija, dentro del
   .d-flex — ya no depende del componente Offcanvas de Bootstrap. */
.sidebar-app {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(var(--sidebar-width), 85vw);
    background: #0f172a;
    color: #fff;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-x: hidden;
    overflow-y: auto;
}
.sidebar-app.is-open { transform: translateX(0); }
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
    display: none;
}
.sidebar-backdrop.is-open { display: block; }
@media (min-width: 992px) {
    .sidebar-app {
        position: static;
        width: var(--sidebar-width);
        flex-shrink: 0;
        transform: none;
    }
    .sidebar-close-header, .sidebar-backdrop { display: none !important; }
}
.sidebar-close-header { padding: .5rem .75rem 0; }
.sidebar-brand {
    color: #fff; font-size: 1.02rem; font-weight: 700;
    padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: .6rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: .4rem;
    line-height: 1.2;
}
/* Placa blanca detrás del logo: tiene trazos negros que se perderían
   directo sobre el navy del sidebar. */
.sidebar-brand img {
    height: 34px; width: 34px; object-fit: contain; flex-shrink: 0;
    background: #fff;
    border-radius: 8px;
    padding: 3px;
}
.sidebar-body .nav-link {
    color: rgba(255,255,255,.75);
    padding: .6rem 1.25rem;
    font-size: 1.02rem;
    display: flex; align-items: center; gap: .65rem;
    border-left: 3px solid transparent;
}
.sidebar-body .nav-link i:not(.nav-chevron) { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-body .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-body .nav-link.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--accent); font-weight: 600; }
.sidebar-body .nav-section-label {
    padding: .85rem 1.25rem .3rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.35);
}
.sidebar-body .nav-section-label:first-child { padding-top: .3rem; }

/* ── Sidebar: grupos padre/submenú colapsables ── */
.sidebar-body .nav-parent { cursor: pointer; }
.sidebar-body .nav-parent .nav-chevron {
    margin-left: auto;
    font-size: .68rem;
    opacity: .5;
    transition: transform .2s ease;
}
.sidebar-body .nav-parent:not(.collapsed) .nav-chevron { transform: rotate(180deg); }
.sidebar-body .nav-parent.has-active { color: #fff; font-weight: 600; }
.sidebar-body .nav-link:focus-visible,
.sidebar-body .nav-parent:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.sidebar-body .collapse, .sidebar-body .collapsing { width: 100%; }
.sidebar-body .nav-submenu { background: rgba(0,0,0,.2); width: 100%; }
.sidebar-body .nav-sublink { padding: .5rem 1.25rem .5rem 2.35rem; font-size: .97rem; }
.sidebar-body .nav-sublink i { width: 16px; font-size: .8rem; flex-shrink: 0; }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-weight: 700; color: #0f172a; flex: 1; font-size: 1rem; }

/* ── Contenido ── */
.content-wrapper { padding: 1.5rem; flex: 1 0 auto; }
@media (max-width: 575.98px) {
    .content-wrapper { padding: 1rem; }
}

/* ── Footer ── */
.app-footer {
    padding: .9rem 1.5rem;
    text-align: center;
    font-size: .78rem;
    color: #94a3b8;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

/* ── Tarjetas de estadística (dashboard, reportes) ──
   White card + acento de color (border-left + ícono opcional) en vez de
   fondo degradado: mismo criterio ya validado en IML-Eventos ("reemplaza
   gradientes coloridos que producían ruido visual y chocaban entre sí").
   .stat-card se queda en block (no flex) a propósito: varias páginas de
   reportes solo ponen .stat-num/.stat-lbl directo adentro, sin ícono, y
   deben seguir viéndose apiladas igual que antes. El layout con ícono
   (.stat-card-body, flex) es opt-in — lo usa el dashboard nuevo. */
.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--stat-color, #0e7490);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat-card-body { display: flex; align-items: center; gap: .85rem; }
.stat-card .stat-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; color: #fff;
    background: var(--stat-color, #0e7490);
}
.stat-card .stat-num { font-size: 1.3rem; font-weight: 800; line-height: 1.15; color: #0f172a; }
.stat-card .stat-lbl { font-size: .75rem; color: #64748b; margin-top: .2rem; }
.stat-blue    { --stat-color: #2563eb; }
.stat-red     { --stat-color: #dc2626; }
.stat-green   { --stat-color: #059669; }
.stat-orange  { --stat-color: #d97706; }
.stat-darkred { --stat-color: #991b1b; }

/* ── Cuentas por Cobrar: fila de agrupación por cliente dentro de la
   misma tabla (en vez de una card separada por cliente — más compacto
   y profesional para reportes con muchos clientes) ── */
.cxc-group-row td {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    font-weight: 700;
    color: #0f172a;
    padding-top: .55rem;
    padding-bottom: .55rem;
}
.cxc-dias-badge {
    display: inline-block;
    min-width: 2.6em;
    padding: .25em .55em;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

/* ── Gráfica Ingresos vs Gastos (dashboard) ──
   Colores validados (par adjacente del tema categórico de referencia,
   ver skill dataviz): aqua #1baf7a (ingresos) + orange #eb6834 (gastos),
   ΔE CVD 9.1 — no son los mismos hex que .stat-green/.stat-orange a
   propósito, esos nunca se validaron para contraste entre sí. */
.viz-legend { display: flex; gap: 1rem; font-size: .78rem; color: #64748b; font-weight: 400; }
.viz-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.viz-svg { width: 100%; height: auto; }
.viz-gridline { stroke: #e2e8f0; stroke-width: 1; }
.viz-baseline { stroke: #c3c2b7; stroke-width: 1; }
.viz-axis-label { fill: #898781; font-size: 9px; font-family: 'Segoe UI', Tahoma, sans-serif; }
.viz-bar { transition: opacity .15s ease; }
.viz-bar:hover { opacity: .8; }
.viz-bar-ingresos { fill: #1baf7a; }
.viz-bar-gastos { fill: #eb6834; }
.viz-table-toggle { font-size: .8rem; color: #0e7490; cursor: pointer; }

/* ── Login ── */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: #eef2f6;
    padding: 1rem;
}
/* .login-card: usado por cambiar_password.php (tarjeta simple centrada,
   no necesita el panel partido de login.php). */
.login-card {
    background: #fff; border-radius: 16px;
    padding: 2.25rem 2rem;
    width: 100%; max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,.12);
}
.login-logo { height: 64px; width: 64px; object-fit: contain; }

/* login.php: panel partido — marca a la izquierda, formulario a la derecha. */
.login-split {
    display: flex;
    width: 100%;
    max-width: 820px;
    min-height: 460px;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.14);
}
.login-brand-panel {
    flex: 1 1 42%;
    background: linear-gradient(160deg, var(--accent), var(--accent-dark));
    color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2.5rem 2rem;
    text-align: center;
}
.login-brand-logo {
    width: 100px; height: 100px; object-fit: contain;
    background: #fff; border-radius: 20px; padding: 10px;
    margin-bottom: 1.25rem;
}
.login-brand-panel h2 { font-size: 1.3rem; font-weight: 800; margin: 0; }
.login-form-panel {
    flex: 1 1 58%;
    display: flex; align-items: center; justify-content: center;
    padding: 2.5rem 2rem;
}
.login-form-inner { width: 100%; max-width: 320px; }
@media (max-width: 700px) {
    .login-split { flex-direction: column; min-height: 0; max-width: 460px; }
    .login-brand-panel { padding: 2.25rem 1.5rem 1.75rem; }
    .login-brand-logo { width: 92px; height: 92px; margin-bottom: .8rem; }
    .login-brand-panel h2 { font-size: 1.25rem; }
    .login-form-panel { padding: 2.25rem 2rem 2.5rem; }
    .login-form-inner { max-width: 360px; }
    .login-form-inner h4 { font-size: 1.55rem; }
    .login-form-inner p.text-muted { font-size: 1rem !important; }
    .login-form-inner .form-label { font-size: 1.05rem !important; }
    .login-form-inner .form-control {
        font-size: 1.15rem;
        padding: .7rem 1rem;
    }
    .login-form-inner .btn {
        font-size: 1.15rem;
        padding: .75rem 1rem;
    }
}

/* ── Impresión ── */
@media print {
    .sidebar-app, .topbar, .no-print, .modal { display: none !important; }
    .app-content, .content-wrapper { padding: 0 !important; margin: 0 !important; }
    body { background: #fff; }
    .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
}
