/* style.css — 手機優先 RWD */

:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-secondary: #666666;
  --empty-bg: #f0f0f0;
  --empty-text: #999999;
  --border: #e0e0e0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px;
  text-align: center;
}

.header h1 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.35);
}

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

.date-display {
  font-size: 1.1rem;
  font-weight: 500;
}

.date-display.past {
  opacity: 0.65;
}

.badge {
  font-size: 0.8rem;
  margin-left: 4px;
}

.badge-past {
  opacity: 0.7;
}

.updated-time {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-top: 4px;
}

/* ── Offline banner ── */
.offline-banner {
  background: #ffc107;
  color: #333;
  text-align: center;
  padding: 8px;
  font-size: 0.85rem;
}

.update-banner {
  background: #1a73e8;
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.update-banner[hidden] { display: none; }
.update-banner button {
  background: #fff;
  color: #1a73e8;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Loading ── */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Booth list ── */
.booth-list {
  flex: 1;
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.booth-card {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  overflow: hidden;
}

.booth-card.booth-empty {
  background: var(--empty-bg);
}

.booth-card.booth-clickable {
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.booth-card.booth-clickable:hover {
  background-color: #f0f4ff;
  box-shadow: 0 2px 8px rgba(21,101,192,0.15);
}
.booth-card.booth-clickable.selected {
  border: 2px solid var(--primary);
  background-color: #e8eeff;
}

.booth-no {
  width: 60px;
  min-width: 60px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  padding: 14px 0;
  border-right: 2px solid var(--primary-light);
}

.booth-empty .booth-no {
  color: var(--empty-text);
  border-right-color: var(--border);
}

.booth-info {
  padding: 12px 14px;
  flex: 1;
  min-width: 0;
}

.vendor-name {
  font-size: 1rem;
  font-weight: 600;
}

.booth-empty .vendor-name {
  color: var(--empty-text);
  font-weight: 400;
}

.vendor-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.empty-msg {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 16px;
  font-size: 1rem;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

/* ── View tabs ── */
.view-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.tab-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.tab-btn.active {
  background: rgba(255,255,255,0.9);
  color: var(--primary);
  font-weight: 700;
}

/* ── Booth map ── */
.booth-map {
  flex: 1;
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* 外牆容器 */
.floor-plan-wrapper {
  background: #f4f1eb;
  border: 3px solid #8a8278;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
  position: relative;
}

.floor-grid {
  display: grid;
  /* col1=外部標籤(7-11/喜憨兒), col2=攤位9欄, col3~5=主攤位, col6=右側地標 */
  grid-template-columns: 44px 60px 1fr 1fr 1fr 52px;
  /* row1=電梯, row2=攤位列A, row3=步行走廊, row4=攤位列B,
     row5=實體牆, row6=攤位列C, row7=步行走廊, row8=攤位列D, row9=底部 */
  grid-template-rows: 44px 90px 16px 90px 14px 90px 16px 90px 44px;
  gap: 6px;
}

/* 橫向實體牆分隔線 */
.wall-h {
  grid-column: 1 / 7;
  background: #8a8278;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #f4f1eb;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* 地標 */
.lm {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #999;
  background: #efefef;
  border: 1.5px dashed #ccc;
  text-align: center;
  line-height: 1.3;
}
.lm-elevator { font-size: 0.85rem; color: #666; background: #e4e4e4; }
.lm-side { writing-mode: vertical-rl; font-size: 0.7rem; }

/* 攤位卡片 */
.mc-card {
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  overflow: hidden;
  position: relative;
}
.mc-card:active { transform: scale(0.97); }
.mc-occupied { background: #e8f5e9; border-color: #4caf50; }
.mc-vacant   { background: #f5f5f5; border-color: #e0e0e0; }
.mc-card.mc-selected { box-shadow: 0 0 0 3px var(--primary); transform: translateY(-2px); }

/* 類別背景色 — 6 色高對比方案，互不相似 */
.mc-cat-food    { background: #FFF3E0; border-color: #F57C00; } /* 橘紅 — 食品/餐飲 */
.mc-cat-daily   { background: #E3F2FD; border-color: #1565C0; } /* 深藍 — 生活/百貨 */
.mc-cat-clothes { background: #F3E5F5; border-color: #6A1B9A; } /* 紫色 — 服飾/織品 */
.mc-cat-fresh   { background: #E0F2F1; border-color: #00796B; } /* 青綠 — 生鮮/農產 */
.mc-cat-shoes   { background: #EFEBE9; border-color: #5D4037; } /* 棕色 — 鞋包/皮件 */
.mc-cat-other   { background: #F5F5F5; border-color: #757575; } /* 灰色 — 其他 */

/* 右上角類別角標 */
.mc-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mc-cat-food    .mc-badge { background: #F57C00; }
.mc-cat-daily   .mc-badge { background: #1565C0; }
.mc-cat-clothes .mc-badge { background: #6A1B9A; }
.mc-cat-fresh   .mc-badge { background: #00796B; }
.mc-cat-shoes   .mc-badge { background: #5D4037; }
.mc-cat-other   .mc-badge { background: #757575; }

/* 類別圖例 */
.cat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 4px 12px;
  font-size: 0.72rem;
  color: #666;
}
.cat-legend-item { display: flex; align-items: center; gap: 4px; }
.cat-legend-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.mc-no   { font-size: 1.1rem; font-weight: 700; color: #333; line-height: 1.2; }
.mc-name { font-size: 0.8rem; color: #555; overflow: hidden; text-overflow: ellipsis; width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; max-height: 2.7em; word-break: break-all; }
.mc-empty-text { color: #bbb; }
.mc-tag  { font-size: 0.6rem; color: #888; background: #fff; padding: 1px 5px; border-radius: 999px; border: 1px solid #ddd; line-height: 1.2; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* 地圖詳情 */
.map-disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: #aaa;
  margin: -4px 0 10px;
  letter-spacing: 0.02em;
}
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
}
.detail-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}
.detail-row {
  display: flex;
  gap: 10px;
  font-size: 0.875rem;
}
.detail-row span { color: var(--text-secondary); min-width: 56px; }
.detail-row strong { color: var(--text); }
.detail-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 8px 0;
}

/* ── 未來擺攤排程 ── */
.detail-schedule {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.sched-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}
.sched-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid #f0f0f0;
}
.sched-item:last-child { border-bottom: none; }
.sched-date { color: var(--text); }
.sched-booth {
  font-weight: 700;
  color: var(--primary);
  min-width: 32px;
  text-align: right;
}
.sched-none {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── List filter bar ── */
.list-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.list-filter-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-chip.active {
  background: var(--chip-color, var(--primary));
  border-color: var(--chip-color, var(--primary));
  color: #fff;
}
.hide-empty-btn {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.hide-empty-btn.active { background: #fff3e0; border-color: #f57c00; color: #e65100; }

/* ── List card enhancements ── */
.list-cat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.booth-future-hint {
  padding: 0 12px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  min-width: 46px;
  line-height: 1.3;
  flex-shrink: 0;
}
.booth-future-hint strong { color: var(--primary); font-size: 1rem; display: block; }
.booth-future-hint.last-time { color: #ccc; font-size: 0.68rem; }

/* ── Search view ── */
.booth-search {
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.search-bar-wrapper { margin-bottom: 12px; }
.search-input {
  width: 100%;
  padding: 10px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  outline: none;
  background: var(--card-bg);
  color: var(--text);
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }
.search-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 24px 0;
}
.search-results { display: flex; flex-direction: column; gap: 10px; }
.search-result-card {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.src-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.src-cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.src-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.src-product { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Desktop ── */
@media (min-width: 768px) {
  .header h1 { font-size: 1.5rem; }
  .booth-list { padding: 20px; }
  .booth-map  { padding: 20px; }
  .booth-card { margin-bottom: 10px; }
  .booth-no { width: 72px; min-width: 72px; font-size: 1.25rem; }
  .floor-grid {
    grid-template-columns: 50px 72px 1fr 1fr 1fr 60px;
    grid-template-rows: 52px 100px 18px 100px 16px 100px 18px 100px 52px;
    gap: 8px;
  }
  .mc-no { font-size: 1.3rem; }
  .mc-name { font-size: 0.85rem; }
}

/* ── Small phones (≤ 400px) ── */
@media (max-width: 400px) {
  .header h1 { font-size: 1.05rem; margin-bottom: 6px; }
  .date-display { font-size: 0.95rem; }
  .badge { font-size: 0.72rem; }
  .date-nav { gap: 6px; }
  .nav-btn { width: 30px; height: 30px; font-size: 1rem; }

  .booth-map { padding: 8px; }
  .floor-grid {
    grid-template-columns: 32px 44px 1fr 1fr 1fr 40px;
    grid-template-rows: 38px 82px 14px 82px 12px 82px 14px 82px 38px;
    gap: 5px;
  }
  .lm { font-size: 0.65rem; }
  .lm-side { font-size: 0.6rem; }
  .mc-card { padding: 5px 3px; gap: 2px; }
  .mc-no { font-size: 0.95rem; }
  .mc-name { font-size: 0.65rem; -webkit-line-clamp: 1; }
  .mc-tag { display: none; }
}
