/* TasteByMaa Admin Portal — design system.
   Tokens mirror the approved dashboard mockup: indigo accent by default,
   switchable font pairing, full dark mode. See assets/js/theme.js for the
   switcher logic (persists choice, applies data-theme + data-font on <html>). */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --accent: #5B5BD6;
  --accent-soft: rgba(91, 91, 214, 0.12);
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-alt: #F1F2F5;
  --border: #E4E6EB;
  --text: #12141A;
  --text-muted: #6B7280;
  --card-shadow: 0 1px 2px rgba(16,17,20,0.04), 0 6px 16px rgba(16,17,20,0.05);

  --sidebar-bg: #101114;
  --sidebar-text: #F2F3F6;
  --sidebar-muted: #8B8D98;
  --sidebar-card: #1B1C22;

  --green: #0E9F6E;
  --green-soft: rgba(14, 159, 110, 0.12);
  --red: #DC2626;
  --red-soft: rgba(220, 38, 38, 0.12);
  --amber: #B8862E;
  --amber-soft: rgba(184, 134, 46, 0.14);
  --blue: #2F86EB;
  --blue-soft: rgba(47, 134, 235, 0.12);

  --radius-sm: 7px;
  --radius: 9px;
  --radius-lg: 14px;
  --sidebar-w: 232px;
}

html[data-theme="dark"] {
  --bg: #0A0B0E;
  --surface: #16171D;
  --surface-alt: #1E2028;
  --border: #2A2C36;
  --text: #F2F3F6;
  --text-muted: #9195A3;
  --card-shadow: none;
  --green: #34D399;
  --green-soft: rgba(52, 211, 153, 0.2);
  --red: #F87171;
  --red-soft: rgba(248, 113, 113, 0.2);
  --amber: #F5B94F;
  --amber-soft: rgba(245, 185, 79, 0.2);
  --accent-soft: rgba(91, 91, 214, 0.22);
}

html[data-font="warm-editorial"] { --font-heading: 'Fraunces', serif; --font-body: 'Manrope', sans-serif; }
html[data-font="classic-elegant"] { --font-heading: 'Playfair Display', serif; --font-body: 'Work Sans', sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-body);
  -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-heading); margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: var(--font-body); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; min-height: 100vh; background: var(--sidebar-bg);
  padding: 24px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: var(--radius); background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-family: var(--font-heading);
  font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0;
}
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand-text strong { font-family: var(--font-heading); font-weight: 700; font-size: 16px; color: var(--sidebar-text); }
.sidebar-brand-text span { font-size: 11px; color: var(--sidebar-muted); letter-spacing: .03em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex-grow: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--sidebar-muted); font-size: 13.5px; font-weight: 500;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-nav a:hover:not(.active) { background: rgba(255,255,255,0.05); color: var(--sidebar-text); }
.sidebar-nav a .count {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px;
}

.sidebar-account {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--sidebar-card);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12.5px;
  font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-account-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-account-text strong { font-size: 12.5px; font-weight: 600; color: var(--sidebar-text); }
.sidebar-account-text span { font-size: 10.5px; color: var(--sidebar-muted); }
.icon-btn {
  background: none; border: none; color: var(--sidebar-muted); cursor: pointer; padding: 4px;
  display: flex; align-items: center; justify-content: center;
}

.main { flex-grow: 1; min-width: 0; padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 24px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; width: 230px; margin-left: auto;
}
.topbar-search input { border: none; outline: none; background: none; color: var(--text); width: 100%; }
.topbar-search svg { color: var(--text-muted); flex-shrink: 0; width: 15px; height: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; cursor: pointer;
  border-radius: var(--radius); padding: 9px 16px; font-weight: 700; font-size: 13px; font-family: var(--font-body);
  transition: opacity .12s ease;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); }
.card-pad { padding: 20px 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 14px; }
.card-header a, .card-header .link { font-size: 11.5px; font-weight: 600; color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--card-shadow); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.stat-icon.danger { background: var(--red-soft); color: var(--red); }
.stat-value { font-family: var(--font-heading); font-size: 25px; font-weight: 600; }
.stat-delta { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--text-muted); }
.cell-strong { font-weight: 700; }
.row-link { cursor: pointer; }

/* ---------- Badges / status pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.input, select.input, textarea.input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px;
  color: var(--text); font-size: 13px; width: 100%; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

/* ---------- Layout helpers ---------- */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-grow { flex-grow: 1; }
.mt-auto { margin-top: auto; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 4px; margin-right: 20px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 4px; font-size: 12.5px; color: var(--text-muted); }
.pagination .btns { display: flex; gap: 6px; }

/* ---------- Empty / loading states ---------- */
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: 6px; }
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,11,14,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; box-shadow: var(--card-shadow); min-width: 220px; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

/* ---------- Login page ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 22px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .18s ease; height: 100vh; }
  .sidebar.open { left: 0; }
  .main { padding: 16px; }
  .form-grid, .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}
