/* ============================================================
   FMB Thali RSVP — Mobile-First Design System
   Faiz al-Mawaid al-Burhaniyah · Holland & Belgium
   Palette: deep teal, warm ivory, saffron gold, terracotta
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

/* ── Tokens ─────────────────────────────────────── */
:root {
  --teal:       #1B4D4A;
  --teal-mid:   #245E5A;
  --teal-light: #E6EFEE;
  --ivory:      #FAF6F0;
  --ivory-dim:  #F0E9DE;
  --charcoal:   #1E1A17;
  --gold:       #C9882A;
  --gold-pale:  #FBF0D8;
  --terra:      #A84230;
  --terra-pale: #FBEAE5;
  --sage:       #5C7A60;
  --sage-pale:  #EBF1EB;
  --line:       #DDD5C8;
  --white:      #FFFDF9;
  --text-muted: #6B5F52;

  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  18px;
  --shadow:     0 1px 3px rgba(30,26,23,.08), 0 4px 16px rgba(30,26,23,.06);
  --shadow-lg:  0 2px 0 var(--line), 0 8px 28px rgba(30,26,23,.10);

  --ff-display: 'Fraunces', Georgia, serif;
  --ff-body:    'Inter', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ff-body);
  background: var(--ivory);
  color: var(--charcoal);
  line-height: 1.55;
  min-height: 100dvh;
}

/* ── Layout shell ───────────────────────────────── */
.app-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
  min-height: 100dvh;
}

.org-logo {
  width: 75px;
  max-width: 100px;
  height: auto;
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.94);
  padding: 0.35rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

body.admin-page .org-logo {
  position: fixed;
  top: 1rem;
  left: 220px;
  z-index: 20;
}

.logo-header .org-logo {
  position: static;
  box-shadow: none;
  background: transparent;
  padding: 0;
}

/* ── Header ─────────────────────────────────────── */
.app-header {
  text-align: center;
  padding: 2rem 0 1.25rem;
}
.logo-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.logo-header .header-copy {
  text-align: left;
}
.logo-header .org-logo {
  width: 100px;
  min-width: 75px;
}
.app-header .eyebrow {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal-mid);
  font-weight: 700;
  margin-bottom: .3rem;
}
.app-header h1 {
  font-family: var(--ff-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--teal);
  line-height: 1.15;
}
.app-header .sub {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ── Card ───────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}
.card-body { padding: 1.25rem 1.1rem; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: .85rem;
  margin-bottom: .85rem;
  border-bottom: 1.5px dashed var(--line);
}
.card-head h2 {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--charcoal);
}

/* ── Thali number badge ─────────────────────────── */
.thali-pill {
  background: var(--teal);
  color: var(--white);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  padding: .28rem .7rem;
  border-radius: 20px;
  white-space: nowrap;
}
.date-pill {
  background: var(--gold-pale);
  color: var(--gold);
  font-size: .75rem;
  font-weight: 700;
  padding: .28rem .75rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Menu rows (ticket style) ───────────────────── */
.menu-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--ivory-dim);
}
.menu-row:last-child { border-bottom: none; }
.menu-row .dish-tag {
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  width: 58px;
  flex-shrink: 0;
}
.menu-row .dish-name { font-weight: 500; flex: 1; }

/* ── Skip toggles ───────────────────────────────── */
.skip-section {
  background: var(--teal-light);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  margin-top: .85rem;
}
.skip-section h3 {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--teal-mid);
  margin-bottom: .65rem;
}
.skip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  font-size: .9rem;
  border-bottom: 1px solid rgba(27,77,74,.12);
}
.skip-row:last-child { border-bottom: none; }
.skip-row .skip-label { flex: 1; }

/* iOS-style toggle switch */
.toggle-wrap { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 13px;
  cursor: pointer;
  transition: background .2s ease;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  top: 3px; left: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: transform .2s ease;
}
.toggle-wrap input:checked + .toggle-track { background: var(--terra); }
.toggle-wrap input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Family bar ─────────────────────────────────── */
.family-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 0 .9rem;
  font-size: .83rem;
  color: var(--text-muted);
}
.family-bar strong { color: var(--charcoal); }
.link-btn {
  background: none; border: none;
  color: var(--teal-mid); font-weight: 600;
  font-size: .83rem; cursor: pointer;
  font-family: var(--ff-body); padding: 0;
}

/* ── Tab row ────────────────────────────────────── */
.tab-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tab-btn {
  flex: 1;
  padding: .65rem .5rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--white);
  font-family: var(--ff-body);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
  text-align: center;
}
.tab-btn.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .8rem 1.4rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--ff-body);
  font-size: .93rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--teal);  color: var(--white); }
