/* ═══════════════════════════════════════════════════════════
   FuelMap — Teal/Petroleum Branding
   Primary: #0D9488 (teal-600)  
   Accent:  #14b8a6 (teal-500)  
   Light:   #ccfbf1 (teal-100)
   Dark:    #134e4a (teal-900)
   
   Price colors:
   Cheap:  #059669 (emerald)
   Mid:    #d97706 (amber)
   Expensive: #dc2626 (red)
   ═══════════════════════════════════════════════════════════ */

:root {
  --fm-primary: #0D9488;
  --fm-primary-dark: #0f766e;
  --fm-primary-darker: #134e4a;
  --fm-accent: #14b8a6;
  --fm-accent-light: #2dd4bf;
  --fm-light: #ccfbf1;
  --fm-lighter: #f0fdfa;
  --fm-surface: #ffffff;
  --fm-surface-2: #f8fafa;
  --fm-text: #1a1a2e;
  --fm-text-secondary: #6b7280;
  --fm-text-muted: #9ca3af;
  --fm-border: #e5e7eb;
  --fm-shadow: 0 4px 24px rgba(13, 148, 136, 0.08);
  --fm-shadow-lg: 0 12px 40px rgba(13, 148, 136, 0.12);
  --fm-radius: 16px;
  --fm-radius-sm: 10px;
  --fm-header-h: 56px;
  --fm-search-h: 150px;
  --fm-panel-peek: 140px;
  --fm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --fm-safe-top: env(safe-area-inset-top, 0px);

  /* Price colors */
  --price-cheap: #059669;
  --price-cheap-bg: #d1fae5;
  --price-mid: #d97706;
  --price-mid-bg: #fef3c7;
  --price-expensive: #dc2626;
  --price-expensive-bg: #fee2e2;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%; width: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--fm-text);
  background: var(--fm-surface);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══ SPLASH ═══ */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0D9488 0%, #0f766e 50%, #134e4a 100%);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.splash.hide {
  opacity: 0; transform: scale(1.05);
  pointer-events: none;
}
.splash-content { text-align: center; }
.splash-icon {
  font-size: 4rem; margin-bottom: 16px;
  animation: pulse-icon 2s ease-in-out infinite;
}
@keyframes pulse-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.splash-title {
  font-size: 2.2rem; font-weight: 800; color: white;
  letter-spacing: -0.5px; margin-bottom: 8px;
}
.splash-sub {
  font-size: 0.95rem; color: rgba(255,255,255,0.8);
  font-weight: 500;
}
.splash-dots {
  display: flex; gap: 8px; justify-content: center; margin-top: 24px;
}
.splash-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5);
  animation: dot-bounce 1.4s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; background: white; }
}

