/* ═══════════════════════════════════════════════════════════════
   MOOEE FOOD Admin — Design System
   Dark charcoal · Clean · Functional
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:             #111214;
  --surface:        #1a1c1f;
  --surface-raised: #222528;
  --surface-hover:  #2a2d31;
  --surface-active: #313539;

  /* Borders */
  --border:         #2e3035;
  --border-strong:  #3e4148;

  /* Text */
  --text-primary:   #f0f1f3;
  --text-secondary: #b0b4bc;
  --text-muted:     #6b7280;

  /* Accent — emerald */
  --accent:         #10b981;
  --accent-hover:   #0fd494;
  --accent-dim:     rgba(16,185,129,.12);

  /* Semantic */
  --success:        #34c97b;
  --success-dim:    rgba(52,201,123,.12);
  --danger:         #f05252;
  --danger-dim:     rgba(240,82,82,.12);
  --warning:        #f5a623;
  --warning-dim:    rgba(245,166,35,.12);

  /* Typography */
  --font-display: 'Inter', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w:    220px;
  --topbar-h:     56px;
  --radius:       10px;
  --radius-lg:    16px;
  --radius-sm:    6px;
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }

/* ─── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / 3;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .wordmark {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--text-primary);
}
.sidebar-logo .sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-link.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  grid-column: 2;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Main content ───────────────────────────────────────────── */
.main-content {
  grid-column: 2;
  padding: 28px 24px;
  overflow-y: auto;
}

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Cards / Surfaces ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .02em;
}

/* ─── Stats row ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

/* ─── Table ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); }
.td-mono { font-family: var(--font-mono); font-size: 13px; }
.td-actions { display: flex; gap: 6px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .12s, transform .08s, opacity .12s;
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #0d0e10; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon {
  padding: 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  display: inline-flex; align-items:center; justify-content:center;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  appearance: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(.98);
  transition: transform .2s;
  box-shadow: 0 32px 80px rgba(0,0,0,.5);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 20px; line-height: 1;
  transition: color .12s; padding: 2px;
}
.modal-close:hover { color: var(--text-primary); }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim);  color: var(--danger); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-neutral { background: var(--surface-raised); color: var(--text-muted); }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }

/* ─── Search / Filter bar ────────────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap input {
  padding-left: 36px;
}
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* ─── Ingredient rows in forms ───────────────────────────────── */
.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 120px 90px auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row .qty-input {
  text-align: right;
  font-family: var(--font-mono);
}
.add-ingredient-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--surface-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.add-ingredient-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Cost display ───────────────────────────────────────────── */
.cost-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.cost-na { color: var(--text-muted); font-size: 13px; font-style: italic; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity:0; } to { transform:translateX(0); opacity:1; } }

/* ─── Autocomplete dropdown ──────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
  margin-top: 4px;
}
.autocomplete-item {
  padding: 9px 13px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .1s;
}
.autocomplete-item:hover, .autocomplete-item.focused { background: var(--surface-hover); }
.autocomplete-item .unit-hint { font-size: 11px; color: var(--text-muted); }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Utilities ──────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mono { font-family: var(--font-mono); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4 { margin-top: 4px; }
.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; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Divider line in modal ──────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ─── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }