/* ============================================================
   KIOSK BASE STYLES
   Touch-first: large targets, no hover states, high contrast
   ============================================================ */

:root {
  --header-h: 72px;
  --panel-w: 420px;
  --sidebar-w: 520px;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.18);
  --transition: 0.25s ease;
  --bg: #f4f4f6;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1565C0;
  --accent-light: #e3edf7;
  --danger: #c62828;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* ============================================================
   HEADER
   ============================================================ */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#app-header .logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#app-header .logo span { color: var(--text-muted); font-weight: 400; font-size: 0.8rem; display: block; }

#search-btn {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 40px;
  padding: 0 20px;
  height: 48px;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  max-width: 480px;
}

#search-btn:active { background: var(--accent-light); border-color: var(--accent); }
#search-btn i { font-size: 1.1rem; color: var(--accent); }

#home-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 40px;
  padding: 0 20px;
  height: 48px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), transform 0.1s;
}

#home-btn:active { background: #0d47a1; transform: scale(0.97); }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
#app-body {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
}

/* ============================================================
   SIDEBAR — Category & Store List
   ============================================================ */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Responsive: collapse sidebar on narrow screens */
  min-width: 0;
}

@media (max-width: 900px) {
  :root { --sidebar-w: 380px; }
  #cat-menu { width: 150px; }
}

@media (max-width: 640px) {
  #sidebar { display: none; }
}

#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Two-column menu panel ── */
#menu-panel {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left column — category list */
#cat-menu {
  width: 190px;
  flex-shrink: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--border);
  background: #f8f9fc;
}

.cat-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
  user-select: none;
}

.cat-menu-item:last-child { border-bottom: none; }
.cat-menu-item:active { background: var(--accent-light); }

.cat-menu-item i {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.cat-menu-item .cat-label {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.cat-menu-item .cat-count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--border);
  border-radius: 20px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.cat-menu-item.active {
  background: #fff;
}

.cat-menu-item.active .cat-label { font-weight: 700; }

/* Right column — store submenu */
#store-submenu {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#submenu-heading {
  padding: 10px 14px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
  flex-shrink: 0;
}

#submenu-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Store items in the right submenu column */
.store-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.store-item:last-child { border-bottom: none; }
.store-item:active { background: var(--accent-light); }
.store-item.hidden { display: none; }

.store-item .store-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.store-item .store-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.store-item .store-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.store-item .store-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.store-item.active { background: var(--accent-light); }
.store-item.active .store-name { color: var(--accent); }

#no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

#no-results i { font-size: 2rem; margin-bottom: 10px; }

/* ============================================================
   MAP AREA
   ============================================================ */
#map-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #eef2f7;
  min-width: 0; /* prevent flex child from overflowing */
}

#map-viewport {
  position: absolute;
  inset: 0;
  bottom: 56px; /* leave room for facilities strip */
  overflow: hidden;
  cursor: grab;
}

#map-viewport:active { cursor: grabbing; }

#map-svg-wrapper {
  position: absolute;
  top: 0; left: 0;
  transform-origin: top left;
  will-change: transform;
  transition: none;
}

/* SVG has explicit w/h attributes; JS scales the wrapper */
#map-svg-wrapper svg { display: block; }

.zone {
  stroke: #fff;
  stroke-width: 1.5;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.2s;
  fill: #cccccc;
}

.zone:active { filter: brightness(0.85); }

.zone.dimmed {
  fill: #d8dde5 !important;
  opacity: 0.4;
}

/* Facility icons on map */
.facility-marker {
  cursor: pointer;
}

/* You Are Here */
#you-are-here {
  animation: yah-bounce 2s ease-in-out infinite;
}

@keyframes yah-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* Map tooltip */
#map-tooltip {
  position: absolute;
  background: rgba(26,26,46,0.92);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  z-index: 50;
}

#map-tooltip.visible { opacity: 1; }

/* Map Controls */
#map-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.map-ctrl-btn {
  width: 52px; height: 52px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition), transform 0.1s;
}

.map-ctrl-btn:active { background: var(--accent-light); transform: scale(0.93); }

/* ============================================================
   STORE INFO BAR — compact bottom bar replaces side panel
   ============================================================ */
#info-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 80;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.34,1.28,0.64,1);
  pointer-events: none;
}

#info-bar.open {
  transform: translateY(0);
  pointer-events: all;
}

/* Icon pops in after bar arrives */
#info-bar.open #info-bar-icon {
  animation: infoIconPop 0.42s cubic-bezier(0.34,1.56,0.64,1) 0.22s both;
}

/* Store name slides + fades in */
#info-bar.open #info-bar-name {
  animation: infoTextIn 0.32s ease-out 0.28s both;
}

/* Meta line fades in slightly after */
#info-bar.open #info-bar-meta {
  animation: infoTextIn 0.32s ease-out 0.36s both;
}

/* Colour bar grows from left */
#info-bar.open #info-bar-colour {
  animation: infoColourGrow 0.45s cubic-bezier(0.4,0,0.2,1) 0.1s both;
}

@keyframes infoIconPop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes infoTextIn {
  from { transform: translateX(-14px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes infoColourGrow {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

#info-bar-colour {
  height: 5px;
  width: 100%;
}

#info-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 14px 20px;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.14);
}

#info-bar-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  flex-shrink: 0;
}

#info-bar-text {
  flex: 1;
  min-width: 0;
}

