/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #fafaf8;
  --color-surface: #ffffff;
  --color-border: #e5e5e0;
  --color-text: #1a1a18;
  --color-text-muted: #6b6b60;
  --color-primary: #2d6a4f;
  --color-primary-hover: #1b4332;
  --color-danger: #c0392b;
  --color-danger-hover: #922b21;
  --color-success-bg: #d1fae5;
  --color-success-text: #065f46;
  --color-error-bg: #fee2e2;
  --color-error-text: #991b1b;
  --color-warning-bg: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); line-height: 1.6; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; }
small { font-size: .875em; color: var(--color-text-muted); }
code { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: .875em; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.5rem; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 100;
}
.site-logo { font-weight: 700; font-size: 1.125rem; color: var(--color-text); }
.site-nav { display: flex; gap: 1rem; align-items: center; }
.site-main { min-height: calc(100vh - 120px); padding: 2rem 1.5rem; max-width: 800px; margin: 0 auto; }
.site-footer { text-align: center; padding: 1.5rem; color: var(--color-text-muted); font-size: .875rem;
  border-top: 1px solid var(--color-border); margin-top: 3rem; }

/* ─── Hero ────────────────────────────────────────────────────────────────── */
.hero { display: flex; align-items: center; justify-content: center; min-height: 60vh; text-align: center; }
.hero-content { max-width: 520px; }
.hero h1 { font-size: 2.5rem; margin-bottom: .75rem; }
.hero-subtitle { font-size: 1.125rem; color: var(--color-text-muted); margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.25rem; border-radius: var(--radius); border: none; cursor: pointer;
  font-size: .9375rem; font-weight: 500; transition: background .15s, opacity .15s;
  line-height: 1.4; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-bg); text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); text-decoration: none; color: #fff; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1.0625rem; }
