/* public/styles.css - 護眼暗色模式 (Eye-Friendly Dark Mode) + 四色分類 + 價差紅藍警示與店家庫標章 */
:root {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #1b273d;
  --surface-3: #24334f;
  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --text-muted: #94a3b8;
  --border: #26354d;
  --border-strong: #374b6b;

  --primary: #10b981;
  --primary-dark: #059669;
  --dark-btn: #263654;
  --danger: #f87171;
  --warning: #fbbf24;

  /* 價差透明警示色（高於資料庫＝紅字；低於資料庫＝藍字） */
  --price-higher: #f87171;
  --price-higher-bg: rgba(248, 113, 113, 0.16);
  --price-higher-border: rgba(248, 113, 113, 0.42);
  --price-lower: #38bdf8;
  --price-lower-bg: rgba(56, 189, 248, 0.16);
  --price-lower-border: rgba(56, 189, 248, 0.42);

  /* 四大開團分類色標（暗色柔和護眼版） */
  --cat-bento: #fb923c;
  --cat-bento-bg: rgba(251, 146, 60, 0.16);
  --cat-drink: #38bdf8;
  --cat-drink-bg: rgba(56, 189, 248, 0.16);
  --cat-dessert: #c084fc;
  --cat-dessert-bg: rgba(192, 132, 252, 0.16);
  --cat-other: #34d399;
  --cat-other-bg: rgba(52, 211, 153, 0.16);

  --radius: 14px;
  --shadow: 0 4px 16px rgba(2, 6, 23, 0.4);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 86px;
}

.hidden {
  display: none !important;
}

/* 測試身分切換列 */
.dev-bar {
  background: #070c17;
  color: var(--text);
  padding: 7px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.dev-bar-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

.dev-label {
  color: #fde047;
  font-weight: 600;
}

.dev-chip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}

.dev-chip:hover {
  background: var(--surface-3);
}

.dev-chip.active {
  background: #fde047;
  color: #0f172a;
  border-color: #fde047;
  font-weight: 700;
}

.dev-chip-outline {
  background: transparent;
}

/* 頂部列 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(19, 28, 46, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 680px;
  margin: 0 auto;
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.65);
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0;
}

.user-pill {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  cursor: pointer;
}

/* 主內容區 */
.main-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}

.loading-state, .empty-box {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* 按鈕系統 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.08s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--primary);
  color: #042f2e;
  font-weight: 700;
}

.btn-primary:hover {
  background: #34d399;
}

.btn-dark {
  background: var(--dark-btn);
  color: var(--text-strong);
  border: 1px solid var(--border-strong);
}

.btn-dark:hover {
  background: #31456a;
}

.btn-outline {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-3);
}

.btn-danger-outline {
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

/* 大廳頂部操作與篩選膠囊 */
.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.pill.active {
  background: var(--primary);
  color: #042f2e;
  border-color: var(--primary);
  font-weight: 700;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 卡片與四色分類標籤 */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid #64748b;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s;
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  border-color: var(--border-strong);
  background: #162136;
}

.card.cat-BENTO { border-left-color: var(--cat-bento); }
.card.cat-DRINK { border-left-color: var(--cat-drink); }
.card.cat-DESSERT { border-left-color: var(--cat-dessert); }
.card.cat-OTHER { border-left-color: var(--cat-other); }

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.cat-badge.BENTO { color: var(--cat-bento); background: var(--cat-bento-bg); }
.cat-badge.DRINK { color: var(--cat-drink); background: var(--cat-drink-bg); }
.cat-badge.DESSERT { color: var(--cat-dessert); background: var(--cat-dessert-bg); }
.cat-badge.OTHER { color: var(--cat-other); background: var(--cat-other-bg); }

/* 來自店家資料庫認證小 Logo 標章 */
.store-db-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #2dd4bf;
  background: rgba(20, 184, 166, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.38);
}

.store-db-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* 價差透明標籤（高於資料庫＝紅字；低於資料庫＝藍字） */
.price-text-higher {
  color: var(--price-higher) !important;
  font-weight: 800;
}

