/* ============================================================
   Georgia Gas Stations — Main stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --accent:       #f5a623;
  --accent-soft:  rgba(245,166,35,0.13);
  --toggle-on:    #1EC794;
  --red:          #e74c3c;
  --orange:       #F7971D;
  --radius:       12px;
  --shadow:       0 4px 18px rgba(0,0,0,0.13);
  --shadow-lg:    0 8px 36px rgba(0,0,0,0.22);
  --tr:           .22s ease;
}

[data-theme="dark"] {
  --bg:       #13161e;
    --toggle-off:   #202B46;
  --bg-card:  #1a1e2a;
  --border-card:  #3B3B3B;
  --bg-hover: #222839;
  --text:     #edf0f7;
  --text-2:   #8890a8;
  --text-3:   #545c74;
  --border:   rgba(255,255,255,0.07);
  --border-h: rgba(245,166,35,0.4);
  --loader-bg:#0d0f14;
}

[data-theme="light"] {
  --bg:       #ffffff;
    --toggle-off:   #E9ECEF;
  --bg-card:  #f3f5fb;
  --border-card:  #E9ECEF;
  --bg-hover: #e8ecf5;
  --text:     #1a1e2a;
  --text-2:   #4a5270;
  --text-3:   #8890a8;
  --border:   rgba(0,0,0,0.08);
  --border-h: rgba(245,166,35,0.5);
  --loader-bg:#f0f2f8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Google Sans', sans-serif; overflow: hidden; color: var(--text); }

/* ── Fullscreen ─────────────────────────────────────────── */
#map-fullscreen { position: fixed; inset: 0; }
#map { width: 100%; height: 100%; }

/* ── Top-left row ───────────────────────────────────────── */
#top-left-row {
  position: absolute;
  top: 10px; left: 10px; bottom: 10px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
#top-left-row > * { pointer-events: auto; }

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: 300px;
  height: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background var(--tr), border-color var(--tr);
}

/* Sidebar top: logo + language */
.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: border-color var(--tr);
}
.sidebar-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-lang {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
  transition: background var(--tr), border-color var(--tr);
}
.lang-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-family: 'GOoGle Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 5px 10px;
  letter-spacing: .5px;
  transition: color .15s, background .15s;
}
.lang-btn:hover { color: var(--accent); }
.sidebar-close-mob {
  display: none;
  background: none; border: none;
  color: var(--text-3); font-size: 16px; cursor: pointer; padding: 4px;
  margin-left: 4px;
}

/* Sidebar sections */
.sidebar-section { padding: 10px 14px 4px; flex-shrink: 0; }
.sidebar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.sidebar-label a { color: var(--text-3); text-decoration: none; }
.sidebar-label a:hover { color: var(--accent); text-decoration: underline; }

/* Fuel chips */
.fuel-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 2px; }
.fuel-chip {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px;
  font-size: 10px; font-weight: 500; color: var(--text-2);
  cursor: pointer; user-select: none; transition: all .15s;
}
.fuel-chip:hover  { border-color: var(--accent); color: var(--accent); }
.fuel-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Company list */
.company-list { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }
.company-list::-webkit-scrollbar { width: 3px; }
.company-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Company item: border, border-radius, margin, gap */
.company-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  margin: 8px 0;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .15s;
}
.company-item:first-child { margin-top: 0; }
.company-item:hover { border-color: var(--orange); }

/* Logo: no background, no border */
.company-logo {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  overflow: visible;
}
.company-logo img {
  width: 32px; height: 32px;
  object-fit: contain;
}

.company-info { flex: 1; min-width: 0; }
.company-name  { font-size: 15px; font-weight: 600; color: var(--text); }
.company-count { font-size: 10px; color: var(--text-3); font-family: 'Google Sans', monospace; padding-top: 6px; }

/* Toggle switch: 31px tall, green on, grey off, white knob, no border */
.toggle-switch {
  position: relative;
  width: 52px;
  height: 31px;
  flex-shrink: 0;
}
.toggle-track {
  position: absolute; inset: 0;
  background: var(--toggle-off);
  border-radius: 31px;
  cursor: pointer;
  transition: background .2s;
  border: none;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 25px; height: 25px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform .2s;
}
.company-item.active .toggle-track { background: var(--toggle-on); }
.company-item.active .toggle-thumb { transform: translateX(21px); }

/* ── Search ─────────────────────────────────────────────── */
#searchWrap {
  align-self: flex-start;
  position: relative;
  width: 240px;
}
#searchInput {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-family: 'GOoGle Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background var(--tr), color var(--tr);
}
#searchInput::placeholder { color: var(--text-3); }
#searchInput:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; pointer-events: none;
}
.search-clear-btn {
  position: absolute;
  right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--bg-hover);
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  transition: background .15s, color .15s;
  padding: 0;
}
.search-clear-btn:hover { background: var(--border-h); color: var(--text); }
/* Google autocomplete dropdown styling */
.pac-container {
  border-radius: 10px !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: 'GOoGle Sans', sans-serif !important;
  margin-top: 4px !important;
  background: var(--bg) !important;
}
.pac-item {
  padding: 8px 14px !important;
  font-size: 13px !important;
  color: var(--text) !important;
  cursor: pointer !important;
  border-color: var(--border) !important;
}
.pac-item:hover, .pac-item-selected { background: var(--bg-hover) !important; }
.pac-item-query { color: var(--text) !important; }

