/**
 * FD Orders styles: mobile-first layout, tab bar, forms, order views and print styles.
 */
:root {
  --yellow: #ffd100;
  --yellow-dark: #e6bc00;
  --black: #111111;
  --gray: #f3f3f1;
  --line: #e2e2e2;
  --text: #1d1d1d;
  --muted: #666666;
  --red: #b00020;
  --green: #2e7d32;
  --blue: #1565c0;
  --tabbar-height: 64px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Poppins", Arial, sans-serif;
  color: var(--text);
  background: var(--gray);
  line-height: 1.45;
  /* room so the bottom tab bar never covers content */
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 16px);
}

a {
  color: var(--black);
}

h1 {
  font-size: 1.5rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 10px;
}

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

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--black);
  color: white;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}

.app-title {
  color: white;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
}

.app-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.app-logo {
  height: 34px;
  width: auto;
}

/* Line icons from js/icons.js: as big as the text, colored like the text */
.icon {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
}

.who {
  color: #bbbbbb;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header .link-btn {
  color: var(--yellow);
}

/* New website order alert: sticks under the header until tapped or dismissed */
.alert-banner {
  position: sticky;
  top: 52px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--yellow);
  padding: 10px 12px 10px 16px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  animation: alert-in 0.35s ease;
}

.alert-banner a {
  flex: 1;
  text-decoration: none;
}

.alert-banner button {
  font: inherit;
  font-size: 1.1rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

@keyframes alert-in {
  from {
    transform: translateY(-100%);
  }
}

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

/* Red count bubble on the Orders tab */
.tabbar a {
  position: relative;
}

.tab-badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 8px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
}

.demo-banner {
  background: #fff3cd;
  text-align: center;
  font-size: 0.85rem;
  padding: 6px 12px;
}

/* ---------- Main area ---------- */
.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  outline: none;
}

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 4px 0 12px;
}

.loading,
.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
}

.back {
  text-decoration: none;
  font-weight: 600;
}

.panel {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.panel p {
  margin: 6px 0;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--yellow);
  font-size: 0.9rem;
  margin-right: 4px;
}

.error {
  background: #fdecea;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -4px 0 0;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid #c9c9c9;
  border-radius: 8px;
  background: white;
  color: var(--text);
}

textarea {
  resize: vertical;
}

/* Even spacing between form fields */
.stack > * + * {
  margin-top: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.two-col input,
.two-col select {
  min-width: 0;
  width: 100%;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  border: 1px solid #c9c9c9;
  border-radius: 10px;
  background: white;
  color: var(--black);
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--yellow);
  border-color: var(--yellow);
}

.btn-primary:active {
  background: var(--yellow-dark);
}

.btn-block {
  width: 100%;
}

.btn-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-row .btn {
  flex: 1 1 auto;
}

.link-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 0;
  color: var(--black);
}

.link-btn.danger {
  color: var(--red);
}

.actions {
  margin-top: 6px;
}

.actions > .link-btn {
  display: block;
  margin: 14px auto 0;
}

/* Big two-way choices: Grocery / Catering, Delivery / Pickup */
.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.choice {
  min-height: 56px;
  font: inherit;
  font-weight: 700;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: white;
  cursor: pointer;
}

.choice.selected {
  border-color: var(--black);
  background: #fffbe6;
}

/* ---------- Orders list ---------- */
.segmented {
  display: flex;
  background: white;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 8px;
}

.segmented a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 4px;
  border-radius: 8px;
}

