/* Gastro-POS Prototyp — Design-Tokens siehe /DESIGN.md */

:root {
  --bg: oklch(0.15 0.008 60);
  --surface: oklch(0.19 0.01 60);
  --surface-2: oklch(0.23 0.012 62);
  --surface-3: oklch(0.27 0.014 62);
  --line: oklch(0.30 0.012 62);
  --text: oklch(0.95 0.006 75);
  --text-2: oklch(0.66 0.012 70);
  --text-3: oklch(0.48 0.012 68);
  --accent: oklch(0.76 0.14 68);
  --accent-press: oklch(0.70 0.14 68);
  --accent-dim: oklch(0.76 0.14 68 / 0.14);
  --on-accent: oklch(0.18 0.02 68);
  --ok: oklch(0.72 0.11 150);
  --ok-dim: oklch(0.72 0.11 150 / 0.14);
  --err: oklch(0.64 0.17 27);
  --err-dim: oklch(0.64 0.17 27 / 0.14);
  --paper: oklch(0.97 0.008 85);
  --on-paper: oklch(0.22 0.01 60);

  --ease: cubic-bezier(0.165, 0.84, 0.44, 1); /* ease-out-quart */
  --radius: 14px;
  --pill: 999px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  color-scheme: dark;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

input {
  font: inherit;
  color: inherit;
}

.num, .table-sum-value, .price, .qty-badge, .order-bar-sum, .round-time,
.pin-key, .tile-nr, .split-person-sum {
  font-variant-numeric: tabular-nums;
}

/* ===== View-Gerüst ===== */

.view {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.view[hidden] { display: none; }
/* fixed-positionierte Kinder versteckter Views ebenfalls unterdrücken */
.view[hidden] .order-bar, .view[hidden] .draft-sheet { display: none; }

/* ===== Topbar ===== */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) var(--pad) 10px;
}

.topbar-title { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-sub { font-size: 13px; color: var(--text-2); }
.topbar-center { flex: 1; min-width: 0; }
.topbar-center .topbar-title { font-size: 20px; }
.topbar-spacer { width: 44px; }

.topbar-back {
  width: 44px; height: 44px;
  flex: none;
  border-radius: var(--pill);
  background: var(--surface);
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding-bottom: 3px;
}
.topbar-back:active { background: var(--surface-2); }

.topbar-action {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-2);
  padding: 10px 14px;
  border-radius: var(--pill);
  background: var(--surface);
}
.topbar-action:active { background: var(--surface-2); }

/* ===== Buttons ===== */

.btn {
  min-height: 56px;
  padding: 0 22px;
  border-radius: var(--pill);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 120ms var(--ease), background-color 120ms var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; pointer-events: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--err); color: oklch(0.97 0.01 27); }

/* ===== Login ===== */

.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) calc(20px + var(--safe-b));
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

