/* Shri Hari Cafe — shared styles. Mobile-first, big tap targets. */

:root {
  --color-bg: #faf7f2;
  --color-surface: #ffffff;
  --color-border: #e6ded2;
  --color-text: #2a2420;
  --color-muted: #7a6f61;
  --color-primary: #b5451b;
  --color-primary-dark: #8f3614;
  --color-accent: #2f7d4f;
  --color-warn: #c8890a;
  --color-new: #d9534f;
  --radius: 12px;
  --gap: 12px;
}

* {
  box-sizing: border-box;
}

/* Pages that load auth-guard.js (html class="gate") stay hidden until it
   confirms a session — everything else (customer page, login/setup) is
   unaffected. */
html.gate:not(.authed) body {
  visibility: hidden;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 {
  margin: 0 0 4px;
}

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

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gap);
}

header.top {
  background: var(--color-primary);
  color: #fff;
  padding: 16px var(--gap);
  text-align: center;
}

header.top .cafe-name {
  font-size: 1.4rem;
  font-weight: 700;
}

header.top .subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
}

nav.owner-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 8px var(--gap);
  position: sticky;
  top: 0;
  z-index: 20;
}

nav.owner-nav a {
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
}

nav.owner-nav a.active {
  background: var(--color-primary);
  color: #fff;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-border);
  color: var(--color-text);
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

.btn-accent {
  background: var(--color-accent);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 16px 20px;
  font-size: 1.1rem;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
}

input[type="text"],
input[type="tel"],
textarea {
  width: 100%;
  font-size: 1rem;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.field {
  margin-bottom: var(--gap);
}

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

.center {
  text-align: center;
}

.category-title {
  margin-top: 20px;
  margin-bottom: 4px;
  font-size: 1.15rem;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 4px;
}

.category-note {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item-name {
  font-weight: 600;
}

.menu-item-price {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.size-buttons {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-stepper button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.cart-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 12px var(--gap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  border-radius: var(--radius) var(--radius) 0 0;
}

.cart-bar button {
  background: #fff;
  color: var(--color-primary);
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-qr {
  background: #dcecf7;
  color: #1c5e8a;
}

.badge-phone {
  background: #f1e4fb;
  color: #6a2ea6;
}

.badge-unavailable {
  background: #f2d9d5;
  color: var(--color-new);
}

.status-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.status-btn {
  flex: 1;
  min-width: 90px;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--color-border);
  background: #fff;
  color: var(--color-muted);
  cursor: pointer;
}

.status-btn.active.status-received {
  background: #fdecea;
  border-color: var(--color-new);
  color: var(--color-new);
}

.status-btn.active.status-preparing {
  background: #fff4e0;
  border-color: var(--color-warn);
  color: var(--color-warn);
}

.status-btn.active.status-ready {
  background: #e6f4ea;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.order-card {
  position: relative;
  border-left: 6px solid var(--color-border);
}

.order-card.is-new {
  border-left-color: var(--color-new);
  box-shadow: 0 0 0 2px rgba(217, 83, 79, 0.25);
}

.order-card .new-flag {
  display: none;
  background: var(--color-new);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.order-card.is-new .new-flag {
  display: inline-block;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.order-items-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.order-items-list li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.order-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.paid-toggle {
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  border: 2px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.paid-toggle.is-paid {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

table.receipt-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

table.receipt-table th,
table.receipt-table td {
  text-align: left;
  padding: 4px 2px;
  font-size: 0.9rem;
}

table.receipt-table th:last-child,
table.receipt-table td:last-child {
  text-align: right;
}

.receipt-total-row {
  border-top: 1px dashed #999;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 40px 16px;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 8px;
}

.history-row:last-child {
  border-bottom: none;
}

.range-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--gap);
}

.range-btn.active {
  background: var(--color-primary);
  color: #fff;
}

.stat-row {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 130px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 2px;
}

.top-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.top-item-row:last-child {
  border-bottom: none;
}

.top-item-rank {
  font-weight: 800;
  color: var(--color-muted);
  min-width: 26px;
}

.top-item-main {
  flex: 1;
}

.top-item-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.top-item-bar-track {
  background: var(--color-bg);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.top-item-bar {
  background: var(--color-accent);
  height: 100%;
  border-radius: 999px;
}

.top-item-stats {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: var(--gap);
  flex-wrap: wrap;
}

.search-row input[type="text"],
.search-row input[type="date"] {
  flex: 1;
  min-width: 140px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.section-header-row .category-title {
  margin-top: 0;
  flex: 1;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inline-form {
  background: #fbf6ee;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.inline-form .field {
  margin-bottom: 10px;
}

.size-type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.size-type-toggle button {
  flex: 1;
  border-radius: 10px;
  padding: 10px;
  border: 2px solid var(--color-border);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  color: var(--color-muted);
}

.size-type-toggle button.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: #fdf0ea;
}

.price-fields {
  display: flex;
  gap: 8px;
}

.price-fields .field {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.form-actions .btn {
  flex: 1;
}

.btn-danger {
  background: #fdecea;
  color: var(--color-new);
}

.auth-page {
  max-width: 400px;
  margin: 60px auto 0;
  padding: 0 var(--gap);
}

.auth-page h1 {
  text-align: center;
  margin-bottom: 4px;
}

.auth-page .muted {
  text-align: center;
  margin-bottom: 20px;
}

.auth-error {
  background: #fdecea;
  color: var(--color-new);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: var(--gap);
  display: none;
}

.auth-error.show {
  display: block;
}

.logout-btn {
  margin-left: auto;
}

@media print {
  .no-print {
    display: none !important;
  }
}
