/* Admin – mobile-first, big touch targets (min. 48px). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #5d636b;
  --line: #dde0e4;
  --primary: #1d4e89;
  --primary-text: #ffffff;
  --success: #1e7b34;
  --danger: #b3261e;
  --soldout: #c0392b;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.2; }

/* ---------- Views ---------- */
.view-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  text-align: center;
}
.big-text { margin: 0; font-size: 1.2rem; font-weight: 600; }
.hint { margin: 0; color: var(--muted); font-size: 0.95rem; }
.empty { padding: 32px 16px; text-align: center; }

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  text-align: left;
}
.login h1 { font-size: 1.5rem; margin-bottom: 20px; }
.login .hint { margin-top: 16px; text-align: center; }

/* ---------- Form fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 6px; font-weight: 600; }
.optional { font-weight: 400; color: var(--muted); }
input[type="email"], input[type="password"], input[type="text"],
input[type="search"], textarea, select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px; /* >= 16px stops iOS from zooming in */
}
textarea { resize: vertical; min-height: 96px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
input.is-invalid { border-color: var(--danger); }
.form-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fdecea;
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: #e4e7eb; color: var(--text); }
.btn-block { width: 100%; }
.btn-small {
  min-height: 44px;
  padding: 8px 12px;
  background: transparent;
  color: var(--primary);
  font-size: 0.95rem;
  white-space: nowrap;
}

/* ---------- Top bar + search ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 16px;
  background: var(--bg);
}

/* ---------- Restaurant picker ---------- */
.picker { list-style: none; margin: 0; padding: 16px; display: grid; gap: 12px; }
.picker .btn { width: 100%; text-align: left; background: var(--surface); color: var(--text); font-size: 1.1rem; }

/* ---------- Menu list ---------- */
.menu-list { padding: 0 16px 96px; max-width: 720px; margin: 0 auto; }
.category { margin-top: 20px; }
.category-title { font-size: 1.15rem; margin: 0 0 8px; }
.category-hidden-note {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e4e7eb;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
}

.item {
  display: flex;
  align-items: stretch;
  margin-bottom: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}
.item-main {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.item-main:active { background: #eef2f7; }
.item-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 0.95rem; }
.item-price { font-weight: 600; color: var(--text); }
.item.is-sold-out .item-name,
.item.is-sold-out .item-meta { color: #9aa0a6; }

/* Big "Vypredané" switch */
.soldout {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 96px;
  padding: 8px 4px;
  border-left: 1px solid var(--line);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
.soldout input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.soldout-track {
  position: relative;
  width: 56px;
  height: 32px;
  border-radius: 16px;
  background: #c7ccd2;
  transition: background 0.15s;
}
.soldout-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.soldout input:checked + .soldout-track { background: var(--soldout); }
.soldout input:checked + .soldout-track::after { transform: translateX(24px); }
.soldout input:focus-visible + .soldout-track { outline: 3px solid var(--primary); outline-offset: 2px; }
.soldout input:disabled + .soldout-track { opacity: 0.6; }
.soldout-text { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.soldout input:checked ~ .soldout-text { color: var(--soldout); }

/* ---------- Edit sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 16px 16px 0 0;
}
.sheet h2 { font-size: 1.3rem; margin-bottom: 16px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}
body.no-scroll { overflow: hidden; }
.sheet-top { z-index: 25; } /* confirm dialog above the edit sheet */
.confirm-text { margin: 4px 0 20px; font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 0.9rem; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline {
  margin-top: 24px;
  background: transparent;
  border: 2px solid var(--danger);
  color: var(--danger);
}

/* ---------- Add item / allergen note / account ---------- */
.btn-add {
  width: 100%;
  border: 2px dashed #b7bec7;
  background: transparent;
  color: var(--primary);
  text-align: left;
}
.btn-add:active { background: #eef2f7; }
.item-allergens-missing {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff4d6;
  color: #7a5200;
  font-size: 0.8rem;
  font-weight: 600;
}
.menu-list { padding-bottom: 24px; } /* the account footer below keeps room for the toast */
.account { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 14px 20px;
  border-radius: 10px;
  background: var(--success);
  color: #fff;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.toast.is-error { background: var(--danger); }

/* ---------- Move item up / down ---------- */
.item-move {
  flex: none;
  display: grid;
  grid-template-rows: 1fr 1fr;
  width: 52px;
  border-left: 1px solid var(--line);
}
.move-btn {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.move-btn[data-action="up"] { grid-row: 1; }
.move-btn[data-action="down"] { grid-row: 2; border-top: 1px solid var(--line); }
.move-btn[data-action="up"][hidden] + .move-btn { border-top: 0; }
.move-btn:active { background: #eef2f7; }
.move-btn:disabled { opacity: 0.4; cursor: default; }
.menu-list.is-searching .item-move { display: none; }

/* ---------- Categories ---------- */
.category-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.category-head .category-title { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.category-head .btn-small { flex: none; }
/* Note preview: two lines at most, the full text is in the edit sheet. */
.category-note-preview {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.category-note-preview[hidden] { display: none; }
.note-count { text-align: right; }

/* Hidden category: stays in the admin, but clearly marked. */
.category.is-hidden {
  padding: 10px;
  border: 2px dashed #9aa0a6;
  border-radius: var(--radius);
  background: repeating-linear-gradient(-45deg, #eceef1 0 10px, #e4e7eb 10px 20px);
}
.category.is-hidden .item { opacity: 0.75; }
.category.is-hidden .category-hidden-note { background: #3c4148; color: #fff; }

.add-category { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
.category-status { margin: 24px 0 12px; color: var(--muted); }
.category-status strong { color: var(--text); }

/* ---------- Tabs: main menu / daily menu / Wi-Fi and footer ---------- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px 0;
}
.tab {
  min-height: 52px;
  padding: 8px 6px;
  line-height: 1.2;
  border: 2px solid var(--primary);
  border-radius: 10px;
  background: var(--surface);
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.tab.is-active { background: var(--primary); color: var(--primary-text); }

/* ---------- Wi-Fi and menu footer ---------- */
.settings { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }
.settings-title { margin: 20px 0 10px; font-size: 1.15rem; }
#settings-retry { margin-bottom: 12px; }

/* ---------- Daily menu ---------- */
.daily { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }
.daily-days {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
}
.day-btn { padding: 12px 8px; background: #e4e7eb; color: var(--text); }
.day-btn.is-active { background: var(--primary); color: var(--primary-text); }
input[type="date"] {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
}
input[type="date"].is-active { border-color: var(--primary); }
.daily-title { margin: 20px 0 10px; font-size: 1.15rem; }
.daily-status { margin: 0 0 12px; color: var(--muted); }
.daily-status.is-error { color: var(--danger); font-weight: 600; }
#daily-retry { margin-bottom: 12px; }
.daily-label {
  display: inline-block;
  margin-bottom: 2px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.daily-allergens { display: block; margin-top: 2px; color: var(--muted); font-size: 0.85rem; }
.item.is-sold-out .daily-label { color: #9aa0a6; }

/* ---------- Allergen picker ---------- */
.allergen-picker { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.allergen-picker .field-hint { margin: 0 0 10px; }
.allergen-options {
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 12px;
}
.allergen-picker.is-invalid .allergen-options { border-color: var(--danger); }
.allergen-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f0f2f5;
  cursor: pointer;
  touch-action: manipulation;
}
.allergen-option input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--primary); }
.allergen-option.is-none { margin-bottom: 6px; background: #e4ecf6; font-weight: 600; }
.allergen-number { flex: none; min-width: 1.6em; font-weight: 700; }
@media (min-width: 600px) {
  .allergen-options { grid-template-columns: 1fr 1fr; }
  .allergen-option.is-none { grid-column: 1 / -1; }
}
