/* ====== TANKITO — Design v0.7 (logo Space Grotesk) ====== */

:root {
  /* Palette */
  --bg-deep: #0a0e14;
  --bg-base: #11161f;
  --bg-elevated: #1a212e;
  --bg-glass: rgba(17, 22, 31, 0.78);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-soft: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --brand: #00d97e;
  --brand-soft: rgba(0, 217, 126, 0.15);
  --brand-glow: rgba(0, 217, 126, 0.35);

  --warn: #fbbf24;
  --danger: #f87171;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 4px 24px rgba(0, 217, 126, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ====== HEADER ====== */
header {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  z-index: 1000;
  position: relative;
}

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

/* === Brand (Space Grotesk) === */
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.25rem;
  filter: drop-shadow(0 0 10px var(--brand-glow));
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: 'Space Grotesk', sans-serif;
  display: inline-flex;
  align-items: baseline;
}

.brand-prefix {
  color: var(--text-primary);
}

.brand-suffix {
  color: var(--brand);
}

/* === Search === */
.search-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0.6;
}

#search-input {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 10px 16px 10px 38px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

#search-input:focus {
  border-color: var(--brand);
  background: var(--bg-base);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

#search-input::placeholder {
  color: var(--text-tertiary);
}

#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
}

.search-result {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

.search-result:last-child { border-bottom: none; }

.search-result:hover {
  background: rgba(255, 255, 255, 0.04);
}

.search-result .result-main {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.search-result .result-sub {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.search-loading,
.search-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* === Controls row === */
.controls-row {
  justify-content: space-between;
  gap: 12px;
}

/* === View toggle (chips) === */
.view-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chip:hover:not(.active) {
  color: var(--text-primary);
}

.chip.active {
  background: var(--bg-base);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.chip-icon { font-size: 0.85rem; }

.chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--text-tertiary);
  color: var(--bg-deep);
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 2px;
}

.chip.active .chip-badge {
  background: var(--brand);
  color: var(--bg-deep);
}

/* === Fuel selector === */
.fuel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#fuel-selector {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 7px 28px 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

#fuel-selector:hover {
  border-color: var(--border-strong);
}

.fuel-arrow {
  position: absolute;
  right: 10px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  pointer-events: none;
}

/* === Status bar === */
.status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

#status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ====== MAIN ====== */
main {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map, #list-view {
  position: absolute;
  inset: 0;
}

#map {
  background: var(--bg-deep);
}

#list-view {
  overflow-y: auto;
  padding: 12px 16px 80px;
  background: var(--bg-deep);
}

.hidden { display: none !important; }

/* ====== FLOATING LOCATE BUTTON ====== */
#btn-locate {
  position: absolute;
  right: 16px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  z-index: 500;
}

#btn-locate svg {
  width: 22px;
  height: 22px;
}

#btn-locate:hover {
  background: var(--brand);
  color: var(--bg-deep);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
}

#btn-locate:active {
  transform: translateY(0);
}

#btn-locate.searching {
  opacity: 0.6;
  cursor: wait;
}

#btn-locate.searching svg {
  animation: spin 1s linear infinite;
}

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

/* ====== LIST VIEW ====== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.list-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-soft);
  transform: translateY(-1px);
}

.list-item .rank {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
}

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

.list-item .name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.list-item .address {
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item .distance {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.list-item .price-and-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-item .price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.list-item .nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  flex-shrink: 0;
}

.list-item .nav-btn:hover {
  background: var(--brand);
  color: var(--bg-deep);
  border-color: var(--brand);
}

.list-item .fav-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  filter: grayscale(100%);
  opacity: 0.4;
  transition: var(--transition);
}

.list-item .fav-btn:hover {
  transform: scale(1.15);
  opacity: 0.8;
}

.list-item .fav-btn.active {
  filter: none;
  opacity: 1;
  color: var(--warn);
}

.empty-favs {
  text-align: center;
  color: var(--text-secondary);
  padding: 80px 24px;
  line-height: 1.6;
}

.empty-favs .emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ====== LEAFLET POPUP ====== */
.leaflet-popup-content-wrapper {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
  padding: 4px;
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-family: 'Inter', sans-serif;
}

.leaflet-popup-tip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
}

.leaflet-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 18px !important;
  padding: 6px 8px !important;
}

.station-popup {
  min-width: 220px;
}

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

.popup-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  flex: 1;
}

.station-popup .fav-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  filter: grayscale(100%);
  opacity: 0.4;
  transition: var(--transition);
}

.station-popup .fav-btn:hover {
  transform: scale(1.15);
  opacity: 0.8;
}

.station-popup .fav-btn.active {
  filter: none;
  opacity: 1;
  color: var(--warn);
}

.station-popup .address {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.station-popup .prices {
  display: grid;
  gap: 4px;
  font-size: 0.83rem;
  margin-bottom: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.station-popup .price-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.station-popup .price-row.active {
  color: var(--text-primary);
  font-weight: 600;
}

.station-popup .price-value {
  font-weight: 700;
}

.station-popup .price-row.active .price-value {
  color: var(--brand);
}

.station-popup .navigate-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--brand);
  color: var(--bg-deep);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.station-popup .navigate-btn:hover {
  background: #00f08c;
  box-shadow: var(--shadow-brand);
}

/* ====== LEAFLET MARKERS / CONTAINER ====== */
.leaflet-container {
  background: var(--bg-deep) !important;
  font-family: 'Inter', sans-serif !important;
}

.leaflet-control-attribution {
  background: rgba(10, 14, 20, 0.7) !important;
  color: var(--text-tertiary) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-soft) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 32px !important;
  font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--brand) !important;
  color: var(--bg-deep) !important;
}

/* ====== RESPONSIVE — MOBILE ====== */
@media (max-width: 600px) {
  header {
    padding: 10px 12px 8px;
  }

  .brand-name {
    display: none;
  }

  .brand-icon {
    font-size: 1.5rem;
  }

  .controls-row {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .controls-row::-webkit-scrollbar { display: none; }

  #fuel-selector {
    font-size: 0.75rem;
  }

  #btn-locate {
    bottom: 20px;
    right: 14px;
  }
}