/* ── Map controls ───────────────────────────────────────── */
.map-controls {
  position: absolute; top: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 7px; z-index: 50;
}
.map-btn-group {
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
  transition: background var(--tr), border-color var(--tr);
}
.map-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: background .12s, color .12s, border-color var(--tr);
}
.map-btn:last-child { border-bottom: none; }
.map-btn:hover { background: var(--bg-hover); color: var(--accent); }

/* ── Info panel ─────────────────────────────────────────── */
#info-panel {
  position: absolute; bottom: 10px; right: 10px;
  width: 330px; max-height: calc(100vh - 20px);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(calc(100% + 20px));
  transition: transform .32s cubic-bezier(.4,0,.2,1), background var(--tr), border-color var(--tr);
  z-index: 50;
}
#info-panel.open { transform: translateY(0); }

.panel-header { padding: 13px 13px 9px; border-bottom: 1px solid var(--border); flex-shrink: 0; position: relative; transition: border-color var(--tr); }
.panel-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.panel-logo  { width: 40px; height: 40px; border-radius: 8px; background: var(--bg-card); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.panel-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.panel-company { font-family: 'Bebas Neue', sans-serif; font-size: 18px; letter-spacing: 1px; color: var(--text); }
.panel-address { font-size: 11px; color: var(--text-2); line-height: 1.4; margin-top: 1px; }
.panel-close {
  position: absolute; top: 11px; right: 11px;
  width: 26px; height: 26px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3); font-size: 12px; transition: all .15s;
}
.panel-close:hover { color: var(--text); border-color: var(--border-h); }
.distance-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 20px; padding: 3px 9px;
  font-size: 11px; color: var(--accent); font-family: 'JetBrains Mono', monospace; font-weight: 600;
}

.panel-body { flex: 1; overflow-y: auto; padding: 11px 13px; display: flex; flex-direction: column; }
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.prices-title { font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.price-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; transition: border-color .15s, background var(--tr); }
.price-card:hover { border-color: var(--border-h); }
.price-type   { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 3px; display: flex; align-items: center; }
.price-value  { font-family: 'Bebas Neue', sans-serif; font-size: 22px; color: var(--accent); line-height: 1; }
.price-unit   { font-size: 10px; color: var(--text-2); }
.price-octane { font-size: 10px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }

.panel-footer { padding: 9px 13px 12px; border-top: 1px solid var(--border); flex-shrink: 0; transition: border-color var(--tr); }
.btn-directions {
  width: 100%; background: var(--accent); color: #000; border: none; border-radius: 8px; padding: 10px;
  font-family: 'GOoGle Sans', sans-serif; font-weight: 700; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: opacity .15s;
}
.btn-directions:hover { opacity: .88; }

/* ── Directions ─────────────────────────────────────────── */
#directions-panel { display: none; flex-direction: column; border-top: 1px solid var(--border); max-height: 250px; overflow-y: auto; }
#directions-panel.open { display: flex; }
.dir-header { display: flex; align-items: center; gap: 9px; padding: 9px 13px; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.dir-stat   { display: flex; align-items: center; gap: 5px; font-family: 'Bebas Neue', sans-serif; font-size: 16px; color: var(--text); }
.dir-stat i { font-size: 12px; color: var(--accent); }
.dir-clear  { margin-left: auto; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 6px; color: var(--text-2); font-family: 'GOoGle Sans', sans-serif; font-size: 11px; padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all .15s; }
.dir-clear:hover { color: var(--red); border-color: var(--red); }
.dir-step { display: flex; align-items: flex-start; gap: 8px; padding: 7px 13px; border-bottom: 1px solid var(--border); transition: background .12s; }
.dir-step:last-child { border-bottom: none; }
.dir-step:hover { background: var(--bg-hover); }
.dir-step-num  { width: 19px; height: 19px; border-radius: 50%; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dir-step-text { flex: 1; font-size: 11px; color: var(--text-2); line-height: 1.5; }
.dir-step-dist { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }

/* ── Skeleton ───────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 5px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Loading overlay ────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--loader-bg, #0d0f14);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  transition: opacity .5s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-img { height: 56px; width: auto; object-fit: contain; }
.loader-bar { width: 160px; height: 3px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; }
.loader-progress { height: 100%; background: var(--accent); border-radius: 2px; animation: load 2s ease-out forwards; }
@keyframes load { from{width:0} to{width:100%} }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 8px 15px; font-size: 12px; color: var(--text); box-shadow: var(--shadow-lg); animation: toastIn .3s ease; white-space: nowrap; }
@keyframes toastIn { from{opacity:0;transform:translateY(7px)} to{opacity:1;transform:translateY(0)} }

/* ── Empty state ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 24px 14px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 28px; margin-bottom: 7px; }
.empty-state p { font-size: 12px; line-height: 1.6; }

/* ── Mobile sidebar toggle ──────────────────────────────── */
.sidebar-toggle-mob {
  display: none; position: absolute; top: 10px; left: 10px;
  width: 40px; height: 40px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); font-size: 15px;
  box-shadow: var(--shadow); z-index: 60;
 transition: background var(--tr), opacity .2s, visibility .2s;
}
.sidebar-toggle-mob.sidebar-open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.sidebar-backdrop { display: none; }

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 680px) {
  #top-left-row {
    position: fixed; top: 0; left: 0; bottom: 0;
    flex-direction: column;
    transform: translateX(-110%);
    transition: transform .3s ease;
    pointer-events: none;
    gap: 0; background: transparent;
  }
  #top-left-row.open { transform: translateX(0); pointer-events: auto; }
  #sidebar { width: 280px; border-radius: 0 var(--radius) var(--radius) 0; }
  #searchWrap { width: 280px; border-radius: 0; padding: 8px; background: var(--bg); border-right: 1px solid var(--border); }
  #searchInput { border-radius: 8px; }
  .sidebar-toggle-mob { display: flex; }
  .sidebar-close-mob  { display: block; }
  .sidebar-backdrop {
    display: block !important; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 49;
    opacity: 0; pointer-events: none; transition: opacity .3s;
  }
  .sidebar-backdrop.active { opacity: 1; pointer-events: all; }
  #info-panel { width: calc(100vw - 20px); }
}

