/* ===== FuelGo LK — Styles v4 ===== */
:root {
  --bg: #0a0f1a;
  --bg2: #111827;
  --bg3: #1a2236;
  --card: #1e2a3f;
  --border: #2a3650;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --green: #00C853;
  --green-bg: rgba(0,200,83,0.12);
  --orange: #FF9800;
  --orange-bg: rgba(255,152,0,0.12);
  --red: #FF1744;
  --red-bg: rgba(255,23,68,0.12);
  --grey: #546e7a;
  --grey-bg: rgba(84,110,122,0.12);
  --primary: #00C853;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 64px;
  --topbar-height: 56px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%; font-family: var(--font); background: var(--bg); color: var(--text);
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}

/* ===== SPLASH ===== */
#splash {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s, transform 0.5s;
}
#splash.fade-out { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-content { text-align: center; }
.splash-icon svg { width: 80px; height: 80px; margin-bottom: 20px; animation: splashPulse 1.5s ease infinite; }
@keyframes splashPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.splash-title { font-size: 36px; font-weight: 800; letter-spacing: -1px; color: #fff; }
.splash-title span { color: var(--green); }
.splash-sub { color: var(--text2); font-size: 14px; margin-top: 4px; font-weight: 500; }
.splash-loader { display: flex; gap: 6px; justify-content: center; margin-top: 32px; }
.splash-loader div { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: splashDot 1.2s ease infinite; }
.splash-loader div:nth-child(2) { animation-delay: 0.2s; }
.splash-loader div:nth-child(3) { animation-delay: 0.4s; }
@keyframes splashDot { 0%,100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }
.splash-by { color: var(--text3); font-size: 11px; margin-top: 40px; font-weight: 500; }

/* ===== APP ===== */
#app { height: 100%; display: flex; flex-direction: column; padding-bottom: var(--nav-height); }
.hidden { display: none !important; }

/* ===== TOPBAR ===== */
#topbar {
  height: var(--topbar-height); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
  flex-shrink: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo { width: 30px; height: 30px; }
.topbar-title { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.topbar-title span { color: var(--green); }
.topbar-toggle { display: flex; background: var(--bg3); border-radius: 10px; padding: 3px; gap: 2px; }
.toggle-btn {
  border: none; background: none; color: var(--text3); font-family: var(--font);
  font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 8px;
  cursor: pointer; transition: all 0.25s;
}
.toggle-btn.active { background: var(--green); color: #000; }

/* ===== AD ===== */
.ad-banner {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  min-height: 50px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.ad-banner-bottom { border-top: 1px solid var(--border); border-bottom: none; }
.ad-placeholder { color: var(--text3); font-size: 11px; text-align: center; padding: 8px; width: 100%; }

/* ===== MAP ===== */
#mapContainer { flex: 1; min-height: 40vh; position: relative; }
#map { width: 100%; height: 100%; z-index: 1; }
#btnLocate, #btnAddStation {
  position: absolute; z-index: 500; width: 42px; height: 42px; border-radius: 12px;
  background: #fff; border: 1px solid #ddd; color: #333;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.15); transition: background 0.2s;
}
#btnLocate { right: 12px; bottom: 12px; }
#btnAddStation { right: 12px; bottom: 62px; }
#btnLocate:active, #btnAddStation:active { background: #f0f0f0; }
#btnLocate svg, #btnAddStation svg { width: 20px; height: 20px; }
#btnLocate.locating svg { animation: locateSpin 1s linear infinite; }
@keyframes locateSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.leaflet-control-zoom { border: none !important; }
.leaflet-control-zoom a {
  background: #fff !important; color: #333 !important;
  border: 1px solid #ddd !important; border-radius: 8px !important;
  width: 34px !important; height: 34px !important; line-height: 34px !important;
  font-size: 16px !important; box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
}
.leaflet-control-zoom a + a { margin-top: 4px !important; }

.station-marker {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 16px; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); border: 2.5px solid #fff;
  transition: transform 0.2s;
}
.station-marker:hover { transform: scale(1.2); }
.marker-green { background: var(--green); }
.marker-orange { background: var(--orange); }
.marker-red { background: var(--red); }
.marker-grey { background: var(--grey); }

/* ===== STATION LIST ===== */
#stationList {
  background: var(--bg); flex: 1; min-height: 30vh; max-height: 50vh;
  display: flex; flex-direction: column; border-top: 1px solid var(--border); overflow: hidden;
}
.list-header {
  padding: 12px 16px 8px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-shrink: 0;
}
.list-header h2 { font-size: 16px; font-weight: 700; white-space: nowrap; }
.list-search { flex: 1; max-width: 220px; }
.list-search input {
  width: 100%; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--text); font-family: var(--font); font-size: 13px;
  outline: none; transition: border-color 0.2s;
}
.list-search input:focus { border-color: var(--green); }
.list-search input::placeholder { color: var(--text3); }

