/* AfriDais Delivery Hub — light/dark theme via CSS custom properties */

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --border: #dde3e8;
  --text: #1d2733;
  --text-muted: #5c6b7a;
  --accent: #1f8a4c;
  --accent-hover: #17703e;
  --accent-contrast: #ffffff;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warn: #b7770d;
  --warn-bg: #fdf3e0;
  --info-bg: #e8f4ee;
  --shadow: 0 1px 3px rgba(16, 32, 48, 0.08);
  --sidebar-bg: #17352a;
  --sidebar-text: #d7e6dd;
  --sidebar-active: #1f8a4c;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12181f;
  --surface: #1b232d;
  --surface-2: #232e3a;
  --border: #33404e;
  --text: #e6edf3;
  --text-muted: #96a5b3;
  --accent: #34b268;
  --accent-hover: #45c67a;
  --accent-contrast: #0c1410;
  --danger: #e06c5c;
  --danger-bg: #3a2422;
  --warn: #e0a44a;
  --warn-bg: #382c1a;
  --info-bg: #17352a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --sidebar-bg: #101f19;
  --sidebar-text: #c4d8cd;
  --sidebar-active: #34b268;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
}
.login-card img { height: 64px; margin-bottom: 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 20px; }

/* ------------------------------------------------------------ layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 4px 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 10px;
}
.sidebar .brand img {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 52px;
  object-fit: contain;
}
.sidebar .brand span { font-weight: 600; font-size: 13px; }
.sidebar a {
  display: block;
  color: var(--sidebar-text);
  padding: 9px 18px;
  font-size: 13.5px;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.sidebar a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header .page-title { font-size: 17px; font-weight: 600; }
.header .user-info { color: var(--text-muted); font-size: 13px; }
.header .actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 20px; max-width: 1200px; width: 100%; }

/* ------------------------------------------------------------ widgets */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th, table.data td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------- badges */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.green { background: var(--info-bg); color: var(--accent); border-color: var(--accent); }
.badge.red { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.badge.amber { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.badge.stage { background: var(--info-bg); color: var(--accent); border-color: var(--accent); }

.overdue { color: var(--danger); font-weight: 600; }
.soon { color: var(--warn); font-weight: 600; }
.muted { color: var(--text-muted); }

/* -------------------------------------------------------------- forms */
form.stack { display: flex; flex-direction: column; gap: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}
.form-ok {
  background: var(--info-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ------------------------------------------------------------- buttons */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 6px;
}
button:hover, .btn:hover { filter: brightness(0.97); text-decoration: none; }
button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small { padding: 3px 9px; font-size: 12.5px; }
button.icon { padding: 5px 9px; background: transparent; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* --------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px;
  width: 560px;
  max-width: 96vw;
  max-height: 86vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------- stepper */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.stepper .step {
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 7px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11.5px;
}
.stepper .step.done { background: var(--info-bg); color: var(--accent); border-color: var(--accent); }
.stepper .step.current { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 700; }

/* -------------------------------------------------------- product cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card-grid .card { margin-bottom: 0; }
.card-grid .card h3 { margin: 0 0 6px; font-size: 15px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h1 { margin: 0; font-size: 20px; }

.empty { color: var(--text-muted); padding: 14px 4px; font-style: italic; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
}
.checklist li .title { flex: 1; }
.checklist li.done .title { text-decoration: line-through; color: var(--text-muted); }

.stage-tag { font-size: 11px; color: var(--text-muted); }