/* ============================================================
   Mobile-specific improvements
   ============================================================ */

/* ── 1. Minimised info panel state (directions mode) ─────── */
#info-panel.minimised {
  /* Collapse to just the header — user can see map + route */
  max-height: 90px;
  overflow: hidden;
}
#info-panel.minimised .panel-body,
#info-panel.minimised #directions-panel,
#info-panel.minimised .panel-footer {
  display: none;
}
/* Restore button shown when minimised */
.panel-restore {
  display: none;
  position: absolute;
  bottom: 10px; right: 50px;
  width: 28px; height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3); font-size: 12px;
  transition: all .15s;
}
.panel-restore:hover { color: var(--accent); border-color: var(--border-h); }
#info-panel.minimised .panel-restore { display: flex; }

/* Clear-directions button — floats above the map on mobile */
#mobile-clear-directions {
  display: none;
  position: fixed;
  bottom: 110px; left: 50%; transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-family: 'GOoGle Sans', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  gap: 8px; align-items: center;
  z-index: 60;
  white-space: nowrap;
}
#mobile-clear-directions.visible { display: flex; }
#mobile-clear-directions i { color: var(--red); }

/* ── 2. Mobile search bar (slide-down from top-right) ─────── */
/* Search button in map-controls — only shown on mobile */
#searchToggleBtn {
  display: none; /* hidden on desktop */
}

/* The search bar that slides down */
#mobile-search-bar {
  display: none; /* hidden on desktop */
}

@media (max-width: 680px) {
  /* Hide desktop search wrap */
  #top-left-row #searchWrap { display: none; }

  /* Show search button in map controls */
  #searchToggleBtn {
    display: flex;
  }

  /* Mobile search bar — fixed at top, slides down */
  #mobile-search-bar {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    z-index: 200;
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s cubic-bezier(.4,0,.2,1),
                padding .3s cubic-bezier(.4,0,.2,1);
  }
  #mobile-search-bar.open {
    max-height: 72px;
    padding: 14px 12px;
  }

  #mobile-search-bar .mob-search-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 14px 0 12px;
    height: 44px;
  }
  #mobile-search-bar .mob-search-inner i {
    color: var(--text-3); font-size: 13px; flex-shrink: 0;
  }
  #mobile-search-bar input {
    flex: 1;
    background: none; border: none; outline: none;
    color: var(--text);
    font-family: 'GOoGle Sans', sans-serif;
    /* font-size 16px prevents iOS zoom-in on focus */
    font-size: 16px;
    padding: 0;
  }
  #mobile-search-bar input::placeholder { color: var(--text-3); }
  #mobile-search-bar .mob-search-close {
    background: none; border: none;
    color: var(--text-3); font-size: 16px; cursor: pointer; padding: 4px;
  }

  /* Push map down when search is open */
  #map-fullscreen {
    transition: top .3s cubic-bezier(.4,0,.2,1);
  }
  #map-fullscreen.search-open {
    top: 72px;
  }

  /* Ensure sidebar-backdrop z-index stays below search */
  .sidebar-backdrop { z-index: 49 !important; }

  /* Info panel full width on mobile */
  #info-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 70vh;
  }
  #info-panel.open { transform: translateY(0); }

  /* ── 3. Prevent zoom on input focus (font-size 16px) ─────── */
  /* Already applied above on #mobile-search-bar input */
}
