/* ===================================================================
   WebInfoFact - Hoja de estilos (SaaS UI)
   =================================================================== */
:root {
    --wf-sidebar-bg: #0f172a;
    --wf-sidebar-fg: #cbd5e1;
    --wf-sidebar-active: #2563eb;
    --wf-radius: 12px;
}
[data-bs-theme="light"] {
    --wf-bg: #f1f5f9;
    --wf-card: #ffffff;
    --wf-border: #e2e8f0;
}
[data-bs-theme="dark"] {
    --wf-bg: #0b1120;
    --wf-card: #111a2e;
    --wf-border: #1e293b;
    --wf-sidebar-bg: #060b18;
}

* { box-sizing: border-box; }
body {
    background: var(--wf-bg);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ----------------------------- Shell ----------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--wf-sidebar-bg);
    color: var(--wf-sidebar-fg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.15rem 1.25rem;
    font-size: 1.2rem; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand i { color: var(--wf-sidebar-active); font-size: 1.5rem; }
.sidebar-nav { padding: .75rem .5rem; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .85rem; margin-bottom: .15rem;
    color: var(--wf-sidebar-fg); text-decoration: none;
    border-radius: 8px; font-size: .92rem;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-item.active { background: var(--wf-sidebar-active); color: #fff; }
.sidebar-nav .nav-item i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-foot { padding: .85rem 1.25rem; color: #64748b; border-top: 1px solid rgba(255,255,255,.07); }

.main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }

/* ----------------------------- Topbar ---------------------------- */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .65rem 1.25rem;
    background: var(--wf-card);
    border-bottom: 1px solid var(--wf-border);
    position: sticky; top: 0; z-index: 1030;
}
.topbar-search {
    position: relative; flex: 1; max-width: 380px;
}
.topbar-search i {
    position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
    color: #94a3b8;
}
.topbar-search input {
    width: 100%; padding: .45rem .7rem .45rem 2rem;
    border: 1px solid var(--wf-border); border-radius: 999px;
    background: var(--wf-bg); color: inherit;
}
.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.btn-icon {
    border: 1px solid var(--wf-border); background: var(--wf-bg);
    color: inherit; width: 36px; height: 36px; border-radius: 8px;
}
.user-chip {
    display: flex; align-items: center; gap: .5rem;
    border: 1px solid var(--wf-border); background: var(--wf-bg); color: inherit;
}
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--wf-sidebar-active); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem;
}

/* ---------------------------- Content ---------------------------- */
.content { padding: 1.5rem; flex: 1; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem;
}
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head .subtitle { color: #94a3b8; font-size: .9rem; }

/* ----------------------------- Cards ----------------------------- */
.card {
    background: var(--wf-card);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius);
}
.card-head {
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--wf-border);
    font-weight: 600; display: flex; align-items: center; justify-content: space-between;
}

/* ---------------------------- Stat KPI --------------------------- */
.kpi-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    margin-bottom: 1.25rem;
}
.kpi {
    background: var(--wf-card); border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius); padding: 1.05rem 1.15rem;
}
.kpi .kpi-label { color: #94a3b8; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }
.kpi .kpi-icon {
    float: right; width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.kpi-icon.bg-soft-primary { background: rgba(37,99,235,.12); color: #2563eb; }
.kpi-icon.bg-soft-success { background: rgba(22,163,74,.12); color: #16a34a; }
.kpi-icon.bg-soft-warning { background: rgba(217,119,6,.14); color: #d97706; }
.kpi-icon.bg-soft-danger  { background: rgba(220,38,38,.12); color: #dc2626; }

/* ---------------------------- Tables ----------------------------- */
.table { margin: 0; }
.table thead th {
    font-size: .76rem; text-transform: uppercase; letter-spacing: .03em;
    color: #94a3b8; border-bottom: 2px solid var(--wf-border);
}
.table td, .table th { padding: .7rem .9rem; vertical-align: middle; }
.table-card { overflow: hidden; }
.table-card .table-responsive { border-radius: 0 0 var(--wf-radius) var(--wf-radius); }

/* ---------------------------- Misc ------------------------------- */
.empty-state { text-align: center; padding: 3.5rem 1rem; }
.empty-state i { font-size: 3rem; color: #cbd5e1; }
.empty-state h3 { margin-top: 1rem; }
.badge { font-weight: 600; }
.dash-grid { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; }
.detail-grid { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { display: flex; justify-content: space-between; padding: .45rem 0;
    border-bottom: 1px dashed var(--wf-border); font-size: .92rem; }
.info-list li:last-child { border-bottom: 0; }
.info-list .lbl { color: #94a3b8; }
.alerta-item {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .6rem .25rem; border-bottom: 1px solid var(--wf-border); font-size: .9rem;
}
.alerta-item:last-child { border-bottom: 0; }

/* ---------------------------- Login ------------------------------ */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.login-card {
    background: var(--wf-card); border-radius: 16px;
    padding: 2.25rem; width: 100%; max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand i { font-size: 2.4rem; color: var(--wf-sidebar-active); }
.login-brand h1 { font-size: 1.5rem; margin: .35rem 0 .15rem; }
.login-brand p { color: #94a3b8; font-size: .85rem; margin: 0; }
.login-demo {
    margin-top: 1.25rem; padding: .65rem; text-align: center;
    background: var(--wf-bg); border-radius: 8px; font-size: .82rem; color: #64748b;
}

/* --------------------------- Backdrop ---------------------------- */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1035;
}

/* -------------------------- Responsive --------------------------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-backdrop.show { display: block; }
    .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}

/* ------------------------- Print (PDF) --------------------------- */
@media print {
    .no-print { display: none !important; }
}

/* ------------------- KPI con enlace al detalle ------------------- */
a.kpi { display: block; color: inherit;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
a.kpi:hover { border-color: var(--wf-sidebar-active);
    transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.kpi-link { display: block; margin-top: .5rem;
    color: var(--wf-sidebar-active); font-weight: 600; font-size: .8rem; }

/* ------------------- Tom Select (buscador en dropdowns) ---------- */
.ts-wrapper { font-size: .95rem; }
.ts-control, .ts-dropdown {
    background: var(--wf-card); color: inherit; border-color: var(--wf-border);
}
.ts-control input, .ts-dropdown .option { color: inherit; }
.ts-dropdown .active { background: var(--wf-sidebar-active); color: #fff; }
.ts-wrapper.single .ts-control:after { border-color: #94a3b8 transparent transparent; }
