/* TechShop Pro Kenya — design system on top of Bootstrap 5
   Brand + chart colors share one validated palette (see /database — dataviz skill,
   OKLab-checked for colorblind-safety) so KPI tiles, badges, and charts agree. */

:root {
  /* Brand (= chart series-1, so buttons/links/charts read as one system) */
  --brand: #2a78d6;
  --brand-dark: #1c5cab;
  --brand-soft: #eaf2fc;

  /* Chart categorical series (adjacent pair, CVD-checked) */
  --series-1: #2a78d6; /* blue   */
  --series-2: #1baf7a; /* aqua   */

  /* Status palette — fixed, never reused for series identity */
  --status-good: #0ca30c;
  --status-good-soft: #e9f8e9;
  --status-warning: #d97706;   /* darkened from #fab219 for text/icon contrast on light bg */
  --status-warning-soft: #fef6e7;
  --status-serious: #c85a34;   /* darkened from #ec835a for AA-ish contrast */
  --status-serious-soft: #fdefe9;
  --status-critical: #d03b3b;
  --status-critical-soft: #fbeaea;

  --sidebar-bg: #0f1522;
  --sidebar-hover: #1a2233;
  --sidebar-active: rgba(42,120,214,.22);

  --ink: #14181f;
  --ink-secondary: #52565e;
  --muted: #6b7280;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --card-border: #e6e9ef;
  --ring: rgba(42,120,214,.16);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16,24,40,.05);
  --shadow-2: 0 4px 16px rgba(16,24,40,.07);
  --shadow-3: 0 12px 32px rgba(16,24,40,.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
::selection { background: var(--ring); }

/* Re-point Bootstrap's own primary to the brand blue so btn-primary, links,
   focus rings, form-check, and bg/text-primary-subtle utilities stay in sync. */
:root {
  --bs-primary: #2a78d6;
  --bs-primary-rgb: 42, 120, 214;
  --bs-link-color: #2a78d6;
  --bs-link-color-rgb: 42, 120, 214;
  --bs-link-hover-color: #1c5cab;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); box-shadow: none; }
.btn { font-weight: 600; font-size: 13.5px; border-radius: var(--radius-sm); padding: 7px 16px; }
.btn-sm { font-size: 12.5px; padding: 5px 12px; }
.btn:focus, .form-control:focus, .form-select:focus { box-shadow: 0 0 0 3px var(--ring); border-color: var(--brand); }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--card-border); font-size: 13.5px; }
.form-label { font-weight: 600; color: var(--ink-secondary); }

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

.sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #2a78d6, #7b5ce0);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
}
.brand-name { font-weight: 800; font-size: 14px; color: #fff; letter-spacing: -0.2px; }
.brand-sub { font-size: 9.5px; color: #64748b; letter-spacing: .5px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; padding-right: 2px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #263045; border-radius: 4px; }

.nav-group-label {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px;
  color: #4b5568; padding: 14px 12px 5px;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-link-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 10px; border-radius: 8px; color: #9aa4b6;
  font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s, border-color .12s;
  border-left: 3px solid transparent; position: relative;
}
.nav-link-item i { font-size: 15.5px; width: 18px; text-align: center; }
.nav-link-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link-item.active { background: var(--sidebar-active); color: #6cabf2; font-weight: 700; border-left-color: var(--brand); }
.badge-mini {
  margin-left: auto; background: rgba(27,175,122,.2); color: #3ecf98;
  font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 99px;
}

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #171f30; margin-top: 10px; position: relative; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 12.5px; font-weight: 700; color: #fff; }
.user-role { font-size: 10.5px; color: #64748b; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--card-border);
  padding: 13px 26px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 17.5px; font-weight: 800; margin: 0; letter-spacing: -.2px; }
.topbar-sub { font-size: 11.5px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.branch-pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand-dark);
  font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: none; cursor: pointer;
}

.pill {
  font-size: 11.5px; font-weight: 700; padding: 6px 12px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pill-good { background: var(--status-good-soft); color: var(--status-good); }
.pill-warning { background: var(--status-warning-soft); color: var(--status-warning); }
.pill-critical { background: var(--status-critical-soft); color: var(--status-critical); }

/* ── Notifications dropdown ───────────────────────────────────────────────── */
.notif-btn { position: relative; background: var(--bg); border: 1px solid var(--card-border); border-radius: var(--radius-sm); color: var(--ink-secondary); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.notif-dot { position: absolute; top: -3px; right: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--status-critical); font-size: 9px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; border: 2px solid var(--surface); }
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow-3); border: 1px solid var(--card-border); }
.notif-item { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; }
.notif-item:hover { background: var(--bg); }
.notif-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.avatar-menu { min-width: 200px; padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow-3); border: 1px solid var(--card-border); }

.content { padding: 24px; flex: 1; }

