/* 臺中市西屯區長安國民小學 3D 校園導覽系統 — 介面與響應式樣式表 */
:root {
  --bg-glass: rgba(15, 23, 42, 0.84);
  --bg-glass-light: rgba(30, 41, 59, 0.78);
  --border-glass: rgba(148, 163, 184, 0.24);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --gold: #facc15;
  --pink-1f: #f4c2d7;
  --yellow-2f: #facc15;
  --green-3f: #d9e89c;
  --blue-4f: #bfe1f6;
  --gray-b1: #cbd5e1;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.42);
  --radius-lg: 14px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background: #0f172a;
  color: var(--text-main);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* 3D 空間浮動標籤層 (自動避讓) */
#labels-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.label-3d {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.38);
  transition: opacity 0.18s ease, background-color 0.2s ease;
  border: 1.5px solid rgba(255,255,255,0.65);
}

.label-3d.building-label {
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
}
.label-3d.building-label:hover,
.label-3d.building-label.selected {
  background: #0284c7;
  border-color: #fde047;
  z-index: 20;
}

.label-3d.landmark-label {
  background: rgba(20, 83, 45, 0.85);
  color: #ecfccb;
  font-size: 11.5px;
  padding: 3px 8px;
}

.label-3d.room-label {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.label-3d.room-label.highlight-pulse {
  outline: 3px solid #ef4444;
  transform: translate(-50%, -115%) scale(1.18);
  z-index: 30;
}

.label-leader-svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

/* 頂部導覽列 */
#topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-title h1 {
  font-size: 15.5px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.brand-title p {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* 搜尋框與自動完成清單 */
.search-wrapper {
  position: relative;
  width: 310px;
  max-width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-lg);
  gap: 8px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13.5px;
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
}

.search-box input::placeholder {
  color: #94a3b8;
}

.search-clear-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}

.search-results.open {
  display: block;
}

.search-item {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s;
}

.search-item:hover {
  background: rgba(56, 189, 248, 0.18);
}

.search-item-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #f8fafc;
}

.search-item-sub {
  font-size: 11.5px;
  color: #94a3b8;
}

.floor-pill {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* 頂部右側快速功能鈕 */
.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-lg);
  transition: all 0.18s;
}

.btn-glass:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent);
}

.btn-glass.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: #7dd3fc;
  color: #fff;
}

/* 左側控制列：樓層切換 + 導覽與路線規劃面板 */
#left-dock {
  position: fixed;
  top: 76px;
  left: 12px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 230px);
  pointer-events: none;
}

#left-dock > * {
  pointer-events: auto;
}

.floor-switcher {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--shadow-lg);
  width: 96px;
}

.floor-switcher-title {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 700;
  margin-bottom: 2px;
}

.floor-btn {
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  transition: all 0.16s;
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
}

.floor-btn:hover {
  transform: translateX(2px);
}

