@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   JHB Staff Portal — Shared Stylesheet
   Mobile-first, matches DepotIQ/Bonus Metres branding
   ============================================================ */

:root {
  /* ── Brand — matches platform shell.js exactly ── */
  --red:          #cc0000;
  --red-light:    #fff5f5;
  --red-dim:      #aa0000;
  --green:        #16a34a;
  --green-light:  #f0fdf4;
  --amber:        #d97706;
  --amber-light:  #fffbeb;
  --blue:         #2563eb;
  --blue-light:   #eff6ff;

  --bg:           #f7f8fa;
  --bg-white:     #ffffff;
  --bg-2:         #f3f4f6;

  --border:       #e5e7eb;
  --border-light: #f0f0f0;

  --text:         #111827;
  --text-dim:     #4b5563;
  --text-muted:   #9ca3af;

  /* Mobile keeps larger radius for touch-friendly feel */
  --radius:       12px;
  --radius-lg:    16px;
  --radius-sm:    8px;

  /* Inter font — matches platform */
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 8px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  --transition:   150ms ease;

  /* Safe areas for notched phones */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-ui);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--safe-bottom);
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dim); }

/* ── Page wrapper ────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo { height: 28px; }

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.header-title span { color: var(--red); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Content ─────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 20px 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

/* ── Module grid ─────────────────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.module-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: all var(--transition);
  border: 2px solid transparent;
  position: relative;
  cursor: pointer;
}

.module-card:hover, .module-card:active {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.module-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.module-card.disabled:hover {
  border-color: transparent;
  box-shadow: var(--shadow-sm);
  transform: none;
}

.module-icon {
  font-size: 36px;
  line-height: 1;
}

.module-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

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

.coming-soon {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 2px 6px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dim); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #1f7a1f; }

.btn-sm {
  padding: 10px 16px;
  font-size: 13px;
  width: auto;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px; /* Prevents iOS zoom */
  padding: 12px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(204,0,0,0.08);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.badge-ok      { background: var(--green-light); color: var(--green); }
.badge-low     { background: var(--red-light);   color: var(--red); }
.badge-warning { background: var(--amber-light); color: #b07800; }
.badge-neutral { background: #f0f0f0;            color: var(--text-dim); }

/* ── List items ──────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }

.list-item-name  { font-weight: 600; font-size: 15px; color: var(--text); }
.list-item-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Number input with big tap targets ───────────────────── */
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-white);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: all var(--transition);
}
.qty-btn:active { background: var(--bg); transform: scale(0.95); }
.qty-btn.plus   { border-color: var(--red); color: var(--red); }
.qty-btn.minus  { border-color: var(--border); }

.qty-display {
  font-size: 18px;
  font-weight: 700;
  min-width: 50px;
  text-align: center;
  color: var(--text);
}

/* ── Loading ─────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.empty-text { font-size: 14px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--amber); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sticky bottom button ────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  z-index: 100;
}

.has-bottom-bar .page-content {
  padding-bottom: 90px;
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
  margin-top: 20px;
}
.section-header:first-child { margin-top: 0; }

/* ── Back button ─────────────────────────────────────────── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* ── PWA install prompt ──────────────────────────────────── */
.install-banner {
  background: var(--blue-light);
  border: 1px solid #c0d8ff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