.login-head { padding: max(48px, calc(env(safe-area-inset-top) + 32px)) 0 28px; }
.login-restaurant {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.login-title { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }

.waiter-row { display: flex; gap: 10px; flex-wrap: wrap; }

.waiter-chip {
  min-height: 52px;
  padding: 0 18px 0 8px;
  border-radius: var(--pill);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.waiter-chip .avatar {
  width: 38px; height: 38px;
  border-radius: var(--pill);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--text);
}
.waiter-chip.is-active { background: var(--accent-dim); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.waiter-chip.is-active .avatar { background: var(--accent); color: var(--on-accent); }

.pin-label { margin-top: 34px; font-size: 13px; color: var(--text-2); text-align: center; }
.pin-label.is-error { color: var(--err); }

.pin-dots { display: flex; gap: 14px; justify-content: center; margin-top: 14px; height: 12px; }
.pin-dots span {
  width: 12px; height: 12px;
  border-radius: var(--pill);
  background: var(--surface-3);
  transition: background-color 100ms var(--ease);
}
.pin-dots span.is-filled { background: var(--accent); }
.pin-dots.is-shake { animation: shake 320ms var(--ease); }
@keyframes shake {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

.pin-pad {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pin-key {
  height: 64px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 24px;
  font-weight: 500;
  transition: background-color 80ms var(--ease);
}
.pin-key:active { background: var(--surface-3); }
.pin-key-del { font-size: 20px; color: var(--text-2); }

.demo-toggle {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
}
.demo-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ===== Tischplan ===== */

.segment {
  display: flex;
  gap: 4px;
  margin: 6px var(--pad) 4px;
  padding: 4px;
  border-radius: var(--pill);
  background: var(--surface);
}
.segment-btn {
  flex: 1;
  min-height: 44px;
  border-radius: var(--pill);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.segment-btn.is-active { background: var(--surface-3); color: var(--text); }

.table-zones { flex: 1; padding: 10px var(--pad) calc(28px + var(--safe-b)); }

.zone-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 18px 2px 10px;
}
.zone-label:first-child { margin-top: 4px; }

.table-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tile {
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 108px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  transition: background-color 100ms var(--ease), transform 120ms var(--ease);
  position: relative;
}
.tile:active { transform: scale(0.97); background: var(--surface-2); }

.tile-nr { font-size: 42px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.tile.is-free .tile-nr { color: var(--text-3); }
.tile.is-free { background: oklch(0.17 0.009 60); box-shadow: inset 0 0 0 1px var(--line); }

.tile-meta {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tile.is-mine::after {
  content: "";
  position: absolute;
  top: 12px; right: 12px;
  width: 8px; height: 8px;
  border-radius: var(--pill);
  background: var(--accent);
}
.tile-sum { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 2px; }

/* ===== Tisch-Detail ===== */

.rounds { flex: 1; padding: 4px var(--pad) 16px; }

.round { margin-top: 18px; }
.round:first-child { margin-top: 6px; }

.round-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.round-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.round-time { font-size: 13px; color: var(--text-3); }

.status-chip {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-chip.is-sending { background: var(--surface-2); color: var(--text-2); }
.status-chip.is-sending::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: var(--pill);
  background: var(--text-2);
  animation: pulse 900ms ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }
.status-chip.is-sent { background: var(--ok-dim); color: var(--ok); }
.status-chip.is-error { background: var(--err-dim); color: var(--err); }

.round-items { border-radius: var(--radius); background: var(--surface); overflow: hidden; }

.row {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: background-color 100ms var(--ease);
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }

.row-qty { font-weight: 700; color: var(--text-2); min-width: 26px; }
.row-main { flex: 1; min-width: 0; }
.row-name { display: block; font-size: 16px; font-weight: 500; }
.row-mods { display: block; font-size: 13px; color: var(--accent); margin-top: 1px; }
.row-void-tag { display: block; }
.row-price { font-size: 15px; color: var(--text-2); }
.row.is-void .row-name { text-decoration: line-through; color: var(--text-3); }
.row.is-void .row-qty, .row.is-void .row-price { color: var(--text-3); }
.row-void-tag { font-size: 12px; color: var(--err); }

.round-retry {
  margin-top: 8px;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--err-dim);
  color: var(--err);
  font-weight: 600;
  font-size: 15px;
}

.empty {
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
  padding: 56px 24px;
}

.table-footer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  padding: 18px var(--pad) calc(16px + var(--safe-b));
}
.table-sum {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.table-sum-label { font-size: 13px; color: var(--text-2); }
.table-sum-value { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }

.table-actions { display: flex; gap: 10px; }
.table-actions .btn { white-space: nowrap; font-size: 15px; padding: 0 14px; }
.table-actions .btn-ghost { flex: 1; }
.table-actions .btn-primary { flex: 1.4; }

/* ===== Bonieren ===== */

.cat-chips {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 8px var(--pad) 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(to bottom, var(--bg) 82%, transparent);
}
.cat-chips::-webkit-scrollbar { display: none; }

.cat-chip {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--pill);
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.cat-chip.is-active { background: var(--accent); color: var(--on-accent); }

.menu-list {
  flex: 1;
  margin: 0 var(--pad);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  align-self: stretch;
  margin-bottom: 140px;
}

.menu-row {
  width: 100%;
  min-height: 60px;
  padding: 10px 6px 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: background-color 80ms var(--ease);
}
.menu-row + .menu-row { border-top: 1px solid var(--line); }
.menu-row:active { background: var(--surface-2); }

.menu-main { flex: 1; min-width: 0; }
.menu-name { display: block; font-size: 16px; font-weight: 500; }
.menu-mods { display: block; font-size: 13px; color: var(--accent); margin-top: 1px; }
.price { font-size: 15px; color: var(--text-2); }

.qty-badge {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  animation: pop 180ms var(--ease);
}
@keyframes pop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }

.menu-more {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 20px;
  border-radius: var(--pill);
}
.menu-more:active { background: var(--surface-3); color: var(--text); }

.order-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  display: flex;
  gap: 10px;
  padding: 14px var(--pad) calc(14px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 20;
}

.order-bar-summary {
  flex: 1;
  min-height: 56px;
  border-radius: var(--pill);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 0 10px;
  min-width: 0;
  transition: background-color 120ms var(--ease);
}
.order-bar-summary:active { background: var(--surface-3); }

.order-bar-count {
  width: 36px; height: 36px;
  flex: none;
  border-radius: var(--pill);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.order-bar-summary.has-items .order-bar-count { background: var(--accent); color: var(--on-accent); }

.order-bar-text {
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-bar-sum { margin-left: auto; font-size: 16px; font-weight: 700; white-space: nowrap; }

.order-send { flex: none; min-width: 118px; }

/* Bon-Entwurf */
.draft-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  max-height: 62dvh;
  overflow-y: auto;
  background: var(--surface-2);
  border-radius: 20px 20px 0 0;
  padding: 8px var(--pad) calc(100px + var(--safe-b));
  z-index: 15;
}
.draft-items { border-radius: var(--radius); background: var(--surface); overflow: hidden; margin-top: 12px; }

.draft-row-controls { display: flex; align-items: center; gap: 4px; }
.qty-step {
  width: 44px; height: 44px;
  border-radius: var(--pill);
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--text-2);
}
.qty-step:active { background: var(--surface-3); color: var(--text); }

/* ===== Sheets ===== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.08 0.005 60 / 0.6);
  z-index: 30;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.sheet-backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: min(100%, 560px);
  background: var(--surface-2);
  border-radius: 20px 20px 0 0;
  padding: 8px var(--pad) calc(20px + var(--safe-b));
  z-index: 31;
  transform: translate(-50%, 105%);
  transition: transform 240ms var(--ease);
  max-height: 82dvh;
  overflow-y: auto;
}
.sheet.is-open { transform: translate(-50%, 0); }

.sheet-grip {
  width: 40px; height: 4px;
  border-radius: var(--pill);
  background: var(--surface-3);
  margin: 6px auto 14px;
}
.sheet-title { font-size: 20px; font-weight: 700; }
.sheet-sub { font-size: 14px; color: var(--text-2); margin-top: 3px; }
.sheet-actions { margin-top: 18px; display: flex; }
.sheet-actions .btn { flex: 1; }

.mod-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.mod-chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--pill);
  background: var(--surface);
  font-size: 15px;
  color: var(--text-2);
  transition: background-color 100ms var(--ease), color 100ms var(--ease);
}
.mod-chip.is-active { background: var(--accent-dim); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }

.mod-freetext {
  margin-top: 14px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  outline: none;
}
.mod-freetext:focus { border-color: var(--accent); }
.mod-freetext::placeholder { color: var(--text-3); }

.storno-reasons { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.storno-reason {
  min-height: 52px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  text-align: left;
  padding: 0 16px;
  color: var(--text-2);
  transition: background-color 100ms var(--ease), color 100ms var(--ease);
}
.storno-reason.is-active { background: var(--err-dim); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--err); }

/* ===== Bon-Vorschau (Thermo-Look) ===== */

.sheet-bon { background: var(--surface-2); }
.bon-wrap { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

.bon {
  background: var(--paper);
  color: var(--on-paper);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 18px 18px 26px;
  border-radius: 3px;
  /* Zickzack-Abrisskante unten */
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px),
    97.5% 100%, 95% calc(100% - 8px), 92.5% 100%, 90% calc(100% - 8px), 87.5% 100%,
    85% calc(100% - 8px), 82.5% 100%, 80% calc(100% - 8px), 77.5% 100%,
    75% calc(100% - 8px), 72.5% 100%, 70% calc(100% - 8px), 67.5% 100%,
    65% calc(100% - 8px), 62.5% 100%, 60% calc(100% - 8px), 57.5% 100%,
    55% calc(100% - 8px), 52.5% 100%, 50% calc(100% - 8px), 47.5% 100%,
    45% calc(100% - 8px), 42.5% 100%, 40% calc(100% - 8px), 37.5% 100%,
    35% calc(100% - 8px), 32.5% 100%, 30% calc(100% - 8px), 27.5% 100%,
    25% calc(100% - 8px), 22.5% 100%, 20% calc(100% - 8px), 17.5% 100%,
    15% calc(100% - 8px), 12.5% 100%, 10% calc(100% - 8px), 7.5% 100%,
    5% calc(100% - 8px), 2.5% 100%, 0 calc(100% - 8px));
}
.bon-station { font-size: 16px; font-weight: 700; letter-spacing: 0.08em; }
.bon hr { border: 0; border-top: 1px dashed oklch(0.6 0.01 60); margin: 8px 0; }
.bon-line { display: flex; justify-content: space-between; gap: 12px; }
.bon-mod { padding-left: 26px; }

/* ===== Split-Vorschlag ===== */

.split-hint {
  font-size: 13px;
  color: var(--text-2);
  padding: 2px var(--pad) 12px;
}

.split-persons {
  display: flex;
  gap: 8px;
  padding: 0 var(--pad) 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.split-persons::-webkit-scrollbar { display: none; }

.person-chip {
  flex: none;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--pill);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.person-chip.is-active { background: var(--accent); color: var(--on-accent); }
.person-chip-add { color: var(--accent); background: var(--accent-dim); }

.split-items {
  flex: 1;
  margin: 0 var(--pad);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.split-assign {
  flex: none;
  min-width: 44px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--pill);
  background: var(--surface-3);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  display: grid;
  place-items: center;
}
.split-assign.is-assigned { background: var(--accent); color: var(--on-accent); }

.split-footer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  padding: 16px var(--pad) calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.split-person-line { display: flex; justify-content: space-between; font-size: 16px; }
.split-person-name { color: var(--text-2); }
.split-person-sum { font-weight: 700; }
.split-rest { color: var(--text-3); }

/* ===== Toast ===== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--surface-3);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--pill);
  z-index: 40;
  white-space: nowrap;
  animation: toast-in 220ms var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

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