.site-footer {
  padding: 14px 24px; border-top: 1px solid var(--card-border); background: var(--surface);
  font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px;
}
.page-lede { font-size: 13px; color: var(--muted); margin-top: -10px; margin-bottom: 18px; }

/* ── Cards / KPIs ─────────────────────────────────────────────────────────── */
.card { border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-body { padding: 18px; }
a.card-link-hover { display: block; }
a.card-link-hover .card { transition: box-shadow .15s, border-color .15s, transform .15s; }
a.card-link-hover:hover .card { box-shadow: var(--shadow-2); border-color: #d7dce4; transform: translateY(-1px); }

.kpi-label { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.kpi-value { font-size: 23px; font-weight: 800; line-height: 1.15; margin-top: 6px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
}
.kpi-icon-blue { background: var(--brand-soft); color: var(--brand); }
.kpi-icon-good { background: var(--status-good-soft); color: var(--status-good); }
.kpi-icon-warning { background: var(--status-warning-soft); color: var(--status-warning); }
.kpi-icon-critical { background: var(--status-critical-soft); color: var(--status-critical); }
.kpi-icon-violet { background: #f1eefb; color: #6b4de0; }

.stat-trend-up { color: var(--status-good); font-weight: 700; font-size: 11.5px; }
.stat-trend-down { color: var(--status-critical); font-weight: 700; font-size: 11.5px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  border-bottom-width: 1px; border-color: var(--card-border); font-weight: 700; white-space: nowrap;
}
.table td { vertical-align: middle; font-size: 13.5px; border-color: var(--card-border); }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 32px; opacity: .35; margin-bottom: 10px; display: block; }
.empty-state-title { font-weight: 700; color: var(--ink-secondary); margin-bottom: 3px; }

/* ── POS ──────────────────────────────────────────────────────────────────── */
.pos-product-card {
  border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 12px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .1s; background: var(--surface);
}
.pos-product-card:hover { border-color: var(--brand); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.pos-product-card:active { transform: translateY(0); }
.pos-product-card.disabled { opacity: .45; cursor: not-allowed; }
.pos-product-card.disabled:hover { transform: none; box-shadow: none; border-color: var(--card-border); }
.pos-cart-scroll { max-height: 320px; overflow-y: auto; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.section-title { font-size: 14.5px; font-weight: 800; margin-bottom: 14px; letter-spacing: -.1px; }
.text-muted-sm { font-size: 11.5px; color: var(--muted); }
.badge-soft { font-weight: 700; font-size: 10.5px; padding: 4px 9px; border-radius: 99px; }
.workflow-step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 5px 0; }
.workflow-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: #fff; border: 2px solid var(--card-border); background: #fff;
}
.workflow-dot.done { background: var(--status-good); border-color: var(--status-good); }
.workflow-dot.active { background: var(--brand); border-color: var(--brand); }

.stepper-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.stepper-nav .chip { border: 1px solid var(--card-border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted); }
.stepper-nav .chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #16233e 0%, #0b1120 55%, #05070d 100%);
  padding: 20px;
}
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius-lg); padding: 40px 34px; box-shadow: var(--shadow-3); }

@media (max-width: 991px) {
  .sidebar { position: fixed; left: -260px; z-index: 1000; transition: left .2s; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar-sub { display: none; }
}

/* Dashboard · New Web Orders card — rows blink until the order is opened / marked seen */
.web-orders-card { transition: box-shadow .3s, border-color .3s; }
.web-orders-card.has-new { border-color: var(--status-critical); animation: webOrdersGlow 1.6s ease-in-out infinite; }
.web-order-row { padding: 7px 8px; margin: 0 -8px; border-radius: 8px; border-left: 3px solid transparent; }
.web-order-row + .web-order-row { border-top: 1px solid var(--card-border); }
.web-order-row:hover { background: var(--brand-soft); }
.web-order-row.is-new { border-left-color: var(--status-critical); animation: webOrderBlink 1.2s ease-in-out infinite; }
.web-orders-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--status-critical); animation: webOrdersPing 1.2s ease-out infinite; }
@keyframes webOrderBlink { 0%, 100% { background: transparent; } 50% { background: var(--status-critical-soft); } }
@keyframes webOrdersGlow { 0%, 100% { box-shadow: var(--shadow-1); } 50% { box-shadow: 0 0 0 4px rgba(208, 59, 59, .18); } }
@keyframes webOrdersPing { 0% { box-shadow: 0 0 0 0 rgba(208, 59, 59, .6); } 100% { box-shadow: 0 0 0 8px rgba(208, 59, 59, 0); } }
@media (prefers-reduced-motion: reduce) {
  .web-orders-card.has-new, .web-order-row.is-new, .web-orders-dot { animation: none; }
  .web-order-row.is-new { background: var(--status-critical-soft); }
}
