/* ============================================================
   Sistema de Cierres — Hoja de estilos principal
   ============================================================ */

:root {
    --primary:        #1e3a5f;
    --primary-light:  #2e5496;
    --primary-dark:   #122444;
    --accent:         #f0a500;
    --accent-dark:    #c98600;
    --success:        #198754;
    --danger:         #dc3545;
    --sidebar-w:      260px;
    --topbar-h:       60px;
    --bg-body:        #f0f2f5;
    --text-muted-col: #6c757d;
    --card-radius:    12px;
    --shadow-sm:      0 2px 8px rgba(0,0,0,.08);
    --shadow-md:      0 4px 16px rgba(0,0,0,.12);
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-body); color: #212529; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}

.login-wrapper { width: 100%; max-width: 420px; padding: 1rem; }

.login-card {
    border-radius: var(--card-radius);
    overflow: hidden;
    background: #fff;
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    padding: 2rem;
    text-align: center;
}

.login-icon {
    width: 72px; height: 72px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
}

.btn-login {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    padding: .75rem;
    font-weight: 600;
    letter-spacing: .5px;
    transition: opacity .2s;
}
.btn-login:hover { opacity: .9; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform .3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    text-decoration: none;
    color: #fff;
}

.sidebar-brand-icon {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    color: var(--primary-dark);
}

.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong { font-size: .95rem; display: block; }
.sidebar-brand-text small { font-size: .72rem; opacity: .7; }

.sidebar-nav { flex: 1; padding: 1rem 0; }

.nav-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    opacity: .5;
    padding: 1rem 1.5rem .35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.5rem;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .9rem;
    border-radius: 0;
    transition: all .2s;
    position: relative;
}

.sidebar-nav .nav-link i { font-size: 1.1rem; flex-shrink: 0; }

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.12);
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .82rem;
    color: rgba(255,255,255,.55);
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
    gap: 1rem;
}

.topbar-title { font-weight: 700; font-size: 1.1rem; flex: 1; }

/* ---- Main content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   CARDS & STATS
   ============================================================ */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,.07);
    font-weight: 700;
    padding: 1rem 1.25rem;
}

.stat-card {
    border-radius: var(--card-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.stat-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-icon.blue  { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green { background: #dcfce7; color: #15803d; }
.stat-icon.gold  { background: #fef9c3; color: #a16207; }
.stat-icon.red   { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple{ background: #f3e8ff; color: #7e22ce; }

.stat-label { font-size: .8rem; color: var(--text-muted-col); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1.1; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-hover tbody tr:hover { background: rgba(30,58,95,.04); cursor: pointer; }

.badge-rol-superadmin { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }
.badge-rol-colaborador { background: #e2e8f0; color: #475569; }

/* ============================================================
   FORMULARIO DE CIERRE
   ============================================================ */
.form-cierre-section {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.form-cierre-section .section-title {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
    padding-bottom: .5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--accent);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.denom-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .5rem;
    align-items: center;
    padding: .4rem 0;
    border-bottom: 1px dashed #e9ecef;
}

.denom-row:last-child { border-bottom: none; }

.denom-label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--primary);
}

.denom-subtotal {
    font-weight: 700;
    text-align: right;
    color: var(--success);
    font-size: .9rem;
}

/* Panel resumen de totales */
.totales-panel {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    border-radius: var(--card-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: calc(var(--topbar-h) + 1.5rem);
}

.totales-panel .t-label { font-size: .78rem; opacity: .75; text-transform: uppercase; letter-spacing: .5px; }
.totales-panel .t-value { font-size: 1.1rem; font-weight: 700; }
.totales-panel .t-main  { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.totales-panel .t-diff-ok   { color: #4ade80; font-weight: 800; }
.totales-panel .t-diff-warn { color: #f87171; font-weight: 800; }
.totales-panel hr { border-color: rgba(255,255,255,.2); }

/* Filas dinámicas de ingresos/egresos */
.dynamic-row {
    display: flex;
    gap: .5rem;
    margin-bottom: .5rem;
    align-items: center;
}

.dynamic-row input { flex: 1; }

/* ============================================================
   DETALLE DE CIERRE
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-label { font-size: .8rem; color: var(--text-muted-col); font-weight: 600; text-transform: uppercase; }
.detail-value { font-size: 1rem; font-weight: 600; }

.diferencia-positiva { color: var(--danger); font-weight: 800; }
.diferencia-negativa { color: var(--success); font-weight: 800; }
.diferencia-cero     { color: var(--success); font-weight: 800; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-accent { color: var(--accent); }
.bg-primary-gradient { background: linear-gradient(135deg, var(--primary-dark), var(--primary-light)); }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
}

.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); }

.btn-accent {
    background: var(--accent);
    color: var(--primary-dark);
    border: none;
    font-weight: 700;
}
.btn-accent:hover { background: var(--accent-dark); color: var(--primary-dark); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Sidebar overlay en mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-overlay.show { display: block; }
}

/* Tipo cambio badge */
.tc-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--accent);
    color: var(--primary-dark);
    border-radius: 20px;
    padding: .25rem .85rem;
    font-weight: 700;
    font-size: .85rem;
}

/* Select2 override */
.select2-container--bootstrap-5 .select2-selection {
    border-color: #dee2e6 !important;
    border-radius: .375rem !important;
}
