/* ============================================================
   Despachante CAC — Estilos
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #a8b2c8;
  --sidebar-active: #4f8ef7;
  --topbar-h: 64px;
  --body-bg: #f4f6fb;
}

body {
  background: var(--body-bg);
  font-family: 'Segoe UI', sans-serif;
  font-size: 0.9rem;
}

/* ── Tema escuro ── */
[data-bs-theme="dark"] {
  --body-bg: #0d1117;
  --sidebar-bg: #11151f;
}
[data-bs-theme="dark"] body { background: var(--body-bg); }
[data-bs-theme="dark"] .topbar { background: #161b26; border-bottom-color: #232a38; }
[data-bs-theme="dark"] .card { background: #161b26; border-color: #232a38; }
[data-bs-theme="dark"] .form-label { color: #aeb9cc; }
[data-bs-theme="dark"] .table { --bs-table-bg: transparent; }
[data-bs-theme="dark"] .bg-primary-soft { background: rgba(79,142,247,0.18); }
[data-bs-theme="dark"] .bg-light { background-color: #1c2230 !important; }
[data-bs-theme="dark"] .table-light > * { --bs-table-bg: #1c2230; color: #e6e9ef; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  overflow-y: auto;
  transition: width 0.25s ease;
}

#sidebar .sidebar-brand {
  padding: 1.25rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
}

#sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 0.55rem 1.25rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
  font-size: 0.82rem;
  transition: all 0.15s;
}

#sidebar .nav-link i { font-size: 1rem; min-width: 1.1rem; }

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

#sidebar .nav-link.active {
  background: rgba(79,142,247,0.18);
  color: var(--sidebar-active);
  border-left: 3px solid var(--sidebar-active);
}

.nav-divider {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 0.5rem 0;
}

/* ── Content ── */
#content-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  transition: margin-left 0.25s ease, width 0.25s ease;
}

#content-wrapper .container-fluid {
  max-width: 1600px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

body.sidebar-collapsed #content-wrapper { width: calc(100% - 64px); }

/* ── Topbar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  height: var(--topbar-h);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── Sidebar collapsed ── */
body.sidebar-collapsed #sidebar { width: 64px; }
body.sidebar-collapsed #sidebar .sidebar-brand span,
body.sidebar-collapsed #sidebar .nav-link span { display: none; }
body.sidebar-collapsed #content-wrapper { margin-left: 64px; }

/* ── Stat cards ── */
.stat-card { transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1) !important; }

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

.bg-primary-soft { background: rgba(13,110,253,0.12); }
.bg-warning-soft  { background: rgba(255,193,7,0.15); }
.bg-danger-soft   { background: rgba(220,53,69,0.12); }
.bg-success-soft  { background: rgba(25,135,84,0.12); }
.bg-info-soft     { background: rgba(13,202,240,0.12); }

/* ── Cards ── */
.card { border-radius: 12px; }
.card-header { border-radius: 12px 12px 0 0 !important; }

/* ── Tables ── */
.table > thead > tr > th { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em; }
.table > tbody > tr { vertical-align: middle; }

/* ── Badges ── */
.badge { font-weight: 500; }

/* ── Forms ── */
.form-control, .form-select { font-size: 0.85rem; }
.form-label { font-weight: 600; font-size: 0.8rem; color: #495057; margin-bottom: 0.3rem; }

/* ── Alerts ── */
.alert { font-size: 0.85rem; }

/* ── Login page ── */
body:not(:has(#wrapper)) { background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%); }

/* ── DataTables overrides ── */
.dataTables_wrapper .dataTables_filter input { font-size: 0.82rem; }
.dataTables_wrapper .dataTables_length select { font-size: 0.82rem; }

/* ── Urgency row colors ── */
tr[data-urg="vencido"] { background: rgba(220,53,69,0.06) !important; }
tr[data-urg="critico"] { background: rgba(220,53,69,0.04) !important; }
tr[data-urg="alerta"]  { background: rgba(255,193,7,0.05) !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #sidebar { width: 64px; }
  #sidebar .sidebar-brand span, #sidebar .nav-link span { display: none; }
  #content-wrapper { margin-left: 64px; }
}

@media (max-width: 576px) {
  #sidebar { display: none; }
  #content-wrapper { margin-left: 0; }
}

/* ── Print ── */
@media print {
  #sidebar, .topbar, .btn, .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_paginate { display: none !important; }
  #content-wrapper { margin-left: 0 !important; }
}