#info-bar-name {
  font-size: 1.35rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#info-bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

#info-bar-unit {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

#info-bar-hours {
  font-size: 0.82rem;
  color: var(--text-muted);
}

#info-bar-hours::before { content: '· '; }

#info-bar-close {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
  transition: background var(--transition);
}

#info-bar-close:active { background: #fde8e8; color: var(--danger); }

/* ============================================================
   ROUTE ANIMATION
   ============================================================ */
#route-path {
  stroke-dasharray: 14 8;
  pointer-events: none;
}

#route-trail   { pointer-events: none; }
#route-dest-dot   { pointer-events: none; }
#route-dest-pulse { pointer-events: none; }

@keyframes route-pulse {
  0%   { r: 6;  opacity: 0.9; }
  100% { r: 18; opacity: 0; }
}

/* Marching-ants: dashes travel forward along the path continuously */
@keyframes route-march {
  to { stroke-dashoffset: -30; }
}

.route-marching {
  animation: route-march 0.5s linear infinite;
}

/* ── Zones: invisible overlays — the real map image is the visual ── */
.zone {
  fill: transparent;
  stroke: transparent;
  cursor: pointer;
  transition: fill 0.15s, stroke 0.15s, filter 0.15s;
}

/* Hover: category-coloured semi-transparent wash */
.zone:hover {
  fill: color-mix(in srgb, var(--zone-colour, #ffffff) 28%, transparent);
  stroke: white;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.6));
}

/* Dimmed (category filter): grey-out non-matching stores */
.zone.dimmed {
  fill: rgba(0,0,0,0.38);
  stroke: transparent;
  filter: none;
}

/* Active / destination: bright category glow */
.zone.active {
  fill: color-mix(in srgb, var(--zone-colour, #FF6B00) 35%, transparent) !important;
  stroke: white !important;
  stroke-width: 3 !important;
  filter: drop-shadow(0 0 8px var(--zone-colour, #FF6B00))
          drop-shadow(0 0 20px var(--zone-colour, #FF6B00)) !important;
  animation: zone-dest-glow 1.4s ease-in-out infinite;
}

@keyframes zone-dest-glow {
  0%, 100% { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--zone-colour,#FF6B00) 70%, transparent)); }
  50%       { filter: drop-shadow(0 0 18px var(--zone-colour, #FF6B00)); }
}

/* ============================================================
   SEARCH OVERLAY
   ============================================================ */
#search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#search-box {
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

#search-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

#search-input {
  flex: 1;
  height: 56px;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0 20px;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}

#search-input:focus { border-color: var(--accent); }

#search-clear, #search-close {
  width: 56px; height: 56px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: background var(--transition);
}

#search-clear:active, #search-close:active { background: #fde8e8; color: var(--danger); }

#search-results {
  flex: 1;
  background: var(--surface);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.search-result-item:active { background: var(--accent-light); }
.search-result-item:last-child { border-bottom: none; }

.search-result-item .result-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-item .result-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
}

.search-result-item .result-cat {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-result-item mark {
  background: #fff3cd;
  border-radius: 3px;
  padding: 0 2px;
}

/* ============================================================
   IDLE OVERLAY
   ============================================================ */
#idle-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

#idle-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

#idle-overlay .idle-icon { font-size: 4rem; margin-bottom: 20px; }
#idle-overlay h2 { font-size: 2rem; font-weight: 800; margin-bottom: 10px; }
#idle-overlay p { font-size: 1.1rem; opacity: 0.85; }
#idle-count { font-size: 3rem; font-weight: 800; color: #FFD700; margin: 16px 0; }

#idle-cancel-btn {
  margin-top: 8px;
  padding: 16px 40px;
  background: #fff;
  color: var(--text);
  border: none;
  border-radius: 40px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}

#idle-cancel-btn:active { transform: scale(0.96); }

/* ============================================================
   FACILITIES STRIP (bottom of map area)
   ============================================================ */
#facilities-strip {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  transition: bottom 0.32s cubic-bezier(0.4,0,0.2,1);
  background: rgba(255,255,255,0.97);
  border-top: 2px solid var(--border);
  display: flex;
  align-items: center;
  overflow-x: auto;
  padding: 0 12px;
  gap: 8px;
  z-index: 40;
  scrollbar-width: none;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

#facilities-strip::-webkit-scrollbar { display: none; }

.facility-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  transition: background var(--transition);
}

.facility-btn i { font-size: 1.1rem; color: var(--accent); }
.facility-btn:active { background: var(--accent-light); }

/* ============================================================
   PLACEHOLDER MAP (shown until SVG is traced)
   ============================================================ */
#map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 16px;
  background: #eef2f7;
}

#map-placeholder i { font-size: 4rem; color: #cbd5e1; }
#map-placeholder h3 { font-size: 1.2rem; font-weight: 700; }
#map-placeholder p { font-size: 0.9rem; max-width: 320px; text-align: center; }

/* ============================================================
   SCROLLBAR STYLE
   ============================================================ */
#submenu-list::-webkit-scrollbar,
#cat-menu::-webkit-scrollbar { width: 4px; }
#submenu-list::-webkit-scrollbar-track,
#cat-menu::-webkit-scrollbar-track { background: transparent; }
#submenu-list::-webkit-scrollbar-thumb,
#cat-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