.btn-primary:not(:disabled):hover  { background: var(--teal-mid); }
.btn-gold     { background: var(--gold);  color: var(--white); }
.btn-danger   { background: var(--terra); color: var(--white); }
.btn-ghost    { background: var(--ivory-dim); color: var(--charcoal); border: 1.5px solid var(--line); }
.btn-block    { width: 100%; }
.btn-sm       { padding: .5rem 1rem; font-size: .82rem; }

/* ── Form elements ──────────────────────────────── */
.field { margin-bottom: .85rem; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--teal-mid);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}
input[type="text"], input[type="password"],
input[type="date"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: .75rem .9rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1rem;               /* 16px prevents iOS zoom */
  font-family: var(--ff-body);
  background: var(--white);
  color: var(--charcoal);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27,77,74,.14);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Banners ────────────────────────────────────── */
.banner {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .86rem;
  line-height: 1.5;
  margin-bottom: .9rem;
}
.banner-warn    { background: var(--gold-pale);  border: 1.5px solid var(--gold);  color: #7A5210; }
.banner-error   { background: var(--terra-pale); border: 1.5px solid var(--terra); color: var(--terra); }
.banner-success { background: var(--sage-pale);  border: 1.5px solid var(--sage);  color: var(--sage); }
.banner-info    { background: var(--teal-light); border: 1.5px solid #7AB0AC;      color: var(--teal-mid); }

/* ── Stars ──────────────────────────────────────── */
.star-row { display: flex; gap: .4rem; font-size: 2rem; margin: .5rem 0 1rem; }
.star { cursor: pointer; color: var(--line); transition: color .12s ease, transform .1s ease; }
.star.on { color: var(--gold); }
.star:hover { transform: scale(1.12); }

/* ── Spinner ────────────────────────────────────── */
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ── Login screen ───────────────────────────────── */
.login-screen {
  min-height: 90dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-screen .card { width: 100%; }
.login-code-input {
  font-size: 1.3rem !important;
  font-weight: 700;
  text-align: center;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ── Footer ─────────────────────────────────────── */
.app-footer {
  text-align: center;
  font-size: .75rem;
  color: #b0a090;
  padding: 1.5rem 0 0;
}

/* ══════════════════════════════════════════════════
   ADMIN PANEL
   Full-page on desktop, scrollable on mobile
   ══════════════════════════════════════════════════ */

/* Admin shell — stacks vertically on mobile */
.admin-shell { display: flex; min-height: 100dvh; }

.admin-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--teal);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.3rem 1rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand .eyebrow {
  font-size: .65rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
  font-weight: 700;
}
.sidebar-brand .brand-name {
  font-family: var(--ff-display);
  font-size: 1rem;
  color: var(--white);
  margin-top: 2px;
  line-height: 1.2;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: .6rem .5rem; flex: 1; }
.nav-btn {
  width: 100%;
  text-align: left;
  padding: .6rem .8rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  font-family: var(--ff-body);
  font-weight: 500;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.nav-btn:hover { background: rgba(255,255,255,.1); color: var(--white); }
.nav-btn.active { background: var(--gold); color: var(--white); }
.sidebar-footer { padding: .8rem .7rem 1.2rem; }

.admin-main {
  flex: 1;
  min-width: 0;
  background: var(--ivory);
  overflow-y: auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* Section header */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: .6rem;
}
.sec-head h2 {
  font-family: var(--ff-display);
  font-size: 1.35rem;
  color: var(--charcoal);
}
.sec-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1.1rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  text-align: center;
}
.stat-val {
  font-family: var(--ff-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--teal);
  line-height: 1;
}
.stat-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-top: .3rem;
}
.stat-card.gold  .stat-val { color: var(--gold); }
.stat-card.terra .stat-val { color: var(--terra); }
.stat-card.sage  .stat-val { color: var(--sage); }

/* Box count breakdown bar */
.breakdown-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem 0;
  font-size: .88rem;
  border-bottom: 1px solid var(--ivory-dim);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-dish { flex: 1; font-weight: 500; }
.breakdown-count { font-weight: 700; color: var(--teal); min-width: 28px; text-align: right; }
.breakdown-skips { font-size: .75rem; color: var(--text-muted); min-width: 56px; text-align: right; }
.bar-wrap { width: 70px; background: var(--ivory-dim); border-radius: 4px; height: 6px; overflow: hidden; }
.bar-fill { height: 6px; border-radius: 4px; background: var(--terra); transition: width .4s ease; }

/* Admin table */
.tbl-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 1rem;
}
table.atbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.atbl thead th {
  padding: .6rem .9rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  background: var(--ivory-dim);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}
table.atbl tbody td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.atbl tbody tr:last-child td { border-bottom: none; }
table.atbl tbody tr:hover td { background: var(--ivory); }

/* Badge */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
}
.badge-green  { background: var(--sage-pale); color: var(--sage); }
.badge-terra  { background: var(--terra-pale); color: var(--terra); }
.badge-gold   { background: var(--gold-pale); color: var(--gold); }
.badge-teal   { background: var(--teal-light); color: var(--teal-mid); }
.badge-gray   { background: var(--ivory-dim); color: var(--text-muted); }

