/* ==========================================================================
   999 Pizza Reservations — Pro UI (Mobile-First)
   - Clean, modern, low-noise visual system
   - Mobile-first, no horizontal scroll
   - Works across modern browsers without experimental features
   ========================================================================== */

/* DESIGN TOKENS ----------------------------------------------------------- */

:root {
  /* Brand */
  --brand:       #ea4335;
  --brand-soft:  #fde8e6;
  --brand-dark:  #c5221f;

  /* Accent / status */
  --accent:      #16a34a;
  --accent-soft: #e3f5ea;
  --danger:      #ef4444;
  --danger-soft: #fee2e2;
  --warn:        #eab308;
  --warn-soft:   #fef3c7;

  /* Neutrals */
  --bg:          #f4f5f7;
  --surface:     #ffffff;
  --surface-alt: #f9fafb;
  --ink:         #111827;
  --ink-soft:    #6b7280;
  --border:      #e5e7eb;
  --border-subtle:#eef0f3;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Spacing */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", monospace;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);

  --maxw: 1120px;

  --z-header:  30;
  --z-toast:   40;
  --z-modal:   50;
}

/* Dark mode -------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #020617;
    --surface:      #020617;
    --surface-alt:  #020617;
    --ink:          #e5e7eb;
    --ink-soft:     #9ca3af;
    --border:       #111827;
    --border-subtle:#020617;

    --brand-soft:   rgba(234, 67, 53, 0.1);
    --accent-soft:  rgba(22, 163, 74, 0.12);
    --danger-soft:  rgba(239, 68, 68, 0.12);
    --warn-soft:    rgba(234, 179, 8, 0.12);

    --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-sm:    0 2px 10px rgba(0, 0, 0, 0.55);
    --shadow-md:    0 18px 40px rgba(0, 0, 0, 0.7);
  }
}

/* GLOBAL RESET & BASE ---------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* TYPOGRAPHY ------------------------------------------------------------- */

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-2);
  font-weight: 600;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  color: var(--ink-soft);
}

p {
  margin: 0 0 var(--sp-3);
  color: var(--ink-soft);
}

/* CONTAINER -------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-7) var(--sp-4) var(--sp-8);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--sp-6);
  }

  h1 {
    font-size: 1.9rem;
  }
}

/* HEADER ------------------------------------------------------------------ */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background-color: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
}

@media (prefers-color-scheme: dark) {
  .header {
    background-color: rgba(2, 6, 23, 0.9);
  }
}

.header {
  padding-left: max(var(--sp-4), calc((100vw - var(--maxw)) / 2));
  padding-right: max(var(--sp-4), calc((100vw - var(--maxw)) / 2));
}

.brand {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header nav {
  margin-left: auto;
  display: flex;
  flex-wrap: nowrap;
  gap: var(--sp-1);
  overflow-x: auto;
  padding-block: 2px;
  -webkit-overflow-scrolling: touch;
}

.header nav::-webkit-scrollbar {
  display: none;
}

.header nav a,
.header nav button.link {
  flex: 0 0 auto;
  border: none;
  border-radius: var(--r-pill);
  padding: 6px 12px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.header nav a:hover,
.header nav button.link:hover {
  background-color: var(--surface-alt);
}

.header nav a.active {
  background-color: var(--surface-alt);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* CARD -------------------------------------------------------------------- */

.card {
  background-color: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
  padding: var(--sp-5) var(--sp-4);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
  .card {
    padding: var(--sp-6);
  }
}

/* GRID LAYOUTS ----------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--sp-4);
}

.grid-2,
.grid-3 {
  display: grid;
  gap: var(--sp-4);
}

/* Mobile: single column */
.grid-2,
.grid-3 {
  grid-template-columns: minmax(0, 1fr);
}

/* Medium: 2 columns */
@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Large: 3 columns */
@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* FORMS ------------------------------------------------------------------- */

label {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
}

input[type="text"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background-color: var(--surface-alt);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* Prevent iOS zoom */
  line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-soft);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px rgba(234, 67, 53, 0.25);
  background-color: #fff;
}

/* Input rows: stack on mobile, inline on wider screens */
.input-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.input-row > * {
  flex: 1;
}

@media (min-width: 640px) {
  .input-row {
    flex-direction: row;
  }
}

.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-1);
  gap: var(--sp-2);
}

