/* =========================================================
   SISTEMA SST — Tokens de diseño (v5)
   - Acento azul (antes bronce)
   - Modo claro forzado (evita que el navegador invierta colores)
   - Reglas propias para grillas, modales e inputs que NO dependen
     de que el CSS/JS de Bootstrap cargue correctamente (CDN puede
     fallar/tardar en algunas redes). Bootstrap sigue cargado como
     mejora progresiva, pero el sistema funciona bien sin él.
   ========================================================= */
:root {
    color-scheme: light; /* evita el modo oscuro automático del navegador */

    --bg: #F6F7F9;
    --surface: #FFFFFF;
    --border: #E7E9EE;
    --ink: #1F2733;
    --text: #3A4453;
    --muted: #8993A4;

    --accent: #2A63D6;        /* azul: acento único de la marca */
    --accent-dark: #1F4FB0;
    --accent-soft: #E4ECFC;   /* fondo suave del acento */

    --success: #2F7D5A;
    --success-bg: #E4F3EA;
    --warning: #B7791F;
    --warning-bg: #FCEED9;
    --danger: #C0392B;
    --danger-bg: #FBE7E4;
    --neutral-bg: #EEF0F3;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-xs: 0 1px 2px rgba(31,39,51,.04);
    --shadow-sm: 0 2px 8px rgba(31,39,51,.06);
    --shadow-md: 0 10px 30px rgba(31,39,51,.08);
    --shadow-lg: 0 30px 70px rgba(10,15,25,.35);
}

html { color-scheme: light; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: .94rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.015em;
    margin-top: 0;
}
p { color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

/* Respaldo para las clases utilitarias .h1–.h6 (por si Bootstrap no carga) */
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: var(--ink);
}
.h1 { font-size: 2.4rem; } .h2 { font-size: 1.95rem; } .h3 { font-size: 1.7rem; }
.h4 { font-size: 1.4rem; } .h5 { font-size: 1.15rem; } .h6 { font-size: 1rem; }

/* =========================================================
   Topbar
   ========================================================= */
.app-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-navbar .navbar-brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--ink);
    letter-spacing: -.01em;
}
.navbar-user { display: flex; align-items: center; gap: .85rem; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: .85rem; color: var(--ink); line-height: 1.25; }
.user-role { font-size: .74rem; color: var(--muted); line-height: 1.25; }
.btn-icon {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); background: transparent;
    transition: background .15s ease, color .15s ease;
}
.btn-icon:hover { background: var(--neutral-bg); color: var(--danger); text-decoration: none; }

/* =========================================================
   Layout
   ========================================================= */
.app-container { display: flex; align-items: stretch; min-height: calc(100vh - 64px); }

.app-sidebar {
    width: 258px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
}
.sidebar-group + .sidebar-group { margin-top: 1.5rem; }
.sidebar-heading {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 700;
    padding: 0 1.5rem .5rem;
}
.sidebar-link {
    display: flex; align-items: center;
    margin: .15rem .9rem;
    padding: .6rem .85rem;
    color: var(--text);
    font-size: .89rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .15s ease, color .15s ease;
}
.sidebar-link i { width: 18px; margin-right: 10px; color: var(--muted); text-align: center; font-size: .85rem; }
.sidebar-link:hover { background: var(--neutral-bg); color: var(--ink); text-decoration: none; }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.sidebar-link.active i { color: var(--accent-dark); }
.sidebar-link.disabled { opacity: .45; cursor: not-allowed; }

.app-content { flex: 1; padding: 2rem 3rem; min-width: 0; }
.app-content > * + * { margin-top: 2rem; }

/* =========================================================
   Tarjetas
   ========================================================= */
.card-stat { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); background: var(--surface); }
.card-stat .card-body { padding: 1.5rem 1.75rem; }
.card-stat .h3 { font-weight: 800; }

/* Grilla de tarjetas de estadística: SIEMPRE 3 en línea (no depende
   de los breakpoints de Bootstrap), solo se apila en pantallas muy chicas. */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Barra de 2 columnas dentro de formularios (ej. NIT + Teléfono) */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
@media (max-width: 420px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* Barra de filtros: buscar + estado + botón, siempre en línea */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; }
.filter-grow { flex: 1 1 260px; }
.filter-fixed { flex: 0 0 180px; }
.filter-btn { flex: 0 0 140px; }
@media (max-width: 480px) {
    .filter-field { flex: 1 1 100%; }
}