/* ═══ HEADER ═══ */
header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000; height: var(--fm-header-h);
  padding-top: var(--fm-safe-top);
  background: var(--fm-primary);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 16px;
}
.logo {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  user-select: none;
}
.logo-icon { font-size: 1.5rem; }
.logo-text {
  font-size: 1.25rem; font-weight: 800; color: white;
  letter-spacing: -0.5px;
}
.header-stats {
  font-size: 0.75rem; color: rgba(255,255,255,0.75);
  font-weight: 500;
}
.btn-locate {
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: rgba(255,255,255,0.15); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.btn-locate:hover { background: rgba(255,255,255,0.25); transform: scale(1.05); }
.btn-locate:active { transform: scale(0.95); }
.btn-locate.locating {
  animation: locate-pulse 1s ease-in-out infinite;
}
@keyframes locate-pulse {
  0%, 100% { background: rgba(255,255,255,0.15); }
  50% { background: rgba(255,255,255,0.35); }
}

/* ═══ SEARCH ═══ */
.search-container {
  position: fixed;
  top: calc(var(--fm-header-h) + var(--fm-safe-top));
  left: 0; right: 0; z-index: 999;
  padding: 8px 12px 6px;
  background: linear-gradient(to bottom, var(--fm-surface) 80%, transparent);
}
.search-bar {
  display: flex; align-items: center;
  background: var(--fm-surface);
  border: 2px solid var(--fm-border);
  border-radius: var(--fm-radius);
  padding: 0 14px; height: 44px;
  box-shadow: var(--fm-shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar:focus-within {
  border-color: var(--fm-accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15), var(--fm-shadow);
}
.search-icon { color: var(--fm-text-muted); flex-shrink: 0; margin-right: 10px; }
#searchInput {
  flex: 1; border: none; outline: none; background: none;
  font-size: 0.9rem; font-family: inherit; color: var(--fm-text);
}
#searchInput::placeholder { color: var(--fm-text-muted); }
.search-clear {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: var(--fm-border); color: var(--fm-text-secondary);
  cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.search-clear:hover { background: #d1d5db; }
.search-clear.hidden { display: none; }

/* Fuel chips */
.fuel-chips {
  display: flex; gap: 6px; padding-top: 6px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.fuel-chips::-webkit-scrollbar { display: none; }
.fuel-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 18px;
  border: 1.5px solid var(--fm-border);
  background: var(--fm-surface);
  font-size: 0.75rem; font-weight: 600;
  color: var(--fm-text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}
.fuel-chip:hover { border-color: var(--fm-accent); color: var(--fm-primary); }
.fuel-chip.active {
  background: var(--fm-light);
  border-color: var(--fm-accent);
  color: var(--fm-primary);
}
.fuel-chip-icon { font-size: 0.7rem; }

/* Sort/filter controls */
.controls-row {
  display: flex; gap: 6px; padding-top: 6px;
}
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 14px;
  border: 1px solid var(--fm-border);
  background: var(--fm-surface);
  font-size: 0.7rem; font-weight: 600;
  color: var(--fm-text-muted);
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}
.sort-btn:hover { color: var(--fm-primary); border-color: var(--fm-accent); }
.sort-btn.active {
  background: var(--fm-primary);
  border-color: var(--fm-primary);
  color: white;
}
.sort-btn svg { flex-shrink: 0; }

/* ═══ MAP ═══ */
#map {
  position: fixed;
  top: calc(var(--fm-header-h) + var(--fm-safe-top));
  left: 0; right: 0;
  bottom: 0;
  z-index: 1;
}
.leaflet-control-zoom a {
  background: var(--fm-surface) !important;
  color: var(--fm-primary) !important;
  border-color: var(--fm-border) !important;
  width: 36px !important; height: 36px !important;
  line-height: 36px !important; font-size: 18px !important;
  border-radius: 10px !important;
  box-shadow: var(--fm-shadow) !important;
}
.leaflet-control-zoom { border: none !important; border-radius: 12px !important; overflow: hidden; }

/* ═══ PRICE BAR ═══ */
.price-bar {
  position: fixed;
  top: calc(var(--fm-header-h) + var(--fm-search-h) + var(--fm-safe-top) + 4px);
  left: 12px; right: 12px;
  z-index: 998;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex; justify-content: space-around; align-items: center;
  box-shadow: var(--fm-shadow);
  transition: opacity 0.3s, transform 0.3s;
}
.price-bar.hidden {
  opacity: 0; transform: translateY(-10px); pointer-events: none;
}
.price-stat { text-align: center; }
.price-stat-label { display: block; font-size: 0.6rem; font-weight: 600; color: var(--fm-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.price-stat-value { font-size: 0.95rem; font-weight: 800; color: var(--fm-text); }
.price-stat-value.cheap { color: var(--price-cheap); }
.price-stat-value.expensive { color: var(--price-expensive); }

/* ═══ STATION MARKERS ═══ */
.station-marker {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  min-width: 46px;
  padding: 3px 6px 2px;
  border-radius: 10px;
  border: 2px solid white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  text-align: center;
  transition: transform 0.2s;
  cursor: pointer;
}
.station-marker:hover { transform: scale(1.1); }
.station-marker .price-label {
  font-size: 0.7rem; font-weight: 800; color: white;
  line-height: 1.1;
}
.station-marker .brand-label {
  font-size: 0.48rem; font-weight: 600; color: rgba(255,255,255,0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 50px;
}
.station-marker.cheap { background: var(--price-cheap); }
.station-marker.mid { background: var(--price-mid); }
.station-marker.expensive { background: var(--price-expensive); }
.station-marker.no-price { background: #9ca3af; }

/* User location marker */
.user-marker {
  width: 16px; height: 16px;
  background: #3b82f6;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2), 0 2px 8px rgba(0,0,0,0.2);
}

/* Map popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--fm-radius-sm) !important;
  box-shadow: var(--fm-shadow-lg) !important;
  padding: 0 !important;
}
.leaflet-popup-content { margin: 0 !important; width: 270px !important; }
.popup-card { padding: 14px; }
.popup-brand { font-size: 0.78rem; font-weight: 700; color: var(--fm-primary); margin-bottom: 2px; }
.popup-address { font-size: 0.75rem; color: var(--fm-text-secondary); margin-bottom: 8px; }
.popup-prices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin-bottom: 10px;
}
.popup-price-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 8px; border-radius: 6px; background: var(--fm-surface-2);
}
.popup-fuel-name { font-size: 0.68rem; color: var(--fm-text-secondary); }
.popup-fuel-price { font-size: 0.75rem; font-weight: 700; }
.popup-fuel-price.cheap { color: var(--price-cheap); }
.popup-fuel-price.mid { color: var(--price-mid); }
.popup-fuel-price.expensive { color: var(--price-expensive); }
.popup-tags { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.popup-tag {
  font-size: 0.6rem; font-weight: 600; padding: 2px 7px;
  border-radius: 8px; text-transform: uppercase; letter-spacing: 0.3px;
}
.popup-tag.distance { background: #dbeafe; color: #1d4ed8; }
.popup-tag.h24 { background: var(--fm-light); color: var(--fm-primary-dark); }
.popup-tag.brand-tag { background: var(--fm-lighter); color: var(--fm-primary); }
.popup-actions { display: flex; gap: 6px; }
.popup-btn {
  flex: 1; padding: 7px; border: none; border-radius: 8px;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all 0.2s; font-family: inherit;
}
.popup-btn-primary { background: var(--fm-primary); color: white; }
.popup-btn-primary:hover { background: var(--fm-primary-dark); }
.popup-btn-secondary {
  background: var(--fm-lighter); color: var(--fm-primary);
  border: 1px solid var(--fm-light);
}
.popup-btn-secondary:hover { background: var(--fm-light); }

/* ═══ RESULTS PANEL ═══ */
.results-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 998;
  background: var(--fm-surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.1);
  max-height: 65vh;
  transform: translateY(calc(100% - var(--fm-panel-peek)));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: var(--fm-safe-bottom);
}
.results-panel.expanded { transform: translateY(0); }
.results-panel.collapsed { transform: translateY(calc(100% - var(--fm-panel-peek))); }
.panel-handle {
  display: flex; justify-content: center; padding: 10px 0 6px;
  cursor: grab;
}
.handle-bar {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--fm-border);
}
.panel-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 16px 8px;
}
.panel-header h2 { font-size: 1rem; font-weight: 700; color: var(--fm-text); }
.results-count { font-size: 0.8rem; color: var(--fm-text-muted); font-weight: 500; }
.results-list {
  overflow-y: auto; max-height: calc(65vh - 80px);
  padding: 0 12px 12px;
  -webkit-overflow-scrolling: touch;
}

/* Station card in list */
.station-card {
  display: flex; gap: 10px; padding: 10px;
  border-radius: var(--fm-radius-sm);
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.station-card:hover {
  border-color: var(--fm-accent);
  box-shadow: 0 2px 12px rgba(20, 184, 166, 0.1);
  transform: translateY(-1px);
}
.station-card:active { transform: translateY(0) scale(0.99); }
.card-price-box {
  width: 56px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; padding: 6px 4px;
}
.card-price-box.cheap { background: var(--price-cheap-bg); }
.card-price-box.mid { background: var(--price-mid-bg); }
.card-price-box.expensive { background: var(--price-expensive-bg); }
.card-price-box.no-price { background: #f3f4f6; }
.card-price-main {
  font-size: 0.95rem; font-weight: 800; line-height: 1.1;
}
.card-price-main.cheap { color: var(--price-cheap); }
.card-price-main.mid { color: var(--price-mid); }
.card-price-main.expensive { color: var(--price-expensive); }
.card-price-main.no-price { color: var(--fm-text-muted); }
.card-price-unit { font-size: 0.55rem; color: var(--fm-text-muted); font-weight: 500; }
.card-body { flex: 1; min-width: 0; }
.card-brand {
  font-size: 0.82rem; font-weight: 700; color: var(--fm-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-address {
  font-size: 0.72rem; color: var(--fm-text-secondary);
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  display: flex; gap: 6px; margin-top: 4px; align-items: center;
  flex-wrap: wrap;
}
.card-distance {
  font-size: 0.68rem; font-weight: 600; color: #2563eb;
  background: #dbeafe; padding: 1px 6px; border-radius: 6px;
}
.card-badge {
  font-size: 0.62rem; font-weight: 600; padding: 1px 6px;
  border-radius: 6px; white-space: nowrap;
}
.card-badge.h24 { background: var(--fm-light); color: var(--fm-primary-dark); }
.card-badge.schedule { background: #f3f4f6; color: var(--fm-text-muted); }
.card-other-prices {
  display: flex; gap: 4px; margin-top: 3px;
}
.card-subprice {
  font-size: 0.58rem; font-weight: 500; color: var(--fm-text-muted);
  background: var(--fm-surface-2); padding: 1px 5px; border-radius: 4px;
}

/* ═══ STATION DETAIL OVERLAY ═══ */
.station-detail {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--fm-surface);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.station-detail.show { transform: translateX(0); }
.station-detail.hidden { pointer-events: none; }
.detail-close {
  position: fixed; top: 12px; right: 12px; z-index: 2001;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--fm-surface);
  box-shadow: var(--fm-shadow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--fm-text-secondary);
  transition: background 0.2s;
}
.detail-close:hover { background: var(--fm-lighter); }
.detail-hero {
  height: 160px;
  background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-darker));
  display: flex; align-items: flex-end; padding: 20px;
}
.detail-hero h1 {
  font-size: 1.3rem; font-weight: 800; color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.detail-hero .detail-hero-sub {
  font-size: 0.8rem; color: rgba(255,255,255,0.8); margin-top: 4px;
}
.detail-body { padding: 16px; }
.detail-prices-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px;
}
.detail-price-card {
  padding: 10px; border-radius: 10px; background: var(--fm-surface-2);
  border: 1px solid var(--fm-border); text-align: center;
}
.detail-price-card.highlight {
  border-color: var(--fm-accent); background: var(--fm-lighter);
}
.detail-price-fuel { font-size: 0.72rem; font-weight: 600; color: var(--fm-text-secondary); margin-bottom: 2px; }
.detail-price-value { font-size: 1.2rem; font-weight: 800; }
.detail-price-value.cheap { color: var(--price-cheap); }
.detail-price-value.mid { color: var(--price-mid); }
.detail-price-value.expensive { color: var(--price-expensive); }
.detail-price-value.no-price { color: var(--fm-text-muted); font-size: 0.9rem; }
.detail-section { margin-bottom: 16px; }
.detail-section h3 {
  font-size: 0.8rem; font-weight: 700; color: var(--fm-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.detail-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; }
.detail-row svg { flex-shrink: 0; color: var(--fm-primary); margin-top: 2px; }
.detail-row-text { font-size: 0.85rem; color: var(--fm-text); }
.detail-actions {
  display: flex; gap: 10px; padding: 16px; position: sticky; bottom: 0;
  background: var(--fm-surface); border-top: 1px solid var(--fm-border);
}
.detail-btn {
  flex: 1; padding: 12px; border: none; border-radius: var(--fm-radius-sm);
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; transition: all 0.2s;
}
.detail-btn-directions { background: var(--fm-primary); color: white; }
.detail-btn-directions:hover { background: var(--fm-primary-dark); }
.detail-btn-share {
  background: var(--fm-lighter); color: var(--fm-primary);
  border: 1.5px solid var(--fm-light);
}
.detail-btn-share:hover { background: var(--fm-light); }

/* ═══ FOOTER ═══ */
.footer {
  position: fixed; bottom: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  padding: 6px 16px; border-radius: 20px;
  font-size: 0.7rem; color: var(--fm-text-muted);
  display: flex; gap: 6px; align-items: center;
  box-shadow: var(--fm-shadow);
  white-space: nowrap;
}
.footer a { color: var(--fm-primary); text-decoration: none; font-weight: 600; }

/* ═══ EMPTY / LOADING STATES ═══ */
.state-empty { text-align: center; padding: 30px 20px; }
.state-empty-icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  background: var(--fm-lighter); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.state-empty h3 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.state-empty p { font-size: 0.85rem; color: var(--fm-text-secondary); }

.skeleton-card {
  display: flex; gap: 10px; padding: 10px;
  border-radius: var(--fm-radius-sm);
  border: 1px solid var(--fm-border);
  margin-bottom: 6px;
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ═══ RESPONSIVE ═══ */
@media (min-width: 768px) {
  .results-panel {
    width: 400px; left: 12px; right: auto;
    border-radius: var(--fm-radius);
    bottom: 12px;
    max-height: calc(100vh - var(--fm-header-h) - var(--fm-search-h) - 24px);
    transform: translateY(0);
    box-shadow: var(--fm-shadow-lg);
  }
  .results-panel.collapsed { transform: translateY(0); }
  .panel-handle { display: none; }
  .footer { bottom: 12px; }
  .search-container { max-width: 540px; }
  .price-bar { max-width: 540px; left: auto; right: auto; }
}

@media (max-width: 767px) {
  .footer { display: none; }
  .header-stats { display: none; }
}