small.hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* BUTTONS ----------------------------------------------------------------- */

button,
.btn {
  appearance: none;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  background-color: var(--brand);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

button:hover,
.btn:hover {
  background-color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

button:active,
.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-xs);
}

button.secondary,
.btn.secondary {
  background-color: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary:hover,
.btn.secondary:hover {
  background-color: #fff;
}

button.ghost,
.btn.ghost {
  background-color: transparent;
  color: var(--ink-soft);
  border: 1px dashed var(--border);
  box-shadow: none;
}

button.ok,
.btn.ok {
  background-color: var(--accent);
}

button.ok:hover,
.btn.ok:hover {
  background-color: #15803d;
}

button.danger,
.btn.danger {
  background-color: var(--danger);
}

button.danger:hover,
.btn.danger:hover {
  background-color: #b91c1c;
}

/* Link style buttons */
button.link,
.btn.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand);
  box-shadow: none;
}

button.link.danger,
.btn.link.danger {
  color: var(--danger);
}

a.btn {
  text-decoration: none;
}

.btnbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* Mobile hit target */
@media (max-width: 768px) {
  button,
  .btn {
    min-height: 44px;
  }
}

/* BADGES & CHIPS --------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background-color: var(--surface-alt);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
}

.badge.maxed {
  border-color: var(--danger);
  background-color: var(--danger-soft);
  color: var(--danger);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background-color: var(--surface-alt);
  font-size: 12px;
  color: var(--ink-soft);
}

.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background-color: var(--brand);
}

/* TABS -------------------------------------------------------------------- */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background-color: var(--surface-alt);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a,
.tabs button {
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  border: none;
  padding: 6px 12px;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.tabs .active {
  background-color: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* NOTICES ----------------------------------------------------------------- */

.notice,
.error {
  margin: var(--sp-4) 0;
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  font-size: 0.9rem;
}

.notice {
  background-color: var(--accent-soft);
  border-color: rgba(22, 163, 74, 0.3);
  color: #166534;
}

.error {
  background-color: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.4);
  color: #b91c1c;
}

/* TABLES ------------------------------------------------------------------ */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  margin-top: var(--sp-4);
}

thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

tbody tr {
  filter: drop-shadow(var(--shadow-xs));
}

td {
  padding: 10px 12px;
  background-color: var(--surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}

tbody td:first-child {
  border-top-left-radius: var(--r-md);
  border-bottom-left-radius: var(--r-md);
}

tbody td:last-child {
  border-top-right-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

/* Mobile table pattern: stack rows with data-labels */
@media (max-width: 768px) {
  table {
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    margin-bottom: var(--sp-3);
  }

  td {
    position: relative;
    padding-left: 46%;
    border-radius: var(--r-md);
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--ink-soft);
  }
}

/* MODALS & TOASTS -------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  z-index: var(--z-modal);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: var(--z-modal);
  padding: var(--sp-4);
}

.modal .panel {
  width: min(520px, 100%);
  padding: var(--sp-5);
  border-radius: var(--r-xl);
  background-color: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

/* Toasts */
.toast-wrap {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  display: grid;
  gap: var(--sp-2);
  z-index: var(--z-toast);
}

.toast {
  min-width: 220px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background-color: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  color: var(--ink);
}

/* ACTION BAR (MOBILE) ---------------------------------------------------- */

.actionbar {
  position: sticky;
  bottom: 0;
  display: none;
  padding: var(--sp-3);
  background-color: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}

@media (max-width: 768px) {
  .actionbar {
    display: block;
    padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  }
}

/* UTILITY CLASSES -------------------------------------------------------- */

.center {
  display: grid;
  place-items: center;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }

.hidden {
  display: none !important;
}

/* ACCESSIBILITY ---------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* MOTION PREFERENCES ----------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}