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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* --- Sidebar --- */

#sidebar {
  width: 380px;
  min-width: 380px;
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1 {
  font-size: 1.5rem;
  color: #4ecca3;
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 0.85rem;
  color: #888;
  margin-top: -8px;
}

/* Mode toggle */

.mode-toggle {
  display: flex;
  gap: 4px;
  background: #16213e;
  border-radius: 8px;
  padding: 4px;
}

.mode-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #888;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: #4ecca3;
  color: #1a1a2e;
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input, .field select {
  padding: 10px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background: #16213e;
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus, .field select:focus {
  border-color: #4ecca3;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Network checkboxes */

.network-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: none;
  letter-spacing: 0;
}

.checkbox-label:hover {
  border-color: #4ecca3;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #4ecca3;
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: none;
}

.checkbox-label:has(input:checked) {
  background: #2a3f5f;
  border-color: #4ecca3;
  color: #fff;
}

.network-hint {
  font-size: 0.7rem;
  color: #555;
  margin-top: 2px;
}

/* Autocomplete */

.ac-wrapper {
  position: relative;
}

.ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #16213e;
  border: 1px solid #4ecca3;
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.ac-item {
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #ccc;
  cursor: pointer;
  border-bottom: 1px solid #2a2a4a;
}

.ac-item:last-child { border-bottom: none; }

.ac-item:hover, .ac-item.ac-active {
  background: #2a3f5f;
  color: #fff;
}

.ac-loader {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-size: 0.8rem;
  color: #4ecca3;
  z-index: 100;
}

.hidden { display: none !important; }

/* Search button */

#search-btn {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #4ecca3;
  color: #1a1a2e;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

#search-btn:hover { background: #3db88f; }
#search-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Status */

#status {
  padding: 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
}

#status.loading {
  background: #16213e;
  color: #4ecca3;
}

#status.error {
  background: #3e1a1a;
  color: #f56565;
}

/* Results */

#results-summary {
  padding: 10px 12px;
  background: #16213e;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #4ecca3;
}

#results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.result-card {
  background: #16213e;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}

.result-card:hover, .result-card.active {
  background: #1e2d50;
  border-color: #4ecca3;
}

.charger-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 2px;
}

.charger-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #4ecca3;
}

.speed-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.speed-ultra {
  background: #4ecca3;
  color: #1a1a2e;
}

.speed-fast {
  background: #2a7a5a;
  color: #e0e0e0;
}

.speed-std {
  background: #2a2a4a;
  color: #bbb;
}

.charger-meta {
  font-size: 0.78rem;
  color: #777;
  margin-bottom: 8px;
}

.operator-link {
  color: #4ecca3;
  text-decoration: none;
}

.operator-link:hover {
  text-decoration: underline;
}

.charger-ports {
  font-size: 0.78rem;
  color: #bbb;
  margin-bottom: 6px;
}

.charger-links {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.directions-link {
  display: inline-block;
  font-size: 0.78rem;
  color: #4ecca3;
  text-decoration: none;
}

.directions-link:hover {
  text-decoration: underline;
}

.charger-plugs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.plug-badge {
  background: #2a2a4a;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: #bbb;
}

.restaurants-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.restaurant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #2a2a4a;
}

.restaurant-item:last-child { border-bottom: none; }

.restaurant-name {
  font-size: 0.85rem;
  color: #e0e0e0;
}

.restaurant-cuisine {
  font-size: 0.72rem;
  color: #777;
}

.restaurant-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.star { color: #f6c23e; }

.review-count {
  font-size: 0.7rem;
  color: #777;
}

/* Route info */

.route-info {
  padding: 10px 12px;
  background: #16213e;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #bbb;
  display: flex;
  gap: 16px;
}

.route-info strong { color: #4ecca3; }

.usage-info {
  text-align: center;
  font-size: 0.75rem;
  color: #666;
  padding: 6px 0;
}

.usage-low {
  color: #e74c3c;
  font-weight: 600;
}

/* --- Map --- */

#map {
  flex: 1;
  z-index: 0;
}

/* Custom marker icons */

.charger-icon {
  background: #4ecca3;
  border: 2px solid #1a1a2e;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.restaurant-icon {
  background: #f6c23e;
  border: 2px solid #1a1a2e;
  border-radius: 50%;
  width: 10px;
  height: 10px;
}

/* Leaflet popup tweaks */

.leaflet-popup-content-wrapper {
  border-radius: 10px;
}

.popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.popup-meta {
  font-size: 0.8rem;
  color: #666;
}

/* Fit all button on map */
.fit-all-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: #1a1a2e;
  color: #4ecca3;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: none;
  -webkit-tap-highlight-color: transparent;
}

.fit-all-btn:hover {
  background: #16213e;
}

/* Mobile elements hidden on desktop */
#mobile-tabs { display: none; }
.filters-toggle { display: none; }

/* Responsive */

@media (max-width: 768px) {
  /* Layout: full-screen panels with tab bar toggle */
  #app {
    flex-direction: column;
    position: relative;
  }

  #sidebar {
    width: 100%;
    min-width: 0;
    max-height: none;
    height: calc(100vh - 52px - env(safe-area-inset-bottom, 0px));
    padding: 16px;
    gap: 12px;
    z-index: 10;
  }

  #map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    height: auto;
    z-index: 5;
  }

  /* Panel toggle via body class */
  body.show-map #sidebar { display: none; }
  body:not(.show-map) #map { visibility: hidden; }
  body.show-map #map { visibility: visible; z-index: 10; }

  /* Mobile tab bar */
  #mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #1a1a2e;
    border-top: 1px solid #2a2a4a;
    z-index: 100;
    gap: 0;
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab.active { color: #4ecca3; }
  .mobile-tab svg { stroke: currentColor; }

  /* Filters toggle button */
  .filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16213e;
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .filters-arrow {
    transition: transform 0.3s;
    font-size: 0.7rem;
  }

  .filters-toggle.open .filters-arrow {
    transform: rotate(180deg);
  }

  /* Collapsible filters */
  .filters {
    display: none !important;
  }

  .filters.expanded {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  /* Touch-friendly targets */
  .checkbox-label {
    padding: 10px 12px;
    font-size: 0.85rem;
    gap: 8px;
  }

  .checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .mode-btn {
    padding: 12px 8px;
    font-size: 0.85rem;
  }

  #search-btn {
    padding: 14px;
    font-size: 1.05rem;
  }

  .field input, .field select {
    padding: 12px;
    font-size: 1rem; /* 16px prevents iOS auto-zoom on focus */
  }

  .ac-item {
    padding: 12px;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .ac-dropdown {
    max-height: 180px;
  }

  /* Typography */
  h1 { font-size: 1.3rem; }
  .tagline { font-size: 0.8rem; margin-top: -6px; }

  /* Result cards */
  .result-card { padding: 16px; }
  .restaurant-item { padding: 10px 0; min-height: 44px; }
  #results-list { padding-bottom: 24px; }

  /* Fit button on mobile */
  .fit-all-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    top: 14px;
    right: 14px;
  }

  /* Push Leaflet controls above tab bar */
  .leaflet-bottom { bottom: 60px !important; }
}
