/* ============================================================
   DepotIQ — Shared Stylesheet
   Matches Bonus Metres admin structure exactly
   ============================================================ */

:root {
  --red:          #cc0000;
  --red-light:    #fff0f0;
  --red-dim:      #a00000;
  --green:        #2a9d2a;
  --green-light:  #e8f5e9;
  --amber:        #f9a825;
  --amber-light:  #fff8e1;
  --blue:         #3a7bd5;
  --blue-light:   #f0f4ff;

  --bg:           #f0f2f5;
  --bg-white:     #ffffff;
  --bg-2:         #fafafa;

  --border:       #e8e8e8;
  --border-light: #f0f0f0;

  --text:         #1a1a1a;
  --text-dim:     #555555;
  --text-muted:   #aaaaaa;

  --sidebar:          220px;
  --sidebar-collapsed: 52px;
  --radius:       8px;
  --radius-lg:    10px;

  --font-ui:      Arial, sans-serif;

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

  --transition:   150ms ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 40px; left: 0;
  width: var(--sidebar);
  height: calc(100vh - 40px);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: width 0.2s ease;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Logo row */
.sidebar-logo {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  flex-shrink: 0;
}

.sidebar-logo img  { height: 28px; flex-shrink: 0; }
.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}
.sidebar-logo-text span { color: var(--red); }
.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

/* Toggle button */
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: #aaa;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s, background 0.15s, transform 0.2s ease;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--red); background: var(--red-light); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 8px 6px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.sidebar.collapsed .nav-section { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  margin-bottom: 2px;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover  { background: #f4f5f7; color: var(--text); }
.nav-item.active { background: var(--red-light); color: var(--red); font-weight: 700; }

.nav-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-label-text {
  flex: 1;
  overflow: hidden;
  transition: opacity 0.15s;
}
.sidebar.collapsed .nav-item .nav-label-text { opacity: 0; width: 0; }

/* Collapsed tooltips */
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1a1a1a;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 300;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Footer / user */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  overflow: hidden;
}

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

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.logout-btn {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); }
.sidebar.collapsed .logout-btn { display: none; }

/* ── Main content ────────────────────────────────────────── */
.main {
  padding: 24px 28px;
  min-height: calc(100vh - 44px);
}

.page-body {
  /* padding inherited from .main */
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  border-left: 4px solid #e0e0e0;
}

.stat-card.ok      { border-left-color: var(--green); }
.stat-card.low     { border-left-color: var(--red); }
.stat-card.ordered { border-left-color: var(--amber); }
.stat-card.neutral { border-left-color: var(--blue); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-value.ok      { color: var(--green); }
.stat-value.low     { color: var(--red); }
.stat-value.ordered { color: var(--amber); }
.stat-value.blue    { color: var(--blue); }

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

tbody tr:hover   { background: #f9f9f9; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 11px 12px; vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

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

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

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

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

.btn-sm { padding: 5px 10px; font-size: 11px; }

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

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

input, select, textarea {
  width: 100%;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: 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); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 36px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.empty-state-text { font-size: 13px; }

/* ── Loading ─────────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  color: var(--text-muted);
  gap: 8px;
  font-size: 12px;
}

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

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  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(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

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

.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 4px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar) !important; }
  .main { }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-blue   { color: var(--blue); }
.text-dim    { color: var(--text-dim); }
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-bold   { font-weight: 700; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }

.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 16px 0;
}