/* Icon/action button */
.icon-btn {
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: .3rem .6rem;
  font-size: .78rem;
  cursor: pointer;
  color: var(--charcoal);
  font-family: var(--ff-body);
  font-weight: 500;
  transition: background .12s ease;
}
.icon-btn:hover { background: var(--ivory-dim); }

/* ── Modals ──────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(30,26,23,.5);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-bg.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 8px 40px rgba(30,26,23,.22);
}
.modal-box h3 {
  font-family: var(--ff-display);
  font-size: 1.15rem;
  margin-bottom: 1.1rem;
  color: var(--charcoal);
}
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.1rem; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* CSV drop zone */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  transition: border-color .15s ease, background .15s ease;
}
.drop-zone.drag-over { border-color: var(--teal); background: var(--teal-light); }

/* Feedback card */
.fb-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem;
  margin-bottom: .75rem;
}
.fb-card .fb-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .3rem;
}
.fb-card .fb-who { font-weight: 600; font-size: .9rem; }
.fb-card .fb-date { font-size: .75rem; color: var(--text-muted); }
.fb-card .fb-stars { color: var(--gold); letter-spacing: 1px; font-size: 1rem; }
.fb-card .fb-comment { font-size: .85rem; color: var(--text-muted); margin-top: .3rem; font-style: italic; }

/* ── Mobile overrides ────────────────────────────── */
@media (max-width: 640px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap;
  }
  .sidebar-brand { padding: .7rem .9rem; border: none; }
  .sidebar-nav {
    flex-direction: row; flex-wrap: wrap;
    gap: 3px; padding: .4rem .5rem; flex: unset;
  }
  .nav-btn { padding: .4rem .65rem; font-size: .78rem; }
  .sidebar-footer { padding: .5rem .7rem; }
  .admin-main { padding: 1rem .9rem 4rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .field-2col { grid-template-columns: 1fr; }
}

/* ── Audit log ───────────────────────────────────────────────── */
.audit-row {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
}
.audit-row:last-child { border-bottom: none; }
.audit-time {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 110px;
  padding-top: 2px;
}
.audit-who {
  font-weight: 700;
  color: var(--teal-mid);
  white-space: nowrap;
  min-width: 90px;
}
.audit-summary { flex: 1; color: var(--charcoal); line-height: 1.45; }
.audit-action-pill {
  font-size: .68rem;
  font-weight: 700;
  padding: .18rem .55rem;
  border-radius: 20px;
  background: var(--teal-light);
  color: var(--teal-mid);
  white-space: nowrap;
  align-self: center;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.audit-action-pill.login    { background: var(--sage-pale);  color: var(--sage); }
.audit-action-pill.create   { background: #e8f4e8;           color: #2d6a2d; }
.audit-action-pill.update   { background: var(--gold-pale);  color: #7A5210; }
.audit-action-pill.delete   { background: var(--terra-pale); color: var(--terra); }
.audit-action-pill.import   { background: var(--teal-light); color: var(--teal-mid); }
.audit-action-pill.admin    { background: #f0ebff;           color: #5b3fa6; }

/* ── Danger button ───────────────────────────────────────────── */
.btn-danger { background: var(--terra); color: var(--white); }
.btn-danger:not(:disabled):hover { background: #8a3222; }

/* ── Per-item feedback ───────────────────────────────────────── */
.fb-section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--teal-mid);
  margin-bottom: .4rem;
}
.fb-items-block {
  background: var(--ivory-dim);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
}
.fb-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem 0;
  border-bottom: 1px solid var(--line);
  gap: .5rem;
}
.fb-item-row:last-child { border-bottom: none; }
.fb-item-name {
  font-size: .88rem;
  font-weight: 500;
  flex: 1;
  color: var(--charcoal);
}
/* Smaller interactive stars for per-item rows */
.star-row-sm {
  display: flex;
  gap: .15rem;
  font-size: 1.35rem;
  flex-shrink: 0;
}
/* Static (read-only) star display */
.fb-static-stars {
  font-size: 1rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}
/* History card muted border */
.fb-history-card { opacity: .92; }
.fb-history-comment {
  font-size: .83rem;
  color: var(--text-muted);
  font-style: italic;
  margin: .7rem 0 0;
  padding-top: .6rem;
  border-top: 1px dashed var(--line);
}
