/* Page for Plate — owner portal styles. Mobile-first, low-chrome. */

:root {
  --fg:        #1a1a1a;
  --muted:     #6b7280;
  --bg:        #faf8f5;
  --card-bg:   #ffffff;
  --line:      #e7e5e0;
  --accent:    #e8743b;   /* matches the brand orange used on postcards */
  --accent-hi: #c95d27;
  --good:      #166534;
  --good-bg:   #ecfdf5;
  --bad:       #991b1b;
  --bad-bg:    #fef2f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

a { color: var(--accent); }
a:hover { color: var(--accent-hi); }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(0,0,0,0.04);
  padding: 1px 6px;
  border-radius: 4px;
}

.muted { color: var(--muted); }

/* ---- Centered card layout (login + root) ---- */

.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 24px;
}

.card h1 { margin: 0 0 4px; font-size: 22px; }
.card .subtitle { margin: 0 0 24px; color: var(--muted); }

.card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.card input[type="email"],
.card input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.card input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.card button[type="submit"],
button.primary {
  display: inline-block;
  width: 100%;
  margin-top: 16px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.card button[type="submit"]:hover { background: var(--accent-hi); }

.footnote {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.sent h2 { margin: 0 0 8px; font-size: 18px; }

/* ---- Edit page ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.topbar__actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.topbar form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

/* "Install as app" button — quiet pill that's noticeable but doesn't compete
   with primary actions. Hidden by default; install.js shows it when the
   platform supports an install path. */
.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(232, 116, 59, 0.08);
  border: 1px solid rgba(232, 116, 59, 0.25);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.install-btn:hover {
  background: rgba(232, 116, 59, 0.16);
  border-color: rgba(232, 116, 59, 0.4);
}
.install-btn::before {
  content: "+";
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}
.install-btn--block {
  display: flex;
  width: 100%;
  justify-content: center;
  margin-top: 16px;
  padding: 10px 16px;
  font-size: 14px;
}

button.link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.layout {
  display: grid;
  gap: 24px;
  padding: 24px;
  max-width: 1080px;
  margin: 0 auto;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}

.layout--single { grid-template-columns: minmax(0, 720px); }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
}

.composer, .state {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.composer h2, .state h2 { margin: 0 0 12px; font-size: 18px; }

textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.composer button[type="submit"] {
  margin-top: 12px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.result {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.result.ok   { background: var(--good-bg); border-color: #a7f3d0; color: var(--good); }
.result.fail { background: var(--bad-bg);  border-color: #fecaca; color: var(--bad); }
.result h3 { margin: 0 0 8px; }
.result ul { margin: 8px 0 0 18px; padding: 0; }
.result .deploy { margin: 12px 0 0; font-weight: 600; }

/* ---- State sidebar ---- */

.state h3 { margin: 16px 0 8px; font-size: 14px; text-transform: uppercase;
            letter-spacing: 0.04em; color: var(--muted); }

details { border-bottom: 1px solid var(--line); padding: 6px 0; }
details summary { cursor: pointer; padding: 4px 0; font-weight: 600; }

.menu-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.menu-list li {
  display: flex; justify-content: space-between;
  padding: 4px 0; border-bottom: 1px dotted var(--line);
}
.menu-list li:last-child { border-bottom: 0; }
.menu-list .name { flex: 1; }
.menu-list .price { color: var(--muted); font-variant-numeric: tabular-nums; }

.hours { list-style: none; margin: 0; padding: 0; }
.hours li {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 14px;
}
.hours .day { color: var(--muted); text-transform: capitalize; }

.kv { display: flex; gap: 12px; margin: 4px 0; font-size: 14px; }
.kv span:first-child { color: var(--muted); width: 64px; }

/* ---- Manual edit form ---- */

.manual {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.manual__head h2 { margin: 0 0 4px; font-size: 18px; }
.manual__head .muted { margin: 0 0 16px; font-size: 14px; }
.manual h3 {
  margin: 24px 0 8px; font-size: 14px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.manual h3:first-of-type { margin-top: 0; }

.manual fieldset.cat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px 12px;
  margin: 8px 0 16px;
}
.manual fieldset.cat legend {
  font-weight: 600; padding: 0 6px; font-size: 14px;
}

/* Fixed layout so columns get the widths we declare and don't reflow as
   soon as any cell's content gets long. Description gets the leftover. */
.menu-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: fixed;
}
.menu-table colgroup .col-photo  { width: 64px; }
.menu-table colgroup .col-item   { width: 30%; }
.menu-table colgroup .col-price  { width: 124px; }
.menu-table colgroup .col-desc   { width: auto; }
.menu-table colgroup .col-remove { width: 42px; }

.menu-table th {
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.menu-table th.num, .menu-table td.num { text-align: right; }
.menu-table th.del, .menu-table td.del { text-align: center; padding-left: 0; padding-right: 0; }
.menu-table td {
  padding: 6px 8px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.menu-table tr:last-child td { border-bottom: 0; }

/* Inline-edit input feel: zero chrome at rest, accent border on focus.
   Looks clean while still being clearly editable on hover. */
.menu-table input[type="text"],
.menu-table input[type="number"],
.menu-table textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  color: inherit;
  line-height: 1.4;
}
.menu-table input[type="text"]:hover:not(:focus),
.menu-table input[type="number"]:hover:not(:focus),
.menu-table textarea:hover:not(:focus) {
  background: rgba(0,0,0,0.025);
}
.menu-table input:focus,
.menu-table textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
  background: #fff;
}

/* Description textarea — multi-line, vertical-resize only, sane min height. */
.menu-table textarea.menu-desc {
  display: block;
  resize: vertical;
  min-height: 44px;
  max-height: 200px;
  font-family: inherit;
}

/* Number column: prefix + tabular alignment so prices line up cleanly.
   Use flex justify-end so overflow goes the natural way (clipped, not
   leaking sideways into the item column). */
.menu-table td.num {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.menu-table td.num .prefix { color: var(--muted); margin-right: 2px; }
.menu-table td.num .price-row {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}
.menu-table td.num input {
  width: 60px;
  padding: 6px 4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* "Add item" row — quietly inviting, not loud. */
.menu-table tr.add-row td {
  background: rgba(232, 116, 59, 0.05);
  border-bottom: 0;
}
.menu-table tr.add-row td:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.menu-table tr.add-row td:last-child  { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.menu-table tr.add-row input::placeholder { color: var(--accent); opacity: 0.55; }

/* ---- Trash icon (delete toggle) ---------------------------------- */
/* Visible checkbox is hidden — we drive a styled SVG icon via :checked. */
.trash {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: background 100ms, color 100ms;
}
.trash input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.trash__icon { display: block; }
.trash:hover { background: rgba(220, 38, 38, 0.08); color: var(--bad); }
.trash:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.trash:has(input:checked) {
  background: rgba(220, 38, 38, 0.12);
  color: var(--bad);
}

/* When a row is marked for deletion, strike + dim it so it's obvious
   which items will go on the next save. */
.menu-table tr:has(.trash input:checked) {
  background: rgba(220, 38, 38, 0.04);
}
.menu-table tr:has(.trash input:checked) input[type="text"],
.menu-table tr:has(.trash input:checked) input[type="number"] {
  text-decoration: line-through;
  color: var(--bad);
  opacity: 0.7;
}

.section-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.section-hint strong { color: var(--fg); }
.section-hint em { font-style: normal; color: var(--accent); }

/* ---- Dietary tag chips (per menu item) ---------------------------------- */

.tag-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.tag-chip {
  font-size: 11px; line-height: 1;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  background: #fff;
}
.tag-chip input { display: none; }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip:has(input:checked) {
  background: rgba(232, 116, 59, 0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Feature/Banner toggles ------------------------------------------- */

.toggle-row {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 4px 0 12px;
  font-size: 14px;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.kv--wide { grid-column: 1 / -1; }

/* ---- Hours-override table --------------------------------------------- */

.overrides-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: fixed;
  margin-top: 4px;
}
.overrides-table colgroup .col-date   { width: 150px; }
.overrides-table colgroup .col-label  { width: 32%; }
.overrides-table colgroup .col-val    { width: auto; }
.overrides-table colgroup .col-remove { width: 48px; }
.overrides-table th {
  text-align: left; padding: 8px 8px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.overrides-table td { padding: 6px 8px; border-bottom: 1px solid rgba(0,0,0,0.04); }
.overrides-table td:last-child { border-bottom: 0; }
.overrides-table input[type="text"],
.overrides-table input[type="date"] {
  width: 100%; padding: 6px 8px; font-size: 14px;
  border: 1px solid transparent; border-radius: 4px;
  background: transparent; font-family: inherit;
}
.overrides-table input:hover:not(:focus) { background: rgba(0,0,0,0.025); }
.overrides-table input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.overrides-table tr.add-row td { background: rgba(232, 116, 59, 0.05); border-bottom: 0; }
.overrides-table tr.add-row input::placeholder { color: var(--accent); opacity: 0.55; }

/* ---- Add new menu category (inline row) ---------------------------------- */

.add-cat-row {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0 16px;
  padding: 8px 12px;
  border: 1px dashed rgba(232, 116, 59, 0.4);
  border-radius: 8px;
  background: rgba(232, 116, 59, 0.04);
}
.add-cat-row input {
  flex: 0 0 240px;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
}
.add-cat-row input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.add-cat-row input::placeholder { color: var(--accent); opacity: 0.55; }
.add-cat-row__hint { font-size: 12px; line-height: 1.3; }

/* ---- Photo slot (per menu item) ---------------------------------------- */

.menu-table th.ph, .menu-table td.ph {
  padding-left: 0;
  text-align: center;
}

.photo-slot {
  width: 56px;
  height: 42px;
  padding: 0;
  border: 1px dashed var(--line);
  background: rgba(0,0,0,0.02);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--muted);
  overflow: hidden;
  transition: border-color 100ms, background 100ms;
}
.photo-slot:hover { border-color: var(--accent); background: rgba(232, 116, 59, 0.05); }
.photo-slot:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.photo-slot__plus  { font-size: 18px; line-height: 1; color: var(--accent); font-weight: 600; }
.photo-slot__label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.photo-slot__thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}


/* ---- Cropper modal ----------------------------------------------------- */

.crop-modal {
  position: fixed; inset: 0;
  background: rgba(20, 16, 12, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.crop-modal[hidden] { display: none; }

.crop-modal__card {
  width: min(680px, 100%);
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
  max-height: 90vh;
}
.crop-modal__head { padding: 16px 20px 8px; }
.crop-modal__head h3 { margin: 0 0 4px; font-size: 16px; }
.crop-modal__head p  { margin: 0; font-size: 13px; }
.crop-modal__stage {
  padding: 8px 20px;
  flex: 1 1 auto;
  min-height: 240px;
  max-height: 60vh;
  background: #1a1a1a;
}
.crop-modal__stage img {
  display: block;
  max-width: 100%;
  /* Cropper.js replaces this element. The max-height keeps the initial
     pre-load image from blowing past the viewport. */
  max-height: 60vh;
}
.crop-modal__foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.btn-primary {
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--accent); border: 0;
  border-radius: 6px; cursor: pointer; font-family: inherit;
}
.btn-primary:hover { background: var(--accent-hi); }
.btn-secondary {
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.btn-secondary:hover { background: rgba(0,0,0,0.04); }
.menu-table input {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
}
.menu-table input:hover:not([readonly]) { background: rgba(0,0,0,0.03); }
.menu-table input:focus { outline: 2px solid var(--accent); border-color: var(--accent);
  background: #fff; }
.menu-table input[readonly] {
  color: var(--fg);
  cursor: default;
}
.menu-table td.num { white-space: nowrap; display: flex; align-items: center; justify-content: flex-end; }
.menu-table .prefix { color: var(--muted); margin-right: 2px; }

.grid {
  display: grid;
  gap: 8px 16px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
}
.manual label.kv {
  display: flex; flex-direction: column; gap: 2px; font-size: 14px; margin: 0;
}
.manual label.kv span:first-child {
  color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em; width: auto;
}
.manual label.kv input {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.manual label.kv input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.manual__save {
  display: flex; align-items: center; gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.manual__save button {
  padding: 10px 18px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--accent); border: 0;
  border-radius: 8px; cursor: pointer;
}
.manual__save button:hover { background: var(--accent-hi); }
.manual__save .muted { font-size: 13px; }