.btn-sm { padding: .3rem .75rem; font-size: .8125rem; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface); border-radius: var(--radius);
  border: 1px solid var(--color-border); padding: 2rem; box-shadow: var(--shadow);
}
.booking-card, .manage-card { max-width: 560px; margin: 0 auto; }
.booking-card h1, .manage-card h1 { text-align: center; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-full { grid-column: 1 / -1; }
label { font-size: .875rem; font-weight: 500; }
input, select, textarea {
  border: 1px solid var(--color-border); border-radius: 6px; padding: .5rem .75rem;
  font-size: .9375rem; font-family: inherit; background: var(--color-surface);
  color: var(--color-text); width: 100%; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}
textarea { resize: vertical; min-height: 80px; }
.required { color: var(--color-danger); }
.optional { color: var(--color-text-muted); font-weight: 400; }
.button-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.time-input { width: 120px; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .9375rem; }
.alert-error { background: var(--color-error-bg); color: var(--color-error-text); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.hidden { display: none !important; }

/* ─── Booking steps ───────────────────────────────────────────────────────── */
.booking-step h2 { margin-bottom: 1.25rem; }
.booking-step + .booking-step { margin-top: 0; }

/* ─── Slots ───────────────────────────────────────────────────────────────── */
.slots-container { margin-top: 1.5rem; }
.slots-heading { font-size: .875rem; font-weight: 600; margin-bottom: .75rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.slots-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.slot-btn {
  padding: .4rem .9rem; border-radius: 6px; border: 1px solid var(--color-border);
  background: var(--color-surface); cursor: pointer; font-size: .9375rem;
  transition: all .15s;
}
.slot-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.slot-btn.selected { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.slot-end { font-size: .8em; opacity: .65; }
.slot-pill { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1.25rem; }
.no-slots { color: var(--color-text-muted); font-style: italic; }
.loading { color: var(--color-text-muted); }

/* ─── Confirmation ────────────────────────────────────────────────────────── */
.confirmation-success { text-align: center; }
.confirmation-success .button-row { justify-content: center; }
.success-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--color-success-bg);
  color: var(--color-success-text); font-size: 1.75rem; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 1rem; font-weight: 700; }
.confirmation-details { text-align: left; margin: 1.5rem 0; }
.confirmation-note { background: var(--color-warning-bg); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1.5rem; font-size: .9rem; }

/* ─── Detail list ─────────────────────────────────────────────────────────── */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
.detail-list dt { font-weight: 600; font-size: .875rem; color: var(--color-text-muted); }
.detail-list dd { margin: 0; }
.code-display { font-family: ui-monospace, monospace; font-size: 1.1em; letter-spacing: .08em; font-weight: 700; }

/* ─── Status badges ───────────────────────────────────────────────────────── */
.status-badge { display: inline-flex; padding: .2rem .6rem; border-radius: 4px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.status-pending   { background: #fef3c7; color: #92400e; }
.status-confirmed { background: #dbeafe; color: #1e40af; }
.status-seated    { background: #d1fae5; color: #065f46; }
.status-completed { background: #e5e7eb; color: #374151; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-no_show          { background: #fce7f3; color: #9d174d; }
.status-pending_approval { background: #ede9fe; color: #5b21b6; }

/* ─── Admin layout ────────────────────────────────────────────────────────── */
.admin-body { background: var(--color-bg); }
.admin-layout { display: flex; min-height: 100vh; }
.admin-nav {
  width: 220px; flex-shrink: 0; background: var(--color-text); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.admin-nav-header { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-nav-header .site-logo { color: #fff; }
.admin-nav-header small { display: block; color: rgba(255,255,255,.5); font-size: .75rem; }
.admin-nav ul { list-style: none; padding: .5rem 0; flex: 1; overflow-y: auto; }
.admin-nav ul li a {
  display: block; padding: .6rem 1rem; color: rgba(255,255,255,.75); font-size: .9rem;
  border-left: 3px solid transparent; transition: all .15s;
}
.admin-nav ul li a:hover, .admin-nav ul li a.active {
  color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--color-primary); text-decoration: none;
}
.admin-nav-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.admin-user { display: block; font-size: .8rem; color: rgba(255,255,255,.6); margin-bottom: .5rem; }

/* Settings toggle button inside main nav */
.nav-settings-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: .6rem 1rem; background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.75); font-size: .9rem; border-left: 3px solid transparent;
  transition: all .15s; text-align: left;
}
.nav-settings-btn:hover, .nav-settings-btn.active {
  color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--color-primary);
}
.nav-chevron { transition: transform .2s ease; flex-shrink: 0; }
.nav-settings-btn[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }

/* Secondary settings nav */
.admin-nav-sub {
  width: 0; flex-shrink: 0; overflow: hidden;
  background: #2a2e3a; color: #fff;
  position: sticky; top: 0; height: 100vh;
  transition: width .22s ease;
  border-right: 1px solid rgba(255,255,255,.06);
}
.admin-nav-sub.open { width: 185px; }
.admin-nav-sub-inner { width: 185px; display: flex; flex-direction: column; padding-top: .75rem; }
.admin-nav-sub-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.35); padding: .5rem 1rem .25rem; margin: 0;
}
.admin-nav-sub ul { list-style: none; padding: .25rem 0; }
.admin-nav-sub ul li a {
  display: block; padding: .55rem 1rem; color: rgba(255,255,255,.7); font-size: .875rem;
  border-left: 3px solid transparent; transition: all .15s;
}
.admin-nav-sub ul li a:hover, .admin-nav-sub ul li a.active {
  color: #fff; background: rgba(255,255,255,.07); border-left-color: var(--color-primary); text-decoration: none;
}

.admin-main { flex: 1; padding: 2rem; overflow-x: auto; }

/* ─── Admin components ────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.admin-section { margin-top: 2.5rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--color-text-muted); margin-top: .25rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; padding: .6rem .75rem; font-size: .75rem; font-weight: 600;
  color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--color-border); white-space: nowrap; }
.data-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-bg); }
.row-inactive { opacity: .5; }

.empty-state { color: var(--color-text-muted); font-style: italic; padding: 2rem 0; }
.text-muted { color: var(--color-text-muted); }

.status-select { font-size: .8rem; padding: .25rem .5rem; border-radius: 4px; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-content { position: relative; z-index: 1; width: 100%; max-width: 480px; }

/* ─── Closed days list ────────────────────────────────────────────────────── */
.closed-days-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.closed-days-list li { display: flex; align-items: center; gap: .75rem; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

/* Narrow sidebar slightly at 1024px so content has more room */
@media (max-width: 1024px) {
  .admin-nav { width: 195px; }
  .admin-main { padding: 1.5rem; }
}

/* ── Tablet portrait (768px) — horizontal sticky top nav ─────────────────── */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }

  /* Nav becomes a sticky horizontal bar */
  .admin-nav {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 50;
    flex-direction: row; align-items: stretch; flex-wrap: nowrap;
  }
  .admin-nav-header {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .875rem; border-bottom: none;
    border-right: 1px solid rgba(255,255,255,.12); flex-shrink: 0;
  }
  .admin-nav-header img { height: 32px; }
  .admin-nav-header strong { display: none; }
  .admin-nav-header a[href="/platform"] { display: none; } /* hide impersonation link in top bar */

  /* Scrollable nav items */
  .admin-nav ul {
    flex: 1; display: flex; flex-wrap: nowrap; overflow-x: auto;
    padding: 0; align-items: stretch;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .admin-nav ul::-webkit-scrollbar { display: none; }
  .admin-nav ul li { flex-shrink: 0; display: flex; }
  .admin-nav ul li a {
    display: flex; align-items: center; padding: .6rem .9rem;
    border-left: none; border-bottom: 3px solid transparent;
    font-size: .875rem; white-space: nowrap; height: 100%;
  }
  .admin-nav ul li a:hover, .admin-nav ul li a.active {
    border-left-color: transparent; border-bottom-color: var(--color-primary);
    background: rgba(255,255,255,.08);
  }
  .nav-settings-btn {
    padding: .6rem .9rem; border-left: none; border-bottom: 3px solid transparent;
    font-size: .875rem; white-space: nowrap;
  }
  .nav-settings-btn:hover, .nav-settings-btn.active {
    border-left-color: transparent; border-bottom-color: var(--color-primary);
  }
  .nav-chevron { margin-left: .3rem; }

  /* Footer — compact inline */
  .admin-nav-footer {
    display: flex; align-items: center; gap: .5rem; padding: .5rem .875rem;
    border-top: none; border-left: 1px solid rgba(255,255,255,.12); flex-shrink: 0;
  }
  .admin-user { margin-bottom: 0; font-size: .75rem; white-space: nowrap; }
  .role-badge { display: none; }

  /* Sub-nav drops down below the bar */
  .admin-nav-sub {
    width: 100% !important; height: auto; position: sticky; top: 49px; z-index: 49;
    transition: max-height .2s ease; overflow: hidden; max-height: 0;
    border-right: none; border-top: 1px solid rgba(255,255,255,.08);
  }
  .admin-nav-sub.open { width: 100% !important; max-height: 60px; }
  .admin-nav-sub-inner { width: 100%; flex-direction: row; align-items: center; padding: 0; }
  .admin-nav-sub-label { display: none; }
  .admin-nav-sub ul {
    display: flex; flex-wrap: nowrap; overflow-x: auto; padding: .25rem .5rem;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .admin-nav-sub ul::-webkit-scrollbar { display: none; }
  .admin-nav-sub ul li { flex-shrink: 0; }
  .admin-nav-sub ul li a {
    padding: .5rem .9rem; border-left: none; border-bottom: 2px solid transparent; white-space: nowrap;
  }
  .admin-nav-sub ul li a:hover, .admin-nav-sub ul li a.active {
    border-left-color: transparent; border-bottom-color: var(--color-primary);
  }

  /* Main content */
  .admin-main { padding: 1rem; overflow-x: auto; }

  /* Make data tables scroll horizontally instead of breaking layout */
  .data-table { min-width: 520px; }

  /* Stat grid 2-col on tablet */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* Forms single column */
  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }
}

/* ── Phone (640px) — bottom tab bar ─────────────────────────────────────── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.75rem; }

  /* ── Convert nav to fixed bottom tab bar ── */
  .admin-nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: 56px; z-index: 100;
    flex-direction: row; align-items: stretch; flex-wrap: nowrap;
    border-top: 1px solid rgba(255,255,255,.15);
  }
  /* Hide logo and user footer — no room on phone */
  .admin-nav-header { display: none; }
  .admin-nav-footer { display: none; }

  /* Nav items fill the bar equally */
  .admin-nav ul {
    display: flex; flex-wrap: nowrap; width: 100%; padding: 0;
    align-items: stretch; overflow: visible;
  }
  .admin-nav ul li { flex: 1; display: flex; }
  .admin-nav ul li a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .25rem .1rem; border-left: none; border-bottom: none;
    border-top: 2px solid transparent; font-size: .65rem; line-height: 1.3;
    text-align: center; white-space: nowrap; width: 100%; height: 100%;
  }
  .admin-nav ul li a:hover, .admin-nav ul li a.active {
    border-left-color: transparent; border-bottom-color: transparent;
    border-top-color: var(--color-primary); background: rgba(255,255,255,.06);
  }
  .nav-settings-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .25rem .1rem; border-left: none; border-bottom: none;
    border-top: 2px solid transparent; font-size: .65rem; line-height: 1.3;
    text-align: center; white-space: nowrap;
  }
  .nav-settings-btn:hover, .nav-settings-btn.active {
    border-left-color: transparent; border-bottom-color: transparent;
    border-top-color: var(--color-primary);
  }
  .nav-chevron { display: none; }

  /* Sub-nav slides up from above the tab bar */
  .admin-nav-sub {
    position: fixed; bottom: 56px; left: 0; right: 0; top: auto;
    width: 100% !important; max-height: 0; overflow: hidden;
    transition: max-height .2s ease; z-index: 99;
    border-right: none; border-top: 1px solid rgba(255,255,255,.1);
  }
  .admin-nav-sub.open { width: 100% !important; max-height: 56px; }
  .admin-nav-sub-inner { width: 100%; flex-direction: row; align-items: center; padding: 0; }
  .admin-nav-sub-label { display: none; }
  .admin-nav-sub ul {
    display: flex; flex-wrap: nowrap; overflow-x: auto; padding: 0;
    scrollbar-width: none; -ms-overflow-style: none; width: 100%;
  }
  .admin-nav-sub ul::-webkit-scrollbar { display: none; }
  .admin-nav-sub ul li { flex: 1; min-width: max-content; }
  .admin-nav-sub ul li a {
    display: flex; align-items: center; justify-content: center;
    padding: .5rem .75rem; border-left: none; border-bottom: none;
    border-top: 2px solid transparent; font-size: .75rem; white-space: nowrap;
    height: 56px; text-align: center;
  }
  .admin-nav-sub ul li a:hover, .admin-nav-sub ul li a.active {
    border-left-color: transparent; border-bottom-color: transparent;
    border-top-color: var(--color-primary);
  }

  /* Push content up so it's not hidden behind the tab bar */
  .admin-layout { padding-bottom: 56px; }

  /* Bigger touch targets — minimum 44px */
  .btn { min-height: 44px; padding: .6rem 1.25rem; }
  .btn-sm { min-height: 40px; padding: .5rem .875rem; font-size: .875rem; }
  .data-table td, .data-table th { padding: .65rem .5rem; }

  /* Section header stacks */
  .section-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .section-header .btn { width: 100%; justify-content: center; }

  /* Full-screen modals — slide up from bottom, above the tab bar */
  .modal { padding: 0; align-items: flex-end; }
  .modal-content {
    max-width: 100%; border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92dvh; overflow-y: auto; margin-bottom: 56px;
  }

  /* 2-col stat grid on phone */
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Smaller admin main padding */
  .admin-main { padding: .875rem; }
}

/* Embed mode */
.embed-mode .booking-card h1,
.embed-mode .manage-card h1 { text-align: center; }
.embed-mode .button-row { justify-content: center; }