.price-text-lower {
  color: var(--price-lower) !important;
  font-weight: 800;
}

.price-diff-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.price-diff-pill.higher {
  color: var(--price-higher);
  background: var(--price-higher-bg);
  border: 1px solid var(--price-higher-border);
}

.price-diff-pill.lower {
  color: var(--price-lower);
  background: var(--price-lower-bg);
  border: 1px solid var(--price-lower-border);
}

.price-diff-pill.same {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.price-diff-pill.custom {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-OPEN { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.status-PENDING_CONFIRM { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-CONFIRMED { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.status-ARRIVED { background: rgba(217, 70, 239, 0.2); color: #e879f9; }
.status-CLOSED { background: rgba(148, 163, 184, 0.16); color: #94a3b8; }
.status-CANCELLED { background: rgba(248, 113, 113, 0.2); color: #f87171; }

.role-host-tag {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
}

.role-joined-tag {
  font-size: 12px;
  font-weight: 700;
  color: #34d399;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 6px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.sub-note-box {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.delivery-tag {
  margin-top: 6px;
  font-size: 12px;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 5px 9px;
  border-radius: 6px;
}

/* 進度條 */
.progress-wrap {
  margin-top: 10px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.progress-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.full {
  background: var(--warning);
}

/* 團購詳情頁 Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0 16px;
}

.step-box {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.step-box.done {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.step-box.current {
  background: var(--primary);
  color: #042f2e;
  border-color: var(--primary);
}

/* 區塊面板 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.panel-highlight {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}

.panel-warn {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.09);
}

.panel-secret {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.09);
}

.secret-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
}

.secret-row a {
  color: #38bdf8;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* 菜單與購物車列 */
.menu-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

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

.menu-item-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-strong);
}

.menu-item-price {
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.cart-divider {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px dashed var(--border-strong);
}

.cart-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.cart-summary-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13px;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 800;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-strong);
}

.agg-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

/* 雙勾勾對帳按鈕 */
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.check-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.check-btn.checked {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

/* 團員訂單列表 */
.order-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.order-card.mine {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.08);
}

.mini-checks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-check {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
}

.mini-check.on {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.mini-check.clickable {
  cursor: pointer;
}

/* AI 菜單照片辨識上傳區 */
.ocr-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(56, 189, 248, 0.1));
  border: 1.5px dashed rgba(56, 189, 248, 0.5);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.ocr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ocr-title {
  font-size: 14px;
  font-weight: 800;
  color: #7dd3fc;
}

.ocr-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.ocr-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.ocr-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

/* 表單控制項 */
.form-group {
  margin-bottom: 14px;
}

.form-box-subtle {
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 5px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text-strong);
}

.input::placeholder, .textarea::placeholder {
  color: #64748b;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.quick-tag {
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.quick-tag.selected {
  background: var(--primary);
  color: #042f2e;
  border-color: var(--primary);
  font-weight: 700;
}

/* 底部導覽列 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(19, 28, 46, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  max-width: 680px;
  margin: 0 auto;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.nav-item.active {
  color: #34d399;
  font-weight: 800;
}

.nav-icon {
  font-size: 18px;
}

/* Modal 視窗 (手機 Bottom Sheet 風格) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 28px;
  color: var(--text);
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
  .modal-panel {
    border-radius: 18px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-strong);
  margin: 0;
}

.close-x {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  max-width: 90vw;
  text-align: center;
}

/* 管理員操控後台專用樣式 */
.admin-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(30, 41, 59, 0.92));
  border: 1px solid rgba(251, 191, 36, 0.42);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 520px) {
  .admin-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}

.admin-stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-strong);
  line-height: 1.2;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.admin-subtabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.admin-subtab {
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.admin-subtab.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: #fbbf24;
  color: #fde68a;
}

.user-admin-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.user-admin-row.banned {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.16);
}

.audit-row {
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.admin-entry-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
