@import url("styles.css");

/* ==========================================================================
   Admin Dashboard — reuses the palette/tokens from styles.css but is laid
   out as a utility dashboard, not a marketing page.
   ========================================================================== */

body.admin-body {
  background: var(--surface-soft);
  min-height: 100vh;
}

/* ---------------------------------- Login gate ---------------------------------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 34px;
  box-shadow: var(--shadow-soft);
}
.login-card .brand-logo { color: var(--ink); justify-content: center; margin-bottom: 6px; }
.login-card h2 { text-align: center; font-size: 1.5rem; margin: 4px 0 26px; }
.login-card .field label { text-align: left; }
.login-card .form-msg { margin-top: 12px; }

/* ---------------------------------- Shell ---------------------------------- */
.admin-shell { display: none; min-height: 100vh; }
.admin-shell.show { display: flex; }

/* Mobile top bar + hamburger — hidden on desktop, shown under 860px. */
.admin-topbar { display: none; }
.admin-nav-backdrop { display: none; }
.admin-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.admin-nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 2px;
  background: var(--bg);
  transition: transform 0.28s var(--ease), opacity 0.2s var(--ease);
}
.admin-nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.admin-nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.admin-nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 28px 20px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.admin-sidebar .brand-logo { font-size: 1.15rem; margin-bottom: 40px; color: var(--bg); }
.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-logo .mark { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.brand-logo img.mark { object-fit: cover; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.admin-nav-spacer { flex: 1; min-height: 20px; }
.admin-nav button {
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: transparent; border: none;
  color: var(--ink-faint);
  font-size: 0.88rem; font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.admin-nav button:hover { background: rgba(251,247,240,0.08); color: var(--bg); }
.admin-nav button.active { background: rgba(219,154,82,0.18); color: var(--accent); font-weight: 600; }
.admin-sidebar .logout-btn {
  margin-top: auto;
  background: transparent; border: 1px solid rgba(251,247,240,0.2);
  color: var(--ink-faint); padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.admin-sidebar .logout-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-sidebar .view-site { font-size: 0.78rem; color: var(--ink-faint); margin-top: 10px; display: block; text-align: center; }
.admin-sidebar .view-site:hover { color: var(--accent); }

.admin-main { flex: 1; padding: 40px 44px; max-width: 1000px; }
.admin-panel { display: none; }
.admin-panel.active { display: block; animation: fade-in 0.3s var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.panel-header { margin-bottom: 30px; }
.panel-header h2 { font-size: 1.9rem; }
.panel-header p { color: var(--ink-soft); margin-top: 8px; font-size: 0.95rem; }

.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}
.admin-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.admin-card .hint { font-size: 0.82rem; color: var(--ink-faint); margin-bottom: 18px; }

.cash-tally-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.cash-tally-header h3 { margin-bottom: 0; }
.cash-tally-chevron { font-size: 0.9rem; color: var(--ink-faint); transition: transform 0.15s ease; }
.cash-tally-chevron.open { transform: rotate(90deg); }
#cashTallyBody.cash-tally-collapsed { display: none; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.check-row input { width: 16px; height: 16px; }
.check-row label { margin: 0; text-transform: none; font-weight: 500; color: var(--ink-soft); font-size: 0.88rem; }

.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 300;
  background: var(--ink); color: var(--bg);
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 0.88rem; box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 10px;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------------------------------- Menu editor ---------------------------------- */
.menu-edit-row {
  display: grid;
  grid-template-columns: 1fr 110px auto auto;
  gap: 12px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.menu-edit-row:last-child { border-bottom: none; }
.menu-edit-row input[type="text"], .menu-edit-row input[type="number"] {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 10px; font-size: 0.9rem; font-family: var(--font-body);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 0.95rem; color: var(--ink-soft);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.icon-btn.hide-toggle.is-hidden { color: var(--accent-dark); border-color: var(--accent); }
.add-item-row { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }

/* ---------------------------------- Inventory ---------------------------------- */
.inventory-row {
  display: grid;
  grid-template-columns: 36px 1fr 130px 100px 200px auto;
  gap: 12px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.inventory-row:last-child { border-bottom: none; }
.inventory-row input[type="text"], .inventory-row input[type="number"], .inventory-row select {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 10px; font-size: 0.9rem; font-family: var(--font-body);
}
.inventory-qty { display: flex; align-items: center; gap: 8px; }
.inventory-status { font-size: 0.85rem; font-weight: 600; min-width: 120px; }
.inventory-status.out { color: #b3261e; }
.inventory-reorder { display: flex; flex-direction: column; gap: 2px; }
.inventory-reorder .icon-btn { width: 32px; height: 18px; font-size: 0.6rem; }
.inventory-reorder .icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ---------------------------------- Route planner ---------------------------------- */
.route-stop {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.route-stop:last-child { border-bottom: none; }
.route-stop-num {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid; place-items: center;
}
.route-stop-num.origin { background: var(--ink); }
.route-stop-body { flex: 1; }
.route-stop-body strong { font-size: 0.95rem; color: var(--ink); }
.route-stop-body .addr { font-size: 0.86rem; color: var(--ink-soft); margin-top: 2px; }
.route-stop-body .meta { font-size: 0.78rem; color: var(--ink-faint); margin-top: 4px; }
.route-stop-leg {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
  cursor: pointer;
}
.route-stop-leg:hover { text-decoration: underline; }
.route-stop.unlocated { opacity: 0.6; }
.route-stop.delivered { opacity: 0.55; }
.route-stop-num.done { background: #2f7d4f; }
/* ---------------------------------- Driver: cash-collect calculator ---------------------------------- */
.cash-collect-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cash-collect-row label { font-size: 0.78rem; color: var(--ink-soft); }
.cash-collect-row input {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--ink);
}
.cash-change-out { font-size: 0.85rem; font-weight: 700; }
.cash-change-out.even { color: #2f7d4f; }
.cash-change-out.short { color: #b3261e; }
.cash-input-error { border-color: #b3261e !important; box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.15); }

/* ---------------------------------- Driver: cash tally ---------------------------------- */
.cash-tally-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.cash-tally-row:last-child { border-bottom: none; }
.cash-tally-row.total { font-size: 1.05rem; font-weight: 700; padding-top: 12px; }
.cash-tally-row.total span { color: var(--ink); }

/* ---------------------------------- Phone order: card entry (Hosted Fields) ---------------------------------- */
.hosted-field {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  height: 44px;
}
.hosted-field.braintree-hosted-fields-focused { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hosted-field.braintree-hosted-fields-invalid { border-color: #b3261e; }

/* ---------------------------------- Analytics ---------------------------------- */
.cap-bar-track {
  width: 100%;
  height: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.cap-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.cap-bar-fill.cap-bar-warn { background: #b6822a; }
.cap-bar-fill.cap-bar-danger { background: #b3261e; }
.cap-bar-label { margin-top: 8px; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.analytics-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.analytics-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--surface-soft);
}
.analytics-stat .label { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.analytics-stat .value { font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.analytics-stat .sub { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }
.analytics-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.analytics-breakdown-row:last-child { border-bottom: none; }
.analytics-breakdown-row .count { color: var(--ink-faint); font-size: 0.82rem; margin-left: 8px; }

@media print {
  .admin-sidebar, #clearCompletedBtn, .btn { display: none !important; }
  .admin-main { margin: 0 !important; padding: 0 !important; }
  .admin-panel:not(.active) { display: none !important; }
  .admin-card { break-inside: avoid; border: 1px solid #ccc !important; }
}

/* ---------------------------------- Take Phone Order (compact POS) ----------------------------------
   This is a phone-in-hand screen — the customer's on the line, so the whole
   panel should read at a glance with no page scroll to start. Bagel list is
   long (10+ items), so it scrolls in its own pane instead of the page; the
   order-details column stays un-capped so the card-payment step (added
   after "Card" is picked) is still free to grow and scroll the page. */
#panel-phone .panel-header { margin-bottom: 14px; }
#panel-phone .panel-header p { font-size: 0.82rem; margin-top: 4px; }
#panel-phone .order-layout { gap: 26px; }

#panel-phone .menu-list {
  gap: 6px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding-right: 6px;
}
#panel-phone .menu-item { padding: 9px 14px; }
#panel-phone .menu-item-info h4 { font-size: 0.9rem; }
#panel-phone .menu-item-info .price { font-size: 0.76rem; margin-top: 2px; }
#panel-phone .qty-stepper { padding: 3px; gap: 8px; }
#panel-phone .qty-stepper button { width: 24px; height: 24px; font-size: 0.95rem; }
#panel-phone .qty-stepper .qty-val { min-width: 16px; font-size: 0.86rem; }

#panel-phone .order-form-card { padding: 20px 22px; }
#panel-phone .order-form-card h3 { font-size: 1.1rem; margin-bottom: 2px; }
#panel-phone .order-form-card .sub { font-size: 0.76rem; margin-bottom: 12px; }
#panel-phone .field { margin-bottom: 9px; }
#panel-phone .field label { font-size: 0.66rem; margin-bottom: 3px; }
#panel-phone .field input[type="text"],
#panel-phone .field input[type="tel"],
#panel-phone .field input[type="date"],
#panel-phone .field select {
  padding: 7px 10px;
  font-size: 0.84rem;
}
#panel-phone .field-note { margin-top: 4px; font-size: 0.7rem; }
#panel-phone .checkbox-row { gap: 6px; }
#panel-phone .field label.checkbox-option { padding: 5px 10px; font-size: 0.75rem; }
#panel-phone .min-order-note { font-size: 0.7rem; margin-bottom: 3px; }
#panel-phone .order-summary-row { font-size: 0.78rem; padding: 2px 0; }
#panel-phone .order-summary-total { font-size: 0.92rem; margin-top: 6px; padding-top: 6px; }

/* ---------------------------------- Cook list ---------------------------------- */
.cook-list-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cook-list-row:last-child { border-bottom: none; }
.cook-list-qty {
  flex-shrink: 0;
  min-width: 46px;
  height: 46px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: grid; place-items: center;
}
.cook-list-row strong { font-size: 1rem; color: var(--ink); }
.status-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--line);
  color: var(--ink-soft);
  vertical-align: middle;
}
.status-tag-ready { background: #dcefe1; color: #2f7d4f; }
.status-tag-preparing { background: #fdedd3; color: #a1650f; }
.status-tag-pending { background: #ede7f6; color: #6a4ea1; }
.status-tag-completed { background: #e4e4e4; color: #6b6b6b; }
.driver-gate-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.driver-gate-btn {
  flex: 1 1 140px;
  padding: 22px 18px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.driver-gate-btn .name { display: block; font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.driver-gate-btn .count { display: block; font-size: 0.8rem; color: var(--ink-faint); margin-top: 4px; }
.driver-gate-btn:hover { border-color: var(--accent); }
.driver-gate-btn.active { border-color: var(--accent); background: #fdf3e7; }
.driver-switch-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.driver-switch-bar .current { font-weight: 700; color: var(--ink); }

/* ---------------------------------- Orders table ---------------------------------- */
.orders-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.orders-toolbar select {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 0.85rem; background: var(--surface);
}
.orders-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
table.orders-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 820px; }
table.orders-table th {
  text-align: left; padding: 12px 14px; background: var(--surface-soft);
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
table.orders-table td { padding: 14px; border-bottom: 1px solid var(--surface-soft); vertical-align: top; color: var(--ink); }
table.orders-table tr:last-child td { border-bottom: none; }
.order-items-cell div { margin-bottom: 2px; }
.status-select {
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface);
}
.status-pending { color: var(--accent-dark); }
.status-preparing { color: #b6822a; }
.status-ready { color: #2f6b2f; }
.status-completed { color: var(--ink-faint); }
.row-actions { display: flex; gap: 8px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }

@media (max-width: 860px) {
  .admin-shell.show { flex-direction: column; }

  /* Compact top bar with the hamburger. */
  .admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px;
    background: var(--ink);
    color: var(--bg);
    position: sticky; top: 0; z-index: 50;
  }
  .admin-topbar .brand-logo { font-size: 1.05rem; margin: 0; color: var(--bg); }
  .admin-nav-toggle { display: flex; }

  /* Sidebar becomes an off-canvas drawer, slid in by the hamburger. */
  .admin-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(80vw, 300px); height: 100vh;
    flex-direction: column; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    z-index: 60;
  }
  .admin-sidebar.open { transform: translateX(0); box-shadow: 0 0 50px -10px rgba(0,0,0,0.55); }
  .admin-nav { flex-direction: column; }
  .admin-nav-spacer { flex: 1; min-height: 20px; }
  .admin-sidebar .logout-btn { margin-top: auto; }

  .admin-nav-backdrop.show {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 55;
  }

  .admin-main { padding: 24px; }
  .field-row { grid-template-columns: 1fr; }
}

/* ---------------------------------- Edit Order modal ---------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow-soft);
}
.modal-box h3 { margin: 0 0 8px; color: var(--ink); }
.modal-box .hint { font-size: 0.82rem; color: var(--ink-faint); margin-bottom: 18px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px;
}