/* =========================================================
   Tablas
   ========================================================= */
.table { margin-bottom: 0; width: 100%; }
.table thead th {
    border: none; border-bottom: 1px solid var(--border);
    color: var(--muted); font-size: .7rem; text-transform: uppercase;
    letter-spacing: .07em; font-weight: 700; padding: .95rem 1.5rem;
    background: #FBFBFC; text-align: left;
}
.table td { border: none; border-bottom: 1px solid var(--border); padding: 1.05rem 1.5rem; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFAFB; }

/* =========================================================
   Formularios — con reglas propias de respaldo (no dependen
   de que bootstrap.css cargue para verse bien)
   ========================================================= */
.form-group { margin-bottom: 1.5rem; display: block; }
label { display: block; font-weight: 600; font-size: .85rem; color: var(--ink); margin-bottom: .45rem; }

.form-control {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: .7rem .95rem;
    font-size: .92rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: #B7BEC9; }
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3.5px var(--accent-soft);
}
select.form-control { cursor: pointer; }

/* =========================================================
   Botones
   ========================================================= */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: .65rem 1.4rem;
    font-weight: 600;
    font-size: .89rem;
    text-align: center;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-block { display: block; width: 100%; }
.btn-sm { padding: .4rem .85rem; font-size: .82rem; }

.btn-brand, .btn-success {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-brand:hover, .btn-success:hover {
    background: var(--accent-dark); border-color: var(--accent-dark); color: #fff;
}
.btn-outline-secondary { color: var(--text); border-color: var(--border); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--neutral-bg); border-color: var(--border); color: var(--ink); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-outline-success { color: var(--success); border-color: var(--success); background: var(--surface); }
.btn-outline-success:hover { background: var(--success); color: #fff; }

/* =========================================================
   Modales — implementación propia (no depende de bootstrap.js)
   Se controlan con la clase .show desde assets/js/app.js
   ========================================================= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,32,.6);
    z-index: 1050;
    overflow-y: auto;
    padding: 3rem 1rem;
}
.modal.show { display: block; }
.modal-dialog { max-width: 540px; margin: 0 auto; }
.modal-content { border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); background: var(--surface); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding: 1.4rem 1.75rem;
}
.modal-header .modal-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: .6rem;
    border-top: 1px solid var(--border);
    padding: 1.25rem 1.75rem;
}
.modal-body { padding: 1.75rem; }
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.modal-body h6 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }

.close {
    background: transparent; border: 0; padding: 0;
    font-size: 1.5rem; line-height: 1;
    color: var(--muted); opacity: .8; cursor: pointer;
}
.close:hover { opacity: 1; color: var(--ink); }

/* =========================================================
   Badges / estados
   ========================================================= */
.badge { font-weight: 700; letter-spacing: .03em; text-transform: uppercase; font-size: .66rem; padding: .42em .75em; border-radius: 6px; }
.badge-activo { background: var(--success-bg); color: var(--success); }
.badge-inactivo { background: var(--neutral-bg); color: var(--muted); }
.badge-secondary { background: var(--neutral-bg); color: var(--muted); }

/* =========================================================
   Login
   ========================================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1.5rem;
    background: radial-gradient(circle at 30% 20%, #24405C, #10202F 65%);
}
.login-seal {
    width: 60px; height: 60px; border-radius: 50%;
    border: 2px solid var(--accent);
    outline: 1px solid rgba(42,99,214,.5); outline-offset: 4px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Spectral', serif; font-weight: 700; font-size: .92rem; letter-spacing: .07em;
    color: #9CC2F7;
    background: rgba(42,99,214,.15);
    transform: rotate(-6deg);
}
.login-card { width: 100%; max-width: 390px; border: none; border-radius: 16px; box-shadow: var(--shadow-lg); background: var(--surface); }
.login-card .card-body { padding: 2.5rem; }
.login-card h4 { font-family: 'Spectral', serif; font-size: 1.5rem; color: var(--ink); }

/* =========================================================
   Alertas
   ========================================================= */
.alert { border: none; border-radius: var(--radius-sm); padding: .95rem 1.3rem; font-size: .89rem; }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
