/* ==========================================================
   DC Inventory — styles
   Signature element: status LEDs whose color comes from the
   configurable stock_statuses.color_hex value (set via inline
   style), so admins can add new statuses with their own color
   without touching CSS.
   ========================================================== */

:root {
  --graphite-900: #14171d;
  --graphite-800: #1b1f27;
  --graphite-700: #262b35;
  --fog-100: #f4f6f8;
  --fog-200: #e8ebef;
  --fog-300: #d7dce2;
  --ink-900: #1a1d23;
  --ink-600: #565e6b;
  --teal-500: #2dd4bf;
  --teal-600: #14b8a6;
  --flag-low: #64748b;
  --flag-medium: #f59e0b;
  --flag-high: #ef4444;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--fog-100);
  color: var(--ink-900);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

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

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--graphite-800);
  color: #e6e9ee;
  display: flex; flex-direction: column;
  padding: 20px 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 20px; border-bottom: 1px solid var(--graphite-700); margin-bottom: 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
  color: var(--graphite-900); font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.nav a { color: #b7bec9; padding: 10px 12px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--graphite-700); color: #fff; text-decoration: none; }
.nav a.active { background: var(--graphite-700); color: var(--teal-500); }

.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid var(--graphite-700); margin-top: 16px; }
.user-chip { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  width: fit-content; padding: 2px 6px; border-radius: 4px; background: var(--graphite-700); color: #9aa3af;
}
.user-role.role-superadmin { color: var(--teal-500); }
.user-role.role-admin { color: var(--flag-medium); }
.logout-link { font-size: 13px; color: #9aa3af; }

.main-content { flex: 1; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--fog-300); padding: 18px 32px; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.content-body { padding: 28px 32px; max-width: 1280px; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #1f2530, var(--graphite-900)); }
.auth-card { background: #fff; width: 100%; max-width: 380px; border-radius: 12px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.auth-card .brand-mark { margin: 0 auto 14px; }
.auth-card h1 { font-size: 18px; text-align: center; margin: 0 0 4px; }
.auth-card p.sub { text-align: center; color: var(--ink-600); font-size: 13px; margin: 0 0 22px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--fog-300); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink-900);
}
.form-control:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(45,212,191,0.25); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 190px; }
.form-hint { font-size: 12px; color: var(--ink-600); margin-top: 4px; }
input[type="color"].form-control { padding: 3px; height: 40px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--graphite-800); color: #fff; }
.btn-primary:hover { background: var(--graphite-900); text-decoration: none; }
.btn-accent { background: var(--teal-600); color: #fff; }
.btn-accent:hover { background: var(--teal-500); text-decoration: none; }
.btn-outline { background: #fff; border-color: var(--fog-300); color: var(--ink-900); }
.btn-outline:hover { border-color: var(--ink-600); text-decoration: none; }
.btn-danger { background: #fff; border-color: var(--flag-high); color: var(--flag-high); }
.btn-danger:hover { background: var(--flag-high); color: #fff; text-decoration: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Cards / Tables ---------- */
.card { background: #fff; border: 1px solid var(--fog-300); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-header h2 { font-size: 16px; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--fog-200); white-space: nowrap; }
th { color: var(--ink-600); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
th a { color: inherit; }
tbody tr:hover { background: var(--fog-100); }

/* ---------- Status LED (color comes from DB via inline style) ---------- */
.led {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 9px 3px 7px; border-radius: 100px; background: var(--fog-100);
}
.led::before { content: ""; width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--dot-color, #94a3b8); box-shadow: 0 0 6px var(--dot-color, #94a3b8); }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-tile { background: #fff; border: 1px solid var(--fog-300); border-radius: 10px; padding: 18px; }
.stat-tile .stat-label { font-size: 12px; color: var(--ink-600); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-tile .stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; margin-top: 6px; }

/* ---------- Badges (roles) ---------- */
.badge { font-family: var(--font-mono); font-size: 11px; padding: 3px 8px; border-radius: 100px; background: var(--fog-200); color: var(--ink-600); text-transform: uppercase; }
.badge-superadmin { background: rgba(45,212,191,0.15); color: var(--teal-600); }
.badge-admin { background: rgba(245,158,11,0.15); color: #b45309; }
.badge-user { background: var(--fog-200); color: var(--ink-600); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: rgba(34,197,94,0.12); color: #15803d; }
.alert-error { background: rgba(239,68,68,0.12); color: #b91c1c; }
.alert-info { background: rgba(45,212,191,0.12); color: #0f766e; }
.alert-warning { background: rgba(245,158,11,0.12); color: #b45309; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filters .form-group { margin-bottom: 0; }
.filters .form-control { max-width: 190px; }

.text-muted { color: var(--ink-600); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-600); }
.actions-cell { display: flex; gap: 6px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; font-size: 13px; border: 1px solid var(--fog-300); }
.pagination .current { background: var(--graphite-800); color: #fff; border-color: var(--graphite-800); }
.pagination a:hover { border-color: var(--ink-600); text-decoration: none; }

/* ---------- Color swatch (stock status list) ---------- */
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: middle; border: 1px solid var(--fog-300); }

/* ---------- Diff view (audit log) ---------- */
.diff-table td { white-space: normal; font-size: 12.5px; }
.diff-old { color: #b91c1c; text-decoration: line-through; }
.diff-new { color: #15803d; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .brand { border: none; margin: 0 12px 0 0; padding: 0; }
  .nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .content-body { padding: 20px; }
}
