/* Merkez Ankara kurumsal renk paleti (assets/renk-paleti):
   #A68F7A taupe (primary) · #756352 koyu kahve · #D2C2B0 bej/kum ·
   #F4F1EC kırık beyaz (bg) · #E5E3DF açık gri (border) · #292927 antrasit (metin) ·
   #65705A zeytin yeşili (doğa vurgusu) · #3F4B3E koyu yeşil (premium vurgu) */
:root {
  --bg: #f4f1ec;
  --panel: rgba(250, 248, 244, 0.92);
  --panel-border: #e5e3df;
  --text: #292927;
  --text-dim: #756352;
  --accent: #a68f7a;
  --accent-strong: #756352;
  --accent-soft: rgba(166, 143, 122, 0.16);
  --surface: #d2c2b0;
  --nature: #65705a;
  --nature-dark: #3f4b3e;
  --danger: #b4443c;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 12px 40px rgba(41, 41, 39, 0.16);
  --touch: 52px;
}

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

/* Kiosk kilidi: metin seçimi, uzun basış menüsü, tap vurgusu, görsel sürükleme kapalı.
   3B canvas touch-action:none ile OrbitControls pinch/sürüklemeyi alır; UI çift dokunuş zoom'u yok. */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
}

/* Arama / editör kutularına yazı yazılabilsin; bağlam menüsü JS ile yine kapalı */
input, textarea, select {
  -webkit-user-select: text;
  user-select: text;
}

#app {
  position: fixed;
  inset: 0;
  touch-action: none;
}
#app canvas {
  display: block;
  touch-action: none;
}

/* ---------- Üst bar ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(to bottom, rgba(244, 241, 236, 0.92), rgba(244, 241, 236, 0));
  pointer-events: none;
  z-index: 20;
}
#topbar > * { pointer-events: auto; }

/* Gece modunda üst geçiş koyulaşır, metinler açık tona döner */
body.night-mode #topbar {
  background: linear-gradient(to bottom, rgba(5, 8, 15, 0.85), rgba(5, 8, 15, 0));
}
body.night-mode .brand-text h1 { color: #f4f1ec; }
body.night-mode .brand-text span,
body.night-mode #clock { color: #d2c2b0; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  height: 54px;
  width: auto;
  filter: drop-shadow(0 3px 8px rgba(41, 41, 39, 0.28));
}
.brand-text h1 { font-size: 18px; letter-spacing: 2px; font-weight: 700; }
.brand-text span { font-size: 12.5px; color: var(--text-dim); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
#clock {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* ---------- Butonlar ---------- */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill-btn:active { transform: scale(0.97); }
.pill-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.pill-btn.danger { color: var(--danger); border-color: rgba(180, 68, 60, 0.4); }
.pill-btn.danger:active { background: rgba(180, 68, 60, 0.12); }

/* Gece/Gündüz düğmesi: aktif ikona göre görünüm */
#daynight-toggle .icon-moon { display: none; }
body.night-mode #daynight-toggle .icon-moon { display: inline; }
body.night-mode #daynight-toggle .icon-sun { display: none; }
body.night-mode #daynight-toggle {
  background: rgba(63, 75, 62, 0.12);
  border-color: var(--nature-dark);
  color: var(--nature-dark);
}

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(41, 41, 39, 0.04);
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
}

/* ---------- Sol panel ---------- */
#panel-toggle {
  position: fixed;
  top: 88px;
  left: 20px;
  z-index: 14;
  transition: opacity 0.2s;
}
body.panel-open #panel-toggle {
  opacity: 0;
  pointer-events: none;
}

#store-panel {
  position: fixed;
  top: 88px;
  left: 20px;
  bottom: 24px;
  width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 15;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
#store-panel.collapsed {
  transform: translateX(-115%);
  opacity: 0;
  pointer-events: none;
}

.panel-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
}
.panel-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-head-row .search-wrap { flex: 1; }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--touch);
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: rgba(41, 41, 39, 0.05);
  border: 1px solid transparent;
  color: var(--text-dim);
}
.search-wrap:focus-within { border-color: var(--accent); color: var(--accent-strong); }
#store-search {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}
#store-search::placeholder { color: var(--text-dim); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.store-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 10px;
}
.store-list::-webkit-scrollbar { width: 6px; }
.store-list::-webkit-scrollbar-thumb { background: rgba(41,41,39,0.18); border-radius: 3px; }

.store-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s;
}
.store-item:active, .store-item.selected { background: var(--accent-soft); }
.store-avatar {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  color: var(--text);
  background: var(--surface);
}
.store-item.selected .store-avatar { background: var(--accent); color: #fff; }
.store-info { flex: 1; min-width: 0; }
.store-name { font-size: 16px; font-weight: 600; }
.store-cat { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.store-floor {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 4px 8px;
}
.list-empty {
  padding: 30px 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14.5px;
}

/* ---------- Bilgi kartı ---------- */
#info-card {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(480px, calc(100vw - 40px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 18;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#info-card.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(24px);
  pointer-events: none;
}
.card-accent { height: 4px; background: linear-gradient(90deg, var(--accent), var(--surface)); }
.card-body { padding: 18px 20px 20px; }
.card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
#card-name { font-size: 24px; font-weight: 700; }
.card-meta { display: flex; gap: 8px; margin-top: 8px; }
.badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.badge-dim { background: rgba(41, 41, 39, 0.06); color: var(--text-dim); }
.route-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.route-info .dot { color: var(--text-dim); }
.a11y-note {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--nature-dark);
  background: rgba(101, 112, 90, 0.16);
  padding: 4px 10px;
  border-radius: 8px;
  margin-left: 4px;
}
#card-clear-route { width: 100%; justify-content: center; }

