/* Gas.rimwi.es — Light mode, mobile first */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg2: #f8f9fa;
  --bg3: #e9ecef;
  --text: #212529;
  --text2: #6c757d;
  --accent: #0d6efd;
  --green: #198754;
  --orange: #fd7e14;
  --red: #dc3545;
  --border: rgba(0,0,0,0.1);
  --shadow: 0 2px 12px rgba(0,0,0,0.12);
  --radius: 12px;
  --header-h: 52px;
  --panel-h: 240px;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* HEADER */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}

#header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#header .controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

#header label {
  font-size: 0.75rem;
  color: var(--text2);
  white-space: nowrap;
}

select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

select:focus { border-color: var(--accent); }

#btn-locate {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
#btn-locate:hover { opacity: 0.85; }

/* MAP */
#map {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: var(--panel-h);
  z-index: 1;
}

/* PANEL */
#panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--panel-h);
  z-index: 1000;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#panel-header {
  display: flex;
  align-items: center;
  padding: 8px 12px 6px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#panel-title {
  font-size: 0.8rem;
  color: var(--text2);
}

#station-list {
  overflow-y: auto;
  flex: 1;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}

.station-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.station-item:hover, .station-item.active {
  background: var(--bg3);
}

.station-rank {
  font-size: 0.7rem;
  color: var(--text2);
  min-width: 18px;
  text-align: right;
}

.station-price-badge {
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 58px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--bg3);
}

.station-info {
  flex: 1;
  min-width: 0;
}

.station-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-addr {
  font-size: 0.72rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-dist {
  font-size: 0.72rem;
  color: var(--text2);
  white-space: nowrap;
}

/* Loading */
#loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.3s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--text2); font-size: 0.9rem; }

/* Leaflet popup */
.popup-price { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.popup-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.popup-addr { font-size: 0.78rem; color: var(--text2); }
.popup-dist { font-size: 0.75rem; color: var(--text2); margin-top: 4px; }

/* Toast */
#toast {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--text);
  color: var(--bg);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* Marker */
.gas-marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: pointer;
}

/* Desktop */
@media (min-width: 768px) {
  :root { --panel-w: 320px; --panel-h: 0px; }
  #map { right: var(--panel-w); bottom: 0; }
  #panel {
    top: var(--header-h); bottom: 0;
    left: auto; width: var(--panel-w);
    height: auto;
    border-top: none;
    border-left: 1px solid var(--border);
  }
}
