/* ================================================================
   MenuFlow — Design System
   Editorial / Brutally Minimal / High-Contrast
   ================================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  /* Colors */
  --ink:         #0a0a0a;
  --ink-2:       #333333;
  --ink-3:       #666666;
  --ink-4:       #999999;
  --line:        #e5e5e5;
  --line-2:      #f0f0f0;
  --surface:     #ffffff;
  --surface-2:   #fafafa;
  --surface-3:   #f4f4f4;
  --accent:      #e63946;
  --accent-dark: #c1121f;
  --accent-bg:   #fff0f1;
  --ok:          #1a7a4a;
  --ok-bg:       #edf7f2;
  --warn:        #c47c00;
  --warn-bg:     #fff8ec;

  /* Type */
  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-mono:  'DM Mono', 'Fira Code', monospace;
  --font-serif: 'DM Serif Display', Georgia, serif;

  /* Scale */
  --text-xs:   0.6875rem;   /* 11px */
  --text-sm:   0.8125rem;   /* 13px */
  --text-base: 0.9375rem;   /* 15px */
  --text-md:   1.0625rem;   /* 17px */
  --text-lg:   1.25rem;     /* 20px */
  --text-xl:   1.5rem;      /* 24px */
  --text-2xl:  2rem;        /* 32px */
  --text-3xl:  2.75rem;     /* 44px */

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;
  --space-10: 80px;

  /* Radius */
  --r-sm:  4px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.10);
  --shadow-xl:  0 24px 64px rgba(0,0,0,.12);

  /* Transitions */
  --t-fast:   120ms ease;
  --t-mid:    220ms ease;
  --t-slow:   380ms ease;

  /* Layout */
  --sidebar-w:  240px;
  --topbar-h:   56px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; transition: opacity var(--t-fast); }
a:hover { opacity: .8; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Typography ─────────────────────────────────────────────── */
.t-serif   { font-family: var(--font-serif); }
.t-mono    { font-family: var(--font-mono); }
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.25; letter-spacing: -.02em; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--ink);
  color: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: var(--r-md);
  border: 2px solid var(--ink);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn-primary:hover  { background: var(--ink-2); border-color: var(--ink-2); color: var(--surface); opacity: 1; }
.btn-primary:active { transform: scale(.98); }

.btn-accent {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: var(--r-md);
  border: 2px solid var(--accent);
  transition: background var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn-accent:hover  { background: var(--accent-dark); border-color: var(--accent-dark); opacity: 1; color: #fff; }
.btn-accent:active { transform: scale(.98); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  transition: border-color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--ink-3); background: var(--surface-3); opacity: 1; color: var(--ink); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: transparent;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1.5px solid var(--accent);
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-danger:hover { background: var(--accent); color: #fff; opacity: 1; }

.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn-full { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 15px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.btn-icon:hover { border-color: var(--ink-3); background: var(--surface-3); opacity: 1; color: var(--ink); }

/* ── Form fields ─────────────────────────────────────────────── */
.field-group    { display: flex; flex-direction: column; gap: var(--space-2); }
.field-row      { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field-label    { font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); }
.field-label-link { float: right; font-weight: 400; color: var(--ink-4); font-size: var(--text-xs); }
.field-hint     { font-size: var(--text-xs); color: var(--ink-4); margin-top: 2px; }

.field-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
}
.field-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10,10,10,.08);
}
.field-input::placeholder { color: var(--ink-4); }
.field-input.is-error { border-color: var(--accent); }

textarea.field-input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

select.field-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23666' d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; padding-right: 36px; }

.field-password-wrap { position: relative; }
.field-password-wrap .field-input { padding-right: 56px; }
.pwd-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: var(--text-xs); color: var(--ink-4); font-weight: 500;
  transition: color var(--t-fast);
}
.pwd-toggle:hover { color: var(--ink); }

