/* ==========================================================================
   Canteen OS — shared design system
   Ticket-rail motif: every screen reads like a kitchen order ticket.
   Role accent colors are the only thing that changes between apps.
   ========================================================================== */

@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&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --ink: #14171f;
  --paper: #faf7f0;
  --surface: #ffffff;
  --line: #e7e2d8;
  --muted: #6b6557;

  --danger: #d33c3c;
  --danger-dark: #b32d2d;

  /* Default accent — overridden per role in each page's own stylesheet */
  --accent: #1f8a57;
  --accent-dark: #176e45;
  --accent-soft: rgba(31, 138, 87, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 2px rgba(20, 23, 31, 0.04), 0 8px 24px rgba(20, 23, 31, 0.06);
  --shadow-pop: 0 12px 32px rgba(20, 23, 31, 0.14);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   Ticket rail — the persistent top bar, present on every page
   -------------------------------------------------------------------------- */
.ticket-rail {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--accent);
}

.ticket-rail__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.ticket-rail__role {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.ticket-rail__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(250, 247, 240, 0.6);
}

.live-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6);
  animation: pulse-dot 2s infinite;
}

.live-dot.is-offline::before {
  background: var(--danger);
  animation: none;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* --------------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------------- */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.shell__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.shell__header h1 {
  font-size: 28px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card--accent {
  border-top: 3px solid var(--accent);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--auto {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

@media (max-width: 760px) {
  .grid--3 {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Stat cards
   -------------------------------------------------------------------------- */
.stat-card {
  padding: 22px;
}

.stat-card__label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-card__value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-dark);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
  color: #b3ad9c;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

/* --------------------------------------------------------------------------
   Auth screens
   -------------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-pop);
  border-top: 4px solid var(--accent);
  text-align: center;
}

.auth-card__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.auth-card h1 {
  font-size: 26px;
  margin-bottom: 24px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card__footer {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.auth-card__footer a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}

.auth-card__footer a:hover {
  text-decoration: underline;
}

.banner {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  text-align: left;
  display: none;
}

.banner.is-visible {
  display: block;
}

.banner--error {
  background: rgba(211, 60, 60, 0.1);
  color: var(--danger-dark);
  border: 1px solid rgba(211, 60, 60, 0.25);
}

.banner--success {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid rgba(31, 138, 87, 0.25);
}

/* --------------------------------------------------------------------------
   Ticket stub — the signature element. Used for order tokens everywhere.
   -------------------------------------------------------------------------- */
.ticket {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.ticket__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px dashed var(--line);
  position: relative;
}

.ticket__head::before,
.ticket__head::after {
  content: '';
  position: absolute;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--paper);
  border-radius: 50%;
}

.ticket__head::before { left: -7px; }
.ticket__head::after { right: -7px; }

.ticket__token {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket__token-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
}

.ticket__body {
  padding: 16px 18px;
}

.ticket__items {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 12px;
  line-height: 1.7;
}

.ticket__items .qty {
  font-family: var(--font-mono);
  color: var(--muted);
}

.ticket__total {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-pill--preparing {
  background: rgba(217, 98, 43, 0.12);
  color: #b3531f;
}
.status-pill--preparing::before { background: #d9622b; }

.status-pill--ready {
  background: rgba(31, 138, 87, 0.12);
  color: var(--accent-dark);
}
.status-pill--ready::before { background: var(--accent); }

.status-pill--completed {
  background: rgba(107, 101, 87, 0.12);
  color: var(--muted);
}
.status-pill--completed::before { background: var(--muted); }

.status-pill--cancelled {
  background: rgba(211, 60, 60, 0.1);
  color: var(--danger-dark);
}
.status-pill--cancelled::before { background: var(--danger); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

th {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  background: rgba(20, 23, 31, 0.02);
}

td {
  font-size: 14.5px;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(20, 23, 31, 0.015);
}

.price-cell, .qty-cell {
  font-family: var(--font-mono);
}

.row--total td {
  font-weight: 700;
  background: var(--accent-soft);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}

.empty-state__icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 6px;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
}

.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-pop);
  border-left: 3px solid var(--accent);
  animation: toast-in 0.25s ease;
}

.toast--error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------------------------------
   Misc utility
   -------------------------------------------------------------------------- */
.text-muted { color: var(--muted); }
.mt-section { margin-top: 36px; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.category-tab {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}

.category-tab:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.category-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, #f0ece2 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