.segmented a.active {
  background: var(--black);
  color: white;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-list li {
  margin-bottom: 10px;
}

.card {
  display: block;
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.order-card.done {
  opacity: 0.55;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-name {
  font-weight: 600;
}

.order-no {
  color: var(--muted);
  font-size: 0.85rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.badge,
.status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gray);
}

.badge-catering {
  background: #fde7c7;
}

.badge-grocery {
  background: #dcefdc;
}

/* Status colors: easy to scan from across the counter */
.status-new { background: var(--yellow); }
.status-preparing { background: #ffe0b2; }
.status-ready,
.status-out_for_delivery { background: #bbdefb; color: #0d47a1; }
.status-completed { background: #c8e6c9; color: #1b5e20; }
.status-cancelled { background: #eeeeee; color: #777777; text-decoration: line-through; }

.badge-online {
  background: #e3f2fd;
  color: #0d47a1;
}

.online-panel {
  border-left: 6px solid #1565c0;
}

/* Thanksgiving dinner picks: dropdowns in the catering picker, 2 per row */
.choice-picks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
}

.choice-picks:empty {
  display: none;
}

.choice-picks select {
  width: 100%;
  min-width: 0;
}

/* A dropdown still empty after tapping "Add to order" */
.choice-picks select.missing {
  outline: 2px solid #c62828;
}

/* The picks under an item's name (order screen, new order list) */
.line-choices {
  font-size: 0.85rem;
  color: #333333;
}

/* Customer shopped in the store and we deliver the bags */
.badge-instore {
  background: #f3e5f5;
  color: #6a1b9a;
}

/* ---------- Website screen: uploaded flyers ---------- */
.flyer-list {
  margin-top: 16px;
}

.flyer-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  box-shadow: none;
}

.flyer-card img {
  width: 72px;
  height: 92px;
  object-fit: cover;
  object-position: top;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}

.flyer-card .status {
  display: inline-block;
  margin-top: 6px;
}

.flyer-info {
  flex: 1;
  min-width: 0;
}

/* "Feature on homepage" checkbox: box and words on one line */
.feature-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-weight: 600;
  font-size: 0.9rem;
}

.feature-switch input {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
}

.headline-edit {
  margin: 8px 0 4px;
}

.headline-edit summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Deal pictures in the weekly ad's "Homepage deals" panel */
.deal-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.deal-thumbs img {
  height: 64px;
  width: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.small-label {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.small-label input[type="file"] {
  display: block;
  margin: 4px 0;
  max-width: 100%;
}

.headline-edit textarea {
  width: 100%;
  margin: 6px 0;
}

.mini-steps {
  margin: 6px 0 0;
  padding-left: 20px;
}

.mini-steps li {
  margin: 3px 0;
}

/* Register total: the box and its button side by side */
.total-entry {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.total-entry input {
  flex: 1;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.online-panel ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.badge-unpaid {
  background: #fdecea;
  color: var(--red);
}

.pay-state {
  font-weight: 800;
  font-size: 1.05rem;
}

.pay-state.unpaid {
  color: var(--red);
}

.pay-state.paid {
  color: var(--green);
}

.complete-now {
  margin-top: 8px;
}

.reorder-btn {
  margin-top: 6px;
}

/* ---------- Order details ---------- */
.big-when {
  font-size: 1.15rem;
  font-weight: 800;
}

.items-text {
  white-space: pre-wrap;   /* keep the line breaks staff typed */
  margin: 0;
}

.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.line-list > li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.line-list > li:last-child {
  border-bottom: none;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
}

.total-row.grand {
  font-weight: 800;
  font-size: 1.1rem;
  border-top: 2px solid var(--black);
  padding-top: 6px;
}

/* ---------- Grocery checklist ("in the basket") ---------- */
.pick-progress {
  font-weight: 700;
  margin: 0 0 8px;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  background: white;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}

.check-item .box {
  flex: 0 0 28px;            /* fixed 28px wide, never shrinks */
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #999999;
  border-radius: 6px;
  font-weight: 800;
  color: white;
}

/* Checked: green box, item crossed out and faded */
.check-item.picked {
  background: #f1f8f1;
  border-color: #c8e6c9;
}

.check-item.picked .box {
  background: var(--green);
  border-color: var(--green);
}

.check-item.picked .check-text {
  text-decoration: line-through;
  color: var(--muted);
}

/* ---------- New order: customer picking ---------- */
.chosen {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.pick-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.pick-list button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.new-customer {
  margin-top: 12px;
}

.new-customer summary {
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0;
}

/* ---------- New order: catering picker ---------- */
.picker {
  display: grid;
  gap: 10px;
  background: var(--gray);
  border-radius: 10px;
  padding: 12px;
}

.line-list.editable > li {
  display: block;
}

.line-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
}

.line-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}

.line-controls .link-btn {
  margin-left: auto;
}

.qty {
  width: 44px;
  height: 44px;
  font: inherit;
  font-weight: 800;
  font-size: 1.2rem;
  border: 1px solid #c9c9c9;
  border-radius: 8px;
  background: var(--gray);
  cursor: pointer;
}

.qty-input {
  width: 70px;
  text-align: center;
  margin: 0;
}

.line-note {
  font-size: 0.9rem;
  min-height: 38px;
  padding: 6px 10px;
}

.totals {
  background: var(--gray);
  border-radius: 10px;
  padding: 10px 14px;
}

.login {
  max-width: 400px;
  margin: 40px auto;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: white;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);   /* stays above the iPhone home bar */
}

.tabbar a {
  flex: 1;
  height: var(--tabbar-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

.tabbar a span {
  font-size: 1.3rem;
  line-height: 1;
}

.tabbar a.active {
  color: var(--black);
}

.tabbar .tab-new span {
  background: var(--yellow);
  color: var(--black);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* ---------- Toast (small pop-up message) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);   /* centers it */
  z-index: 20;
  background: var(--black);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* ---------- Customer copy (catering): never shown on screen ---------- */
.customer-copy {
  display: none;
}

.cc-head {
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 3px solid var(--black);
  padding-bottom: 12px;
}

.cc-logo {
  width: 150px;
  height: auto;
  border-radius: 6px;
}

.cc-store {
  font-size: 10.5pt;
  line-height: 1.5;
}

.cc-title {
  font-size: 18pt;
  margin: 16px 0 0;
}

.cc-meta {
  color: #444444;
  margin: 2px 0 14px;
}

.cc-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.cc-two h3 {
  font-size: 10pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  color: #444444;
}

.cc-two p {
  margin: 0;
}

.cc-items {
  width: 100%;
  border-collapse: collapse;   /* single lines between cells instead of double */
  margin-top: 16px;
}

.cc-items th,
.cc-items td {
  text-align: left;
  padding: 6px 0;
  border-bottom: 1px solid #cccccc;
  vertical-align: top;
}

.cc-items th:last-child,
.cc-items td:last-child {
  text-align: right;
  white-space: nowrap;
}

.cc-totals {
  margin: 10px 0 0 auto;   /* pushed to the right side of the page */
  max-width: 320px;
}

.cc-notes {
  margin-top: 14px;
}

.cc-policy {
  margin-top: 18px;
  font-size: 9.5pt;
  border: 1px solid #999999;
  border-radius: 6px;
  padding: 8px 12px;
}

.cc-policy ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.cc-thanks {
  text-align: center;
  font-weight: 700;
  margin-top: 18px;
}

@media print {
  .app-header, .demo-banner, .tabbar, .toast, .no-print, .back {
    display: none !important;
  }

  body {
    background: white;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 1px solid #999999;
    break-inside: avoid;
  }

  body[data-print="customer"] .print-area {
    display: none !important;
  }

  body[data-print="customer"] .customer-copy {
    display: block;
  }

  /* Ask the printer to keep the logo's dark background instead of dropping it */
  .cc-logo {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