.cards-container {
  flex: 1; overflow-y: auto; padding: 0 12px 12px;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.cards-container::-webkit-scrollbar { width: 4px; }
.cards-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.station-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; display: flex; align-items: flex-start; gap: 12px;
  transition: border-color 0.2s, transform 0.15s;
}
.station-card:active { transform: scale(0.98); }
.station-card:hover { border-color: var(--green); }

.card-status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-orange { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.dot-red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot-grey { background: var(--grey); }

.card-info { flex: 1; min-width: 0; }
.card-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-brand { font-size: 11px; color: var(--text2); font-weight: 500; }
.card-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.card-meta .fuel-tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.fuel-available { background: var(--green-bg); color: var(--green); }
.fuel-limited { background: var(--orange-bg); color: var(--orange); }
.fuel-out { background: var(--red-bg); color: var(--red); }
.fuel-unknown { background: var(--grey-bg); color: var(--grey); }
.card-distance { font-size: 13px; font-weight: 700; color: var(--text2); white-space: nowrap; flex-shrink: 0; align-self: center; }
.no-stations { text-align: center; color: var(--text3); padding: 40px 20px; font-size: 14px; line-height: 1.6; }

/* ===== MODALS ===== */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; z-index: 1; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; padding: 24px 20px 32px;
  width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--text3); font-size: 28px; cursor: pointer; line-height: 1; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }
.detail-name { font-size: 20px; font-weight: 800; }
.detail-brand { font-size: 13px; color: var(--text2); margin-top: 2px; }
.detail-queue { margin: 12px 0; font-size: 14px; color: var(--text2); }
.detail-queue strong { color: var(--text); }
.detail-updated { font-size: 11px; color: var(--text3); margin-bottom: 16px; }
.detail-fuels { margin: 16px 0; }
.detail-fuels h4 { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.fuel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fuel-chip { text-align: center; padding: 8px 4px; border-radius: 8px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--bg3); }
.fuel-chip.available { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.fuel-chip.limited { border-color: var(--orange); background: var(--orange-bg); color: var(--orange); }
.fuel-chip.out { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.detail-directions {
  flex: 1; padding: 12px; border-radius: 10px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: center; transition: background 0.2s;
}
.detail-directions:hover { background: var(--border); }

/* ===== BUTTONS ===== */
.btn { border: none; font-family: var(--font); font-weight: 700; cursor: pointer; border-radius: var(--radius-sm); transition: all 0.2s; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #000; width: 100%; padding: 14px; }
.btn-primary:hover:not(:disabled) { background: #00b848; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); padding: 10px 16px; }
.btn-danger { background: var(--red); color: #fff; padding: 8px 16px; }
.btn-sm { font-size: 12px; padding: 8px 14px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--text); font-family: var(--font); font-size: 14px;
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--green); }
.form-hint { font-size: 12px; color: var(--text3); margin-bottom: 8px; }
.coords-display { font-size: 12px; color: var(--green); margin-top: 6px; font-weight: 500; }

.update-fuel-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.update-fuel-name { font-size: 14px; font-weight: 600; }
.update-status-btns { display: flex; gap: 4px; }
.status-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--border);
  cursor: pointer; transition: all 0.2s; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); color: var(--text3);
}
.status-btn.selected-green { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.status-btn.selected-orange { border-color: var(--orange); background: var(--orange-bg); color: var(--orange); }
.status-btn.selected-red { border-color: var(--red); background: var(--red-bg); color: var(--red); }

.update-queue-section { margin: 16px 0; }
.update-queue-section h4 { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.queue-btns { display: flex; gap: 8px; }
.queue-btn {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--text3); font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.2s;
}
.queue-btn.selected { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.cooldown-notice { background: var(--orange-bg); border: 1px solid var(--orange); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--orange); text-align: center; }

/* ===== QR TAB (FIXED LAYOUT) ===== */
#qrTab {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: var(--nav-height);
  background: var(--bg);
  z-index: 90;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}
