/* Pizza Queue — touch-first UI for tablets/phones, fine on desktop.
   Big tap targets, clear status colors:
   queued = gray, baking = amber, ready = green. */

:root {
  --bg: #f5f1ea;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e0d6;
  --primary: #c2410c;
  --primary-dark: #9a3412;
  --queued: #94a3b8;
  --baking: #f59e0b;
  --ready: #22c55e;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}

.container { max-width: 1000px; margin: 0 auto; padding: 12px 12px 90px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; padding: 10px 14px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.username { opacity: .85; font-size: .95rem; }
.sse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); display: inline-block; transition: background .3s;
}
.sse-dot.live { background: var(--ready); }
.role-badge {
  text-transform: uppercase; font-size: .7rem; font-weight: 700;
  padding: 4px 8px; border-radius: 999px; letter-spacing: .05em;
}
.role-cafe { background: #fde68a; color: #713f12; }
.role-baker { background: #fdba74; color: #7c2d12; }
.role-admin { background: #c7d2fe; color: #312e81; }

/* ---------- Buttons & inputs ---------- */
.btn {
  font: inherit; border: none; border-radius: var(--radius);
  background: #e7e5e4; color: var(--ink); cursor: pointer;
  min-height: 48px; padding: 10px 18px; font-weight: 600;
  touch-action: manipulation; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: inherit; border: 1.5px solid currentColor; min-height: 40px; }
.btn-big { min-height: 60px; font-size: 1.15rem; }
.btn-block { width: 100%; }
.btn-small { min-height: 42px; padding: 6px 14px; }

.input {
  font: inherit; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 46px; background: #fff; width: 100%;
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tabs .tab {
  flex: 1; font: inherit; font-weight: 700; border: none; cursor: pointer;
  background: #e7e5e4; color: var(--muted); border-radius: var(--radius);
  min-height: 56px; font-size: 1.05rem; touch-action: manipulation;
}
.tabs .tab.active { background: var(--ink); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title { font-size: 1.05rem; margin: 18px 4px 10px; }
.count-badge {
  background: var(--primary); color: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: .85rem; vertical-align: middle;
}
.hint { color: var(--muted); font-size: .95rem; margin: 8px 4px; }
.empty-hint { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- Queue board ---------- */
.queue-board { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.order-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden;
  border-left: 6px solid var(--queued);
}
.order-status-in_process { border-left-color: var(--baking); }
.order-status-ready { border-left-color: var(--ready); }
.order-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #faf7f2; border-bottom: 1px solid var(--line);
}
.order-num { font-size: 1.35rem; font-weight: 800; }
.order-count { color: var(--muted); }
.order-src {
  margin-left: auto; font-size: .75rem; font-weight: 700; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; letter-spacing: .04em;
}
.src-cafe { background: #fde68a; color: #713f12; }
.src-terrace { background: #bbf7d0; color: #14532d; }
.order-time { color: var(--muted); font-size: .85rem; }

.pizza-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.pizza-row:last-child { border-bottom: none; }
.pizza-main { flex: 1; min-width: 0; }
.pizza-name { font-weight: 700; }
.pizza-note { color: var(--primary-dark); font-weight: 600; font-size: .95rem; margin-top: 2px; }
.status-in_process .pizza-name::after { content: " 🔥"; }

.status-chip {
  font-size: .8rem; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  white-space: nowrap;
}
.chip-queued { background: #e2e8f0; color: #334155; }
.chip-in_process { background: #fef3c7; color: #92400e; }
.chip-ready { background: #dcfce7; color: #166534; }
.chip-picked_up { background: #e7e5e4; color: var(--muted); }

.btn-advance { min-width: 118px; white-space: nowrap; }
.advance-queued { background: var(--queued); color: #fff; }
.advance-in_process { background: var(--baking); color: #fff; }
.advance-ready { background: var(--ready); color: #fff; }

.pizza-arrows { display: flex; flex-direction: column; gap: 4px; }
.btn-arrow {
  min-height: 36px; min-width: 44px; padding: 2px 10px;
  border-radius: 8px; font-size: .9rem;
}
.btn-remove { color: var(--danger); }

/* ---------- Order builder ---------- */
.menu-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.menu-tile {
  background: var(--card); border-radius: var(--radius); padding: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.menu-tile-special { outline: 2px dashed var(--baking); }
.menu-tile-name { font-weight: 700; }
.menu-tile-price { color: var(--muted); font-size: .95rem; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper-qty { min-width: 28px; text-align: center; font-size: 1.2rem; font-weight: 800; }
.btn-step { min-width: 54px; min-height: 54px; font-size: 1.5rem; border-radius: 12px; padding: 0; }
.btn-step-plus { background: var(--primary); color: #fff; }

.build-list { display: flex; flex-direction: column; gap: 8px; }
.build-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--radius); padding: 8px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.build-seq {
  background: var(--ink); color: #fff; border-radius: 50%;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; font-size: .9rem;
}
.build-name { font-weight: 700; flex-shrink: 0; min-width: 110px; }
.build-note { flex: 1; min-width: 80px; }

.builder-actions {
  display: flex; gap: 10px; margin-top: 16px;
  position: sticky; bottom: 12px;
}
.builder-actions .btn-primary { flex: 1; }

/* ---------- Baker price editing ---------- */
.menu-edit-list { display: flex; flex-direction: column; gap: 8px; }
.menu-edit-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--radius); padding: 8px 12px;
}
.me-name-fixed { font-weight: 700; flex: 1; }
.me-name { flex: 1; }
.me-currency { color: var(--muted); }
.me-price { width: 110px; flex-shrink: 0; }
.tag { font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.tag-special { background: #fef3c7; color: #92400e; }
.tag-inactive { background: #e7e5e4; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-table { display: flex; flex-direction: column; gap: 6px; }
.admin-row, .admin-row-head {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 2fr 1fr .7fr .6fr .6fr auto auto;
  background: var(--card); border-radius: 10px; padding: 8px 12px;
}
.admin-row-head { background: transparent; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.admin-row-user {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 2fr 1.3fr .8fr .8fr auto;
  background: var(--card); border-radius: 10px; padding: 8px 12px;
}
.admin-row-user.admin-row-head { background: transparent; }
.admin-row-order {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: .5fr 1.4fr .8fr .6fr 1fr .8fr auto;
  background: var(--card); border-radius: 10px; padding: 8px 12px;
}
.admin-row-order.admin-row-head { background: transparent; }
.admin-row-order .status-chip { justify-self: start; }
.check { display: flex; justify-content: center; }
.check input { width: 24px; height: 24px; }
.user-create-form, .export-form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--card); border-radius: var(--radius); padding: 14px;
}
.user-create-form .input { flex: 1; min-width: 160px; }
.export-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 380px; box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0 0 18px; text-align: center; }
.login-card label { display: block; font-weight: 600; margin: 12px 0 6px; }
.login-card input {
  font: inherit; width: 100%; border: 1.5px solid var(--line);
  border-radius: 10px; padding: 12px; min-height: 50px;
}
.login-card button { margin-top: 20px; }
.form-error { color: var(--danger); font-weight: 600; text-align: center; }

/* ---------- Header secondary actions ---------- */
.btn-header { min-height: 38px; padding: 4px 12px; font-size: .9rem; white-space: nowrap; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(28, 25, 23, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 12px 24px; overflow-y: auto;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg); border-radius: var(--radius);
  padding: 16px 18px 20px; width: 100%; max-width: 680px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 22px;
  border-radius: 999px; font-weight: 600; z-index: 100;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 90vw;
  transition: opacity .25s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast-error { background: var(--danger); }

/* ---------- Responsive split layout (cafe & baker) ----------
   Below 760px: tabbed toggle (phones).
   760px and up (incl. portrait tablets ~800px): tab bar hides and queue
   (left, ~45%) + order builder (right, ~55%) show side by side — the live
   queue keeps updating while building. The builder gets the wider column
   so menu tiles and steppers stay large; tiles per row follow the column
   width automatically (auto-fill), dropping to 1 when space is tight. */
.split-only { display: none; }

@media (min-width: 760px) {
  .container { max-width: 1500px; }
  .tabs.split-tabs { display: none; }
  .split-layout {
    display: grid;
    grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); /* queue 45% / builder 55% */
    gap: 16px;
    align-items: start;
    margin-top: 14px;
  }
  .split-layout > .tab-panel { display: block; }
  .split-only { display: block; margin-top: 0; }
  .split-layout .section-title:first-child { margin-top: 0; }
  /* Single column of cards inside the narrow queue pane. */
  .split-layout .queue-board { grid-template-columns: 1fr; }
  /* Menu tiles need ~280px each for full-size steppers + readable names:
     1 per row on portrait tablets (~440px column), 2-3 per row as the
     builder column widens. Tap targets never shrink. */
  .split-layout .menu-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* Wider screens: roomier gap between the two panes. */
@media (min-width: 1100px) {
  .split-layout { gap: 22px; }
}

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .queue-board { grid-template-columns: 1fr; }
  .build-name { min-width: 80px; }
  .username { display: none; }
  .admin-row, .admin-row-head { grid-template-columns: 1.5fr 1fr .6fr .5fr .5fr auto auto; font-size: .85rem; }
}
