/* ═══════════════════════════════════════════════════════════════════
   MapsApi — Google Maps-style UI
   Dark/Light themes with glassmorphism
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Light theme */
  --bg: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-hover: #f1f3f4;
  --bg-active: #e8eaed;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-bg: rgba(26, 115, 232, 0.08);
  --origin: #1a73e8;
  --dest: #ea4335;
  --route: #4285f4;
  --success: #34a853;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg: #1e1e1e;
  --bg-glass: rgba(30, 30, 30, 0.92);
  --bg-hover: #2d2d2d;
  --bg-active: #3c3c3c;
  --text: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #6b6f74;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-bg: rgba(138, 180, 248, 0.12);
}

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

body {
  font-family: var(--font);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  color: var(--text);
  transition: background-color 0.3s ease;
}

/* ─── Map ────────────────────────────────────────────────────────── */
#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.maplibregl-ctrl-attrib { font-size: 10px !important; }

/* ─── Glass Panel ────────────────────────────────────────────────── */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

/* ─── Search Container ───────────────────────────────────────────── */
#search-container {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  z-index: 10;
  overflow: hidden;
}

/* Tabs */
#search-mode-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* Search Input */
.panel-content { padding: 12px; }

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input,
#origin-input,
#dest-input {
  width: 100%;
  padding: 10px 36px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

#origin-input,
#dest-input {
  padding-left: 12px;
}

#search-input:focus,
#origin-input:focus,
#dest-input:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: all 0.2s;
}
.clear-btn:hover { background: var(--bg-active); color: var(--text); }

/* ─── Results List ───────────────────────────────────────────────── */
.results-list {
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.result-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text);
  font-family: var(--font);
}

.result-item:hover { background: var(--bg-hover); }

.result-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.result-text { flex: 1; min-width: 0; }
.result-text .primary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-text .secondary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Directions Panel ───────────────────────────────────────────── */
.directions-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.direction-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.origin-dot { background: var(--origin); border: 2px solid var(--origin); }
.dest-dot { background: var(--dest); border: 2px solid var(--dest); }

.swap-button {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  color: var(--text-secondary);
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.swap-button:hover { background: var(--bg-hover); color: var(--text); }

/* Mode selector */
.mode-selector {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.mode-btn:hover { background: var(--bg-hover); color: var(--text); }
.mode-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* Route Summary */
#route-summary {
  padding: 12px;
  background: var(--accent-bg);
  border-radius: var(--radius);
  margin-top: 8px;
}

.route-summary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.route-duration {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.route-distance {
  font-size: 14px;
  color: var(--text-secondary);
}

.route-via {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Route Steps */
#route-steps {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.step-item {
  display: flex;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  align-items: flex-start;
}

.step-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.step-text { flex: 1; line-height: 1.4; }
.step-dist {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Info Card ──────────────────────────────────────────────────── */
#info-card {
  position: absolute;
  bottom: 24px;
  left: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  z-index: 10;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: all 0.2s;
}
.close-btn:hover { background: var(--bg-active); }

.info-address {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-right: 28px;
}

.info-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.info-field {
  font-size: 12px;
}
.info-field .label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.info-field .value {
  color: var(--text);
  font-weight: 500;
  margin-top: 1px;
}

.info-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.info-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.info-btn:hover { background: var(--accent-bg); }
.info-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.info-btn.primary:hover { background: var(--accent-hover); }

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

.map-ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.map-ctrl-btn:hover {
  background: var(--bg);
  color: var(--text);
  transform: scale(1.05);
}

/* ─── Status Bar ─────────────────────────────────────────────────── */
#status-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 5;
  border: 1px solid var(--border);
  transition: opacity 0.3s;
}

/* ─── Loading Spinner ────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #search-container {
    top: 8px;
    left: 8px;
    width: calc(100vw - 16px);
  }
  
  #info-card {
    bottom: 8px;
    left: 8px;
    width: calc(100vw - 16px);
  }

  #map-controls {
    bottom: 8px;
    right: 8px;
  }
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
.results-list::-webkit-scrollbar,
#route-steps::-webkit-scrollbar {
  width: 4px;
}
.results-list::-webkit-scrollbar-track,
#route-steps::-webkit-scrollbar-track {
  background: transparent;
}
.results-list::-webkit-scrollbar-thumb,
#route-steps::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}