.qr-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; flex-shrink: 0;
}
.qr-header h2 { font-size: 20px; font-weight: 700; }

.qr-privacy {
  background: rgba(0,200,83,0.08); border: 1px solid rgba(0,200,83,0.2);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px;
  font-size: 12px; color: var(--green); text-align: center; flex-shrink: 0;
}
.qr-privacy-small {
  font-size: 11px; color: var(--text3); text-align: center; margin-bottom: 12px;
}

.qr-list { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.qr-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; display: flex; align-items: center; gap: 14px; cursor: pointer;
  transition: border-color 0.2s;
}
.qr-card:hover { border-color: var(--green); }
.qr-card-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--bg3); border: 1px solid var(--border); }
.qr-card-info { flex: 1; }
.qr-card-name { font-size: 15px; font-weight: 700; }
.qr-card-number { font-size: 13px; color: var(--text2); margin-top: 2px; }

.qr-upload-area {
  border: 2px dashed var(--border); border-radius: 12px; padding: 24px;
  text-align: center; cursor: pointer; color: var(--text3); transition: border-color 0.2s;
}
.qr-upload-area:hover { border-color: var(--green); }
.qr-upload-area p { font-size: 13px; margin-top: 8px; }
.qr-preview { width: 100%; max-height: 200px; object-fit: contain; border-radius: 8px; margin-top: 10px; }
.qr-display-content { text-align: center; }
.qr-display-img { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; margin: 16px 0; }
.qr-vehicle-num { color: var(--text2); font-size: 14px; margin-bottom: 8px; }
.qr-empty { text-align: center; color: var(--text3); padding: 60px 20px; }
.qr-empty svg { margin-bottom: 12px; opacity: 0.4; }
.qr-empty p { font-size: 14px; line-height: 1.6; }

.qr-footer {
  margin-top: auto; padding-top: 24px; text-align: center; flex-shrink: 0;
}
.qr-footer a {
  color: var(--text3); font-size: 12px; text-decoration: none; font-weight: 500;
  transition: color 0.2s;
}
.qr-footer a:hover { color: var(--green); }

/* ===== BOTTOM NAV (fixed at bottom, never moves) ===== */
#bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 11px; font-weight: 600;
  cursor: pointer; padding: 6px 20px; border-radius: 10px; transition: color 0.2s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--green); }
.nav-btn.active svg { stroke: var(--green); }

/* ===== PWA INSTALL BANNER ===== */
#installBanner {
  position: fixed; bottom: 72px; left: 12px; right: 12px; z-index: 900;
  background: var(--card); border: 1px solid var(--green);
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 4px 24px rgba(0,200,83,0.15);
  animation: slideUp 0.4s ease;
}
.install-text { display: flex; flex-direction: column; gap: 2px; }
.install-text strong { font-size: 14px; color: var(--text); }
.install-text span { font-size: 12px; color: var(--text2); }
.install-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.install-yes {
  background: var(--green); color: #000; border: none; font-family: var(--font);
  font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 8px; cursor: pointer;
}
.install-no {
  background: none; border: none; color: var(--text3); font-size: 22px; cursor: pointer;
  padding: 0 4px; line-height: 1;
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  padding: 10px 20px; border-radius: 12px; font-size: 13px; font-weight: 600;
  z-index: 2000; animation: toastIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); max-width: 90vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }

@media (min-width: 600px) {
  #mapContainer { min-height: 50vh; }
  #stationList { max-height: 40vh; }
  .modal-content { border-radius: 20px; margin: 20px; }
  .fuel-grid { grid-template-columns: repeat(4, 1fr); }
}