/* ============================================================
   SUGAM — map.css
   Page 2: Map & Indoor Navigation
   ============================================================ */

/* ── Map Page Layout ─────────────────────────────────────── */
.map-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ── Top Bar (Blue) ──────────────────────────────────────── */
.map-topbar {
  background: var(--blue);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}
.map-back-btn {
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
  line-height: 1;
}
.map-back-btn:hover { background: rgba(255,255,255,0.15); }

.map-search-wrap {
  flex: 1;
  position: relative;
}
.map-search-input {
  width: 100%;
  height: 36px;
  border: none;
  border-radius: 20px;
  padding: 0 14px 0 36px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  background: var(--white);
  color: var(--text);
}
.map-search-input::placeholder { color: #AAAAAA; }
.map-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  font-size: 15px;
  pointer-events: none;
}
.map-filter-btn {
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}
.map-filter-btn:hover { background: rgba(255,255,255,0.15); }

/* ── Search History Panel ────────────────────────────────── */
.search-history-panel {
  position: absolute;
  top: 56px;
  left: 0; right: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 14px 14px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  display: none;
}
.search-history-panel.visible { display: block; }

.hist-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 6px;
  border-bottom: 0.5px solid var(--border);
}
.hist-panel-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.hist-panel-clear {
  font-size: 12px;
  color: var(--red);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  padding: 2px 0;
}
.hist-panel-clear:hover { text-decoration: underline; }

.hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 0.5px solid #F5F5F5;
  cursor: pointer;
  transition: background 0.15s;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: #F9F9F9; }
.hist-item-icon { font-size: 16px; color: var(--red); flex-shrink: 0; }
.hist-item-icon.old { color: #BBBBBB; }
.hist-item-texts { flex: 1; min-width: 0; }
.hist-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-item-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.hist-item-time { font-size: 12px; color: #BBBBBB; flex-shrink: 0; }
.hist-item-dismiss {
  font-size: 14px;
  color: #CCCCCC;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.hist-item-dismiss:hover { color: var(--red); }

.hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 8px;
  color: var(--muted);
}
.hist-empty i { font-size: 36px; }
.hist-empty p { font-size: 13px; }

/* ── Filter Panel ────────────────────────────────────────── */
.filter-panel {
  position: absolute;
  top: 56px;
  right: 0;
  width: 220px;
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: 0 0 12px 12px;
  padding: 12px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  display: none;
}
.filter-panel.visible { display: block; }
.filter-title { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip.active {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red-dark);
}

/* ── Autocomplete Dropdown ───────────────────────────────── */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: 0 0 10px 10px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 60;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: none;
}
.autocomplete-list.visible { display: block; }
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 0.5px solid #F5F5F5;
  transition: background 0.15s;
}
.autocomplete-item:hover { background: var(--gray-light); }
.autocomplete-item i { font-size: 16px; color: var(--red); }
.autocomplete-item-name { font-size: 14px; color: var(--text); }
.autocomplete-item-meta { font-size: 11px; color: var(--muted); }

/* ── Main Layout (sidebar + map) ─────────────────────────── */
.map-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Left Sidebar ────────────────────────────────────────── */
.map-sidebar {
  width: 260px;
  background: var(--white);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 5;
}
.sidebar-section {
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--border);
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Filter chips in sidebar */
.sidebar-chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* Destination card in sidebar */
.dest-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--red-light);
  border-radius: 8px;
  padding: 10px 12px;
}
.dest-card i { font-size: 18px; color: var(--red); }
.dest-card-name { font-size: 14px; font-weight: 500; color: var(--text); }
.dest-card-meta { font-size: 11px; color: var(--muted); }

/* ── Map Canvas Area ─────────────────────────────────────── */
.map-canvas-wrap {
  flex: 1;
  position: relative;
  background: #E8F4E8;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ── Floor Selector (right edge of map) ──────────────────── */
.floor-selector {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}
.floor-btn {
  width: 32px;
  height: 26px;
  background: var(--white);
  border: 0.5px solid #CCCCCC;
  border-radius: 5px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: var(--font);
}
.floor-btn:hover { background: var(--red-light); border-color: var(--red); }
.floor-btn.active {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
  font-weight: 600;
}

/* ── Directions Panel (bottom sheet) ─────────────────────── */
.directions-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  max-height: 42vh;
  overflow-y: auto;
  z-index: 20;
  transform: translateY(100%);
  transition: transform 0.35s ease;
}
.directions-panel.open { transform: translateY(0); }

.dir-panel-drag {
  width: 36px;
  height: 4px;
  background: #DDDDDD;
  border-radius: 2px;
  margin: 10px auto 0;
}
.dir-panel-body { padding: 12px 16px 20px; }
.dir-dest-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.dir-dist-time {
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dir-steps { display: flex; flex-direction: column; gap: 0; }
.dir-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 0.5px solid #F5F5F5;
}
.dir-step:last-child { border-bottom: none; }
.dir-step-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dir-step-icon i { font-size: 15px; color: var(--blue); }
.dir-step-icon.arrive { background: var(--red-light); }
.dir-step-icon.arrive i { color: var(--red); }
.dir-step-text { font-size: 13px; color: var(--text); }

.btn-start-nav {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  background: var(--red);
  color: var(--white);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
  font-family: var(--font);
}
.btn-start-nav:hover { background: var(--red-dark); }

/* Leaflet overrides */
.leaflet-control-zoom { border: none !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; }
.leaflet-control-zoom a { color: var(--text) !important; font-size: 16px !important; }

/* Pulsing user location marker */
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
.user-marker-pulse {
  width: 14px; height: 14px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--white);
  position: relative;
}
.user-marker-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.4;
  animation: pulse 1.5s infinite;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .map-sidebar { display: none; }
  .map-page { height: calc(100vh - 56px); }
}