/* Toggle switch */
.toggle-wrap    { display: flex; align-items: center; gap: var(--space-3); }
.toggle-label   { font-size: var(--text-sm); color: var(--ink-2); font-weight: 500; }
.toggle {
  position: relative; width: 40px; height: 22px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0; border-radius: var(--r-full);
  background: var(--line); transition: background var(--t-mid); cursor: pointer;
}
.toggle-track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; transition: transform var(--t-mid);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-track { background: var(--ink); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* Checkbox */
.check-label {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); color: var(--ink-2); cursor: pointer;
}
.check-box {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.check-label input[type=checkbox] { display: none; }
.check-label input:checked + .check-box {
  background: var(--ink); border-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='1.5' d='M1.5 5l2.5 2.5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 10px;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.badge-live    { background: var(--ok-bg); color: var(--ok); }
.badge-draft   { background: var(--surface-3); color: var(--ink-3); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-new     { background: var(--accent); color: white; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-body  { padding: var(--space-6); }
.card-title { font-size: var(--text-md); font-weight: 600; margin-bottom: var(--space-4); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left; font-weight: 600;
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .col-check { width: 40px; }
.data-table .col-actions { width: 100px; text-align: right; white-space: nowrap; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-10) var(--space-6); text-align: center;
  color: var(--ink-4);
}
.empty-state-icon { font-size: 40px; margin-bottom: var(--space-4); opacity: .4; }
.empty-state-text { font-size: var(--text-sm); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  margin-bottom: var(--space-5);
}
.alert p { margin-bottom: 4px; }
.alert p:last-child { margin-bottom: 0; }
.alert-err  { background: var(--accent-bg); color: var(--accent-dark); border-left: 3px solid var(--accent); }
.alert-ok   { background: var(--ok-bg); color: var(--ok); border-left: 3px solid var(--ok); }
.alert-info { background: #f0f7ff; color: #1a5fa8; border-left: 3px solid #3b82f6; }

/* ── Flash bar ───────────────────────────────────────────────── */
.flash {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: 500;
  animation: flashIn .3s ease;
}
.flash-ok  { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--accent-bg); color: var(--accent); }

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: var(--space-2);
  justify-content: flex-end; padding: var(--space-4) 0;
}
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 var(--space-2);
  border-radius: var(--r-md); border: 1.5px solid var(--line);
  font-size: var(--text-sm); color: var(--ink-2);
  transition: background var(--t-fast), border-color var(--t-fast);
  cursor: pointer; background: var(--surface);
}
.page-btn:hover   { border-color: var(--ink-3); background: var(--surface-3); }
.page-btn.active  { background: var(--ink); border-color: var(--ink); color: white; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: var(--space-4);
  animation: fadeIn var(--t-fast);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp var(--t-mid);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--line);
}
.modal-title { font-size: var(--text-md); font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 18px;
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--line);
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex; border-bottom: 1.5px solid var(--line);
  gap: 0; margin-bottom: var(--space-6);
}
.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.tab-btn:hover  { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-7); flex-wrap: wrap; gap: var(--space-4);
}
.page-title    { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.03em; }
.page-subtitle { font-size: var(--text-sm); color: var(--ink-3); margin-top: 4px; }
.page-actions  { display: flex; align-items: center; gap: var(--space-3); }

/* ── Drag handle ─────────────────────────────────────────────── */
.drag-handle {
  display: inline-flex; flex-direction: column; gap: 3px;
  cursor: grab; color: var(--ink-4); padding: 4px;
}
.drag-handle span {
  display: flex; gap: 3px;
}
.drag-handle span::before, .drag-handle span::after {
  content: ''; width: 3px; height: 3px; border-radius: 50%; background: currentColor;
}
.drag-handle:active { cursor: grabbing; }

/* ── Skeleton loader ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--line-2) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Misc utilities ──────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-muted   { color: var(--ink-4); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.fw-600       { font-weight: 600; }
.gap-2        { gap: var(--space-2); }
.gap-3        { gap: var(--space-3); }
.gap-4        { gap: var(--space-4); }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.mt-4         { margin-top: var(--space-4); }
.mt-6         { margin-top: var(--space-6); }
.mb-4         { margin-bottom: var(--space-4); }
.mb-6         { margin-bottom: var(--space-6); }
.w-full       { width: 100%; }
