/* GuardLink Command — Dark Dispatch Theme */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #080d18;
  --surface: #0f1729;
  --surface2: #172033;
  --surface3: #1e2d44;
  --border: #1e3050;
  --accent: #0ea5e9;
  --accent2: #7c3aed;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);

  /* Compatibility aliases. Several feature pages (messages, schedule,
     patrols/overview, reports/*, roster/calendar, clients/*) were authored
     against these token names, which were never defined — so they fell back to
     hardcoded light defaults and rendered as white "islands" inside the dark
     shell. Mapping them to the real palette re-themes those pages consistently.
     A future light mode overrides these under [data-bs-theme="light"]. */
  --primary: var(--accent);
  --gl-text: var(--text);
  --gl-muted: var(--text-muted);
  --gl-surface: var(--surface);
  --gl-surface-2: var(--surface2);
  --gl-border: var(--border);
  --gl-border-light: var(--surface3);

  /* Soft status chips (job blocks, report cells, badges). Dark defaults here; the
     light theme below restores the original Bootstrap-ish pastels. Always use these
     instead of hardcoding pastel hexes so both themes stay correct. */
  --st-success-bg: rgba(16,185,129,0.16);  --st-success-fg: #34d399;  --st-success-border: rgba(16,185,129,0.45);
  --st-info-bg:    rgba(14,165,233,0.16);  --st-info-fg:    #38bdf8;  --st-info-border:    rgba(14,165,233,0.45);
  --st-danger-bg:  rgba(239,68,68,0.16);   --st-danger-fg:  #f87171;  --st-danger-border:  rgba(239,68,68,0.5);
  --st-warning-bg: rgba(245,158,11,0.16);  --st-warning-fg: #fbbf24;  --st-warning-border: rgba(245,158,11,0.45);
  --st-neutral-bg: var(--surface3);        --st-neutral-fg: var(--text-dim);   --st-neutral-border: var(--border);
  --st-muted-bg:   var(--surface2);        --st-muted-fg:   var(--text-muted); --st-muted-border:   var(--border);
}

/* ── Light mode ─────────────────────────────────────────────────────────────
   Only the base palette is overridden; the --gl-* aliases reference these vars
   so they follow automatically. Accent/status hues are shared across themes.
   Toggle lives in the nav; preference persists in localStorage (see main.js). */
:root[data-bs-theme="light"] {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --surface3: #e2e8f0;
  --border: #d3dce6;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #475569;
  --shadow: 0 4px 24px rgba(15,23,42,0.10);

  /* Restore the original pastels in light mode. */
  --st-success-bg: #d4edda; --st-success-fg: #155724; --st-success-border: #b1dfbb;
  --st-info-bg:    #cce5ff; --st-info-fg:    #004085; --st-info-border:    #99caff;
  --st-danger-bg:  #f8d7da; --st-danger-fg:  #721c24; --st-danger-border:  #f5c6cb;
  --st-warning-bg: #fff3cd; --st-warning-fg: #856404; --st-warning-border: #ffeeba;
  --st-neutral-bg: #e2e3e5; --st-neutral-fg: #383d41; --st-neutral-border: #c8cbcf;
  --st-muted-bg:   #f8f9fa; --st-muted-fg:   #6c757d; --st-muted-border:   #ced4da;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* Automated Mode Banner */
.auto-banner {
  background: linear-gradient(90deg, #7c3aed 0%, #0ea5e9 100%);
  text-align: center;
  padding: 5px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: white;
}

/* Navbar */
.main-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.brand-icon {
  background: linear-gradient(135deg, var(--accent2) 0%, var(--accent) 100%);
  color: white;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.brand-name { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.brand-tag { font-size: 0.62rem; font-weight: 700; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; }

.nav-link {
  color: var(--text-muted) !important;
  font-size: 0.85rem; font-weight: 500;
  padding: 0.45rem 0.7rem !important;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  position: relative;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text) !important; background: var(--surface2); }
.nav-link.active { color: var(--accent) !important; background: rgba(14,165,233,0.1); }

.q-badge {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: white;
  font-size: 0.58rem; font-weight: 700;
  border-radius: 8px; padding: 1px 4px; min-width: 14px;
  text-align: center; display: none; line-height: 1.4;
}

.user-chip { display: flex; align-items: center; gap: 6px; color: var(--text-dim) !important; }
.user-av {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: white; width: 28px; height: 28px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
}

/* Main Content */
.main-content { padding: 1.5rem; max-width: 1600px; margin: 0 auto; }
@media (max-width: 768px) { .main-content { padding: 0.875rem 0.75rem; } }

/* Page Header */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-title {
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  margin: 0; display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.02em;
}
.page-title i { color: var(--accent); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header {
  background: var(--surface2); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.875rem;
  padding: 0.8rem 1.2rem; border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center;
}
.card-body { padding: 1.2rem; }
.card-body.p-0 { padding: 0; }
.card-body.p-2 { padding: 0.5rem; }

/* Stat Cards */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.stat-card.c-green::before { background: var(--success); }
.stat-card.c-orange::before { background: var(--warning); }
.stat-card.c-red::before { background: var(--danger); }
.stat-card.c-purple::before { background: var(--accent2); }
.stat-num { font-size: 2.2rem; font-weight: 700; font-family: var(--mono); line-height: 1; }
.stat-label { font-size: 0.73rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }
.stat-icon { position: absolute; right: 1.1rem; top: 1.1rem; font-size: 1.8rem; opacity: 0.12; }

/* Job Cards */
.job-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  transition: all 0.15s; cursor: pointer;
}
.job-card:hover { border-color: rgba(14,165,233,0.5); background: var(--surface2); transform: translateX(2px); }
.job-card.overdue { border-left: 3px solid var(--danger); }

/* Status Badges */
.badge-status {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.06em; padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; vertical-align: middle;
}
.bs-PENDING            { background: rgba(14,165,233,.15);  color:#38bdf8; border:1px solid rgba(14,165,233,.3); }
.bs-ACTIVE             { background: rgba(16,185,129,.15);  color:#34d399; border:1px solid rgba(16,185,129,.3); }
.bs-COMPLETED          { background: rgba(100,116,139,.15); color:#94a3b8; border:1px solid rgba(100,116,139,.3); }
.bs-CANCELLED          { background: rgba(239,68,68,.15);   color:#f87171; border:1px solid rgba(239,68,68,.3); }
.bs-ABANDONED          { background: rgba(51,65,85,.4);     color:#64748b; border:1px solid #334155; }
.bs-REJECTED           { background: rgba(239,68,68,.15);   color:#f87171; border:1px solid rgba(239,68,68,.3); }
.bs-NEEDS_CONFIRMATION { background: rgba(245,158,11,.15);  color:#fbbf24; border:1px solid rgba(245,158,11,.3); }
.bs-NO_CLIENT_MATCH    { background: rgba(245,158,11,.10);  color:#fbbf24; border:1px solid rgba(245,158,11,.2); }
.bs-OFFERED            { background: rgba(99,102,241,.15);  color:#a5b4fc; border:1px solid rgba(99,102,241,.3); }
.bs-NO_PATROL_MATCH    { background: rgba(245,158,11,.15);  color:#fbbf24; border:1px solid rgba(245,158,11,.3); }

/* Tables */
.table { color: var(--text); font-size: 0.875rem; }
.table thead th {
  background: var(--surface2); border-color: var(--border);
  color: var(--text-muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; white-space: nowrap; padding: 0.6rem 0.875rem;
}
.table tbody td { border-color: var(--border); vertical-align: middle; padding: 0.65rem 0.875rem; }
.table tbody tr:hover { background: var(--surface2); }

/* Forms */
.form-control, .form-select {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(14,165,233,.15) !important;
}
.form-control::placeholder { color: var(--text-muted) !important; }
.form-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px;
}
.input-group-text { background: var(--surface2); border-color: var(--border); color: var(--text-muted); }
.form-check-input { background-color: var(--surface2); border-color: var(--border); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* Buttons */
.btn { font-size: 0.85rem; font-weight: 600; border-radius: var(--radius-sm); transition: all 0.15s; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: #0284c7; border-color: #0284c7; transform: translateY(-1px); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #1a1a1a; }
.btn-outline-secondary { border-color: var(--border); color: var(--text-dim); background: transparent; }
.btn-outline-secondary:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }

/* Modals */
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-header { border-bottom: 1px solid var(--border); background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0; }
.modal-footer { border-top: 1px solid var(--border); }

/* Dropdowns */
.dropdown-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.dropdown-item { color: var(--text); font-size: 0.875rem; padding: 0.45rem 0.875rem; border-radius: 4px; }
.dropdown-item:hover { background: var(--surface2); color: var(--text); }
.dropdown-divider { border-color: var(--border); }

/* Pagination */
.page-link { background: var(--surface); border-color: var(--border); color: var(--text-muted); font-size: 0.85rem; }
.page-link:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: white; }

/* Search Bar */
.search-bar {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem 1.1rem; margin-bottom: 1.25rem;
}

/* Attention Banner */
.attn-banner {
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  border-radius: var(--radius); padding: 0.875rem 1.1rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.875rem;
}

/* Timeline */
.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before {
  content: ''; position: absolute; left: 0.375rem; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; margin-bottom: 1rem; }
.tl-dot {
  position: absolute; left: -1.5rem; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.tl-time { font-size: 0.7rem; color: var(--text-muted); font-family: var(--mono); }
.tl-label { font-size: 0.85rem; font-weight: 600; }
.tl-note { font-size: 0.82rem; color: var(--text-dim); }

/* Roster */
.officer-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.875rem; }
.officer-card.on-shift { border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.04); }
.shift-time { font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted); }

/* Attachments */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); gap: 0.75rem; }
.att-thumb {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  opacity: 0; transition: opacity 0.15s;
}
.att-thumb:hover .att-overlay { opacity: 1; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state > i { font-size: 2.5rem; opacity: 0.3; display: block; margin-bottom: 0.75rem; }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 25% 60%, rgba(124,58,237,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 20%, rgba(14,165,233,.07) 0%, transparent 50%);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 420px; box-shadow: var(--shadow);
}

/* Utilities */
.mono { font-family: var(--mono); }
.text-accent { color: var(--accent); }
a { color: var(--accent); }
a:hover { color: #38bdf8; }
hr { border-color: var(--border); }
.section-hr { height: 1px; background: var(--border); margin: 1.5rem 0; border: none; }
.text-muted { color: var(--text-muted) !important; }
.text-dim { color: var(--text-dim) !important; }
.bg-surface2 { background: var(--surface2) !important; }
.border-gl { border-color: var(--border) !important; }
.rounded-gl { border-radius: var(--radius); }
pre { color: var(--text-dim); font-family: var(--mono); font-size: 0.8rem; }
code { color: var(--accent); font-family: var(--mono); }

@media (max-width: 576px) {
  .stat-num { font-size: 1.6rem; }
  .page-title { font-size: 1.1rem; }
  .btn { font-size: 0.8rem; }
}