/* ---------- Legend ---------- */
#legend {
  position: fixed;
  left: 20px;
  bottom: 28px;
  transition: left 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  z-index: 12;
}
body.panel-open #legend { left: 380px; }
.legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  /* 3B sahnedeki başlangıç işaretçisiyle aynı renk (config.markers.startColor) */
  background: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.25);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(34, 211, 238, 0.08); }
}

/* ---------- FPS sayacı ---------- */
#fps-counter {
  position: fixed;
  left: 20px;
  bottom: 84px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  font-family: Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  z-index: 12;
  pointer-events: none;
}
#fps-counter.good { color: var(--nature-dark); }
#fps-counter.mid { color: #8a6410; }
#fps-counter.bad { color: var(--danger); }
body.editor-mode #fps-counter { bottom: 24px; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  padding: 14px 22px;
  border-radius: var(--radius-md);
  background: rgba(250, 248, 244, 0.97);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 600;
  animation: toast-in 0.25s ease;
}
.toast.warn { border-color: rgba(166, 124, 20, 0.5); color: #7c5c10; }
.toast.error { border-color: rgba(180, 68, 60, 0.5); color: var(--danger); }
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Yükleme ---------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.5s;
}
#loading-overlay.out { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; width: min(420px, 80vw); }
.loading-logo {
  height: 132px;
  width: auto;
  margin-bottom: 20px;
  filter: drop-shadow(0 6px 18px rgba(41, 41, 39, 0.25));
}
.loading-title { font-size: 26px; font-weight: 800; letter-spacing: 6px; }
.loading-sub { color: var(--text-dim); margin: 10px 0 26px; font-size: 15px; }
.progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(41, 41, 39, 0.08);
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--surface));
  transition: width 0.2s;
}
#progress-text { margin-top: 12px; color: var(--text-dim); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- Hata katmanı ---------- */
#error-overlay {
  position: fixed;
  left: 16px;
  bottom: 16px;
  max-width: min(600px, calc(100vw - 32px));
  max-height: 40vh;
  overflow: auto;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(60, 12, 20, 0.95);
  border: 1px solid rgba(255, 84, 112, 0.5);
  color: #ffd7dd;
  font-family: Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  z-index: 90;
}

.hidden { display: none !important; }

/* ---------- Editör paneli ---------- */
body.editor-mode #store-panel,
body.editor-mode #panel-toggle,
body.editor-mode #info-card,
body.editor-mode #legend,
body.editor-mode #view2d-toggle,
body.editor-mode #editor-link,
body.editor-mode #a11y-toggle { display: none !important; }

#editor-panel {
  position: fixed;
  top: 88px;
  right: 20px;
  bottom: 24px;
  width: 344px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  overflow-y: auto;
  z-index: 30;
  font-size: 14px;
}
#editor-panel::-webkit-scrollbar { width: 6px; }
#editor-panel::-webkit-scrollbar-thumb { background: rgba(41,41,39,0.18); border-radius: 3px; }

#editor-panel h3 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-strong);
}
#editor-panel .ed-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
#editor-panel label { font-size: 12.5px; color: var(--text-dim); font-weight: 700; }

.ed-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ed-mode-btn {
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(41, 41, 39, 0.03);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ed-mode-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

#editor-panel select,
#editor-panel input[type="number"],
#editor-panel input[type="text"] {
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #edeae3;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#editor-panel select:focus, #editor-panel input:focus { border-color: var(--accent); }

#editor-panel input[type="color"] {
  height: 40px;
  min-width: 56px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #edeae3;
  cursor: pointer;
}

.ed-row { display: flex; gap: 8px; align-items: center; }
.ed-row > * { flex: 1; }
.ed-row label.inline { display: flex; align-items: center; gap: 6px; flex: none; font-size: 13px; }

.ed-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(41, 41, 39, 0.04);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.ed-btn:active { transform: scale(0.97); }
.ed-btn.primary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.ed-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.ed-btn.danger { color: var(--danger); border-color: rgba(180, 68, 60, 0.4); }

#ed-selection-info {
  font-family: Consolas, monospace;
  font-size: 12px;
  background: #edeae3;
  border-radius: 10px;
  padding: 10px;
  min-height: 52px;
  white-space: pre-wrap;
  color: var(--text-dim);
}
#ed-status {
  font-size: 12.5px;
  color: var(--nature-dark);
  min-height: 18px;
  font-weight: 600;
}
#ed-warnings { font-size: 12px; color: #8a6410; white-space: pre-wrap; }
#ed-counts { font-size: 12.5px; color: var(--text-dim); }

/* Dar ekranlar */
@media (max-width: 860px) {
  #store-panel { width: 290px; }
  body.panel-open #legend { left: 330px; }
  #clock { display: none; }
}