.floor-btn.active {
  outline: 2.5px solid #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}

.floor-btn[data-floor="4"]  { background: var(--blue-4f); color: #0c4a6e; border-color: #0284c7; }
.floor-btn[data-floor="3"]  { background: var(--green-3f); color: #1a2e05; border-color: #65a30d; }
.floor-btn[data-floor="2"]  { background: var(--yellow-2f); color: #422006; border-color: #ca8a04; }
.floor-btn[data-floor="1"]  { background: var(--pink-1f); color: #500724; border-color: #db2777; }
.floor-btn[data-floor="B1"] { background: var(--gray-b1); color: #0f172a; border-color: #475569; }

/* 路線規劃與精選導覽浮動抽屜面板 */
.tool-drawer {
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  width: 320px;
  max-height: 56vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
}

.tool-drawer.open {
  display: block;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-glass);
}

.drawer-header h3 {
  font-size: 14.5px;
  font-weight: 800;
  color: #38bdf8;
}

.close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
}

.route-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-form label {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 700;
}

.route-form select {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-glass);
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.route-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.85);
  border: 1px solid var(--border-glass);
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.route-summary {
  margin-top: 10px;
  padding: 10px;
  background: rgba(30, 41, 59, 0.85);
  border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: none;
}

.route-summary.show {
  display: block;
}

.route-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.stat-box {
  flex: 1;
  background: rgba(15, 23, 42, 0.7);
  padding: 6px 8px;
  border-radius: 8px;
  text-align: center;
}

.stat-val {
  font-size: 16px;
  font-weight: 800;
  color: #38bdf8;
}

.stat-lbl {
  font-size: 11px;
  color: #94a3b8;
}

.turn-list {
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.turn-list li {
  padding: 5px 8px;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 6px;
  border-left: 3px solid #38bdf8;
}

/* 精選導覽卡片 */
.tour-card {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.tour-card:hover {
  border-color: #38bdf8;
}

.tour-card h4 {
  font-size: 13.5px;
  color: #fff;
  margin-bottom: 3px;
}

.tour-card p {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.4;
  margin-bottom: 6px;
}

/* 右側建物詳情與同色樓層配置表面板 */
#right-panel {
  position: fixed;
  top: 76px;
  right: 12px;
  width: 370px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 92px);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 19;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(410px);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

#right-panel.open {
  transform: translateX(0);
}

.panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.panel-category {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}

.panel-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bldg-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.meta-card {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 9px;
  padding: 7px;
  text-align: center;
}

.meta-card .val {
  font-size: 15px;
  font-weight: 800;
  color: #facc15;
}

.meta-card .lbl {
  font-size: 11px;
  color: #94a3b8;
}

.bldg-desc {
  font-size: 13px;
  line-height: 1.55;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.5);
  padding: 10px 12px;
  border-radius: 9px;
  border-left: 3px solid #38bdf8;
}

.sensitive-banner {
  background: rgba(185, 28, 28, 0.25);
  border: 1px solid #ef4444;
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 700;
}

/* 同原配置圖配色的樓層配置表 */
.schedule-section-title {
  font-size: 13px;
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.floor-schedule-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floor-row-card {
  border-radius: 10px;
  padding: 8px 10px;
  border: 2px solid transparent;
  transition: transform 0.15s;
}

.floor-row-card.floor-4  { background: var(--blue-4f); border-color: #0284c7; color: #0c4a6e; }
.floor-row-card.floor-3  { background: var(--green-3f); border-color: #65a30d; color: #1a2e05; }
.floor-row-card.floor-2  { background: var(--yellow-2f); border-color: #ca8a04; color: #422006; }
.floor-row-card.floor-1  { background: var(--pink-1f); border-color: #db2777; color: #500724; }
.floor-row-card.floor-B1 { background: var(--gray-b1); border-color: #475569; color: #0f172a; }

.floor-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}

.floor-rooms-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.room-chip {
  background: rgba(255, 255, 255, 0.78);
  border: 1.5px solid rgba(0, 0, 0, 0.22);
  color: #0f172a;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s;
  flex: 1 1 auto;
  text-align: center;
}

.room-chip:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.room-chip.active-room {
  background: #ef4444;
  color: #fff;
  border-color: #fff;
}

/* 左下角小地圖 (Minimap) */
#minimap-card {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 17;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: var(--shadow-lg);
  width: 215px;
  transition: all 0.2s;
}

#minimap-card.collapsed {
  width: 110px;
}

#minimap-card.collapsed #minimap-canvas-wrap {
  display: none;
}

.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 800;
  color: #cbd5e1;
  margin-bottom: 5px;
  cursor: pointer;
}

#minimap-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 745 / 523;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.25);
  cursor: crosshair;
}

#minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 第一人稱漫遊提示與手機虛擬搖桿 */
#fp-hud {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  color: #e0f2fe;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
}

#fp-hud.active {
  display: flex;
}

/* 虛擬搖桿 (第一人稱或手機版顯示) */
#joystick-zone {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  border: 2px solid rgba(56, 189, 248, 0.55);
  z-index: 22;
  display: none;
  touch-action: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

#joystick-zone.visible {
  display: block;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  margin-left: -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7dd3fc, #0284c7);
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* 導覽播報橫幅 */
#tour-banner {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  border: 1.5px solid #facc15;
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  width: 480px;
  max-width: calc(100vw - 28px);
  box-shadow: var(--shadow-lg);
  display: none;
}

#tour-banner.active {
  display: block;
}

.tour-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.tour-stop-title {
  font-size: 14.5px;
  font-weight: 800;
  color: #facc15;
}

.tour-stop-desc {
  font-size: 12.8px;
  color: #f1f5f9;
  line-height: 1.5;
  margin-bottom: 10px;
}

.tour-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 原圖檢視彈窗 Modal */
#map-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#map-modal.open {
  display: flex;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  max-width: 1100px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 12px;
  overflow: auto;
  text-align: center;
  background: #ffffff;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* 手機版響應式設計 */
@media (max-width: 820px) {
  #topbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .brand-title p {
    display: none;
  }
  .brand-card {
    padding: 6px 10px;
  }
  .brand-title h1 {
    font-size: 13.5px;
  }
  .search-wrapper {
    order: 3;
    width: 100%;
  }
  .top-actions .btn-text {
    display: none;
  }
  #left-dock {
    top: 116px;
  }
  .floor-switcher {
    width: 68px;
    padding: 5px;
  }
  .floor-btn {
    font-size: 11px;
    padding: 5px 4px;
  }
  #right-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 55vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
  }
  #right-panel.open {
    transform: translateY(0);
  }
  #minimap-card {
    width: 140px;
    bottom: 10px;
    left: 10px;
  }
  #joystick-zone {
    display: none;
    bottom: 16px;
    right: 16px;
    width: 96px;
    height: 96px;
  }
  #joystick-zone.visible {
    display: block;
  }
}
