/* ===== TankFlex Styles ===== */

/* Basis */
:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
html, body { height: 100%; }

/* Tastatur-Fokus sichtbar (A11y) */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Glassmorphism Panels */
.glass { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); }
[data-theme="light"] .glass { background: rgba(255,255,255,.72); border-color: rgba(15,17,21,.08); }
.glass-strong { background: rgba(15,17,21,.62); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%); }
[data-theme="light"] .glass-strong { background: rgba(255,255,255,.9); border-color: rgba(15,17,21,.1); }

/* Hero Glow */
.hero-glow { position: relative; }
.hero-glow::before { content:''; position:absolute; inset:-1px; border-radius: inherit; background: radial-gradient(600px 200px at 20% 0%, rgba(99,102,241,.25), transparent 60%), radial-gradient(500px 180px at 80% 100%, rgba(52,211,153,.18), transparent 60%); pointer-events: none; }

/* Scrollbar */
.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-thumb { background: rgba(148,163,184,.35); border-radius: 999px; }
.scroll-thin::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.6); }
.scroll-thin { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.4) transparent; }

/* Preis-Bubbles auf der Karte (MapLibre-DOM-Marker, inneres Element eines Wrappers) */
.price-bubble { background: rgba(15,17,21,.88); color: #fff; border: 1.5px solid rgba(255,255,255,.28); padding: 5px 10px 5px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; box-shadow: 0 8px 24px -8px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12); transition: transform .18s ease, box-shadow .18s ease; cursor: pointer; position: relative; transform-origin: 50% 100%; }
[data-theme="light"] .price-bubble { background: rgba(255,255,255,.96); color: #0f1115; border-color: rgba(15,17,21,.14); }
.price-bubble::after { content:''; position:absolute; left:50%; bottom:-5px; transform: translateX(-50%) rotate(45deg); width: 8px; height: 8px; background: inherit; border-right: 1.5px solid rgba(255,255,255,.28); border-bottom: 1.5px solid rgba(255,255,255,.28); }
[data-theme="light"] .price-bubble::after { border-color: rgba(15,17,21,.14); }
.price-bubble .dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.price-bubble .dot-e5 { background: #38bdf8; box-shadow: 0 0 10px #38bdf8; }
.price-bubble .dot-e10 { background: #34d399; box-shadow: 0 0 10px #34d399; }
.price-bubble .dot-diesel { background: #fbbf24; box-shadow: 0 0 10px #fbbf24; }
.price-bubble.best { border-color: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.28), 0 8px 24px -8px rgba(0,0,0,.55); }
.price-bubble:hover { transform: scale(1.08); z-index: 1200; }
.price-bubble.selected { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(129,140,248,.4), 0 10px 30px -8px rgba(0,0,0,.6); transform: scale(1.12); }

/* Standort-Marker */
.loc-dot { width: 16px; height: 16px; border-radius: 999px; background: #6366f1; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(99,102,241,.35), 0 6px 18px rgba(0,0,0,.35); position: relative; }
.loc-ring { position:absolute; inset:-6px; border-radius:999px; border:2px solid rgba(99,102,241,.7); animation: pulseSoft 1.8s ease-in-out infinite; }

@keyframes pulseSoft { 0%,100% { transform:scale(1); opacity:.9; } 50% { transform:scale(1.35); opacity:.35; } }

/* MapLibre GL – Popup & Controls im TankFlex-Look */
.maplibregl-popup-content { border-radius: 16px; box-shadow: 0 20px 50px -12px rgba(0,0,0,.5); color: #e5e7eb; background: rgba(15,17,21,.96); backdrop-filter: blur(10px); padding: 14px 16px; font-family: Inter, sans-serif; }
[data-theme="light"] .maplibregl-popup-content { background: #fff; color: #0f1115; }
.maplibregl-popup-tip { border-top-color: rgba(15,17,21,.96) !important; border-bottom-color: rgba(15,17,21,.96) !important; }
[data-theme="light"] .maplibregl-popup-tip { border-top-color: #fff !important; border-bottom-color: #fff !important; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: rgba(15,17,21,.96) !important; border-bottom-color: transparent !important; }
[data-theme="light"] .maplibregl-popup-anchor-bottom .maplibregl-popup-tip, [data-theme="light"] .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, [data-theme="light"] .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: #fff !important; }
.maplibregl-popup-close-button { color: #94a3b8; font-size: 16px; width: 28px; height: 28px; padding: 0; right: 4px; top: 4px; }
.maplibregl-ctrl-group { border-radius: 12px !important; overflow: hidden; box-shadow: 0 6px 18px -6px rgba(0,0,0,.4) !important; }
.maplibregl-ctrl-group button { background: rgba(15,17,21,.85) !important; color: #fff !important; width: 32px !important; height: 32px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid rgba(255,255,255,.12) !important; }
[data-theme="light"] .maplibregl-ctrl-group button { background: #fff !important; color: #0f1115 !important; }
.maplibregl-ctrl-attrib { background: rgba(15,17,21,.7) !important; color: #94a3b8 !important; font-size: 10px !important; border-radius: 10px 0 0 0; }
.maplibregl-ctrl-attrib a { color: #94a3b8 !important; }
[data-theme="light"] .maplibregl-ctrl-attrib { background: rgba(255,255,255,.8) !important; color: #475569 !important; }
[data-theme="light"] .maplibregl-ctrl-attrib a { color: #475569 !important; }
.maplibregl-map, .maplibregl-canvas { font-family: Inter, sans-serif; }

/* Fuel-Toggle */
.fuel-pill { transition: all .18s ease; border: 1px solid transparent; color: inherit; }
.fuel-pill[data-fuel="e5"] { --c: #38bdf8; }
.fuel-pill[data-fuel="e10"] { --c: #34d399; }
.fuel-pill[data-fuel="diesel"] { --c: #fbbf24; }
.fuel-pill.active { background: color-mix(in srgb, var(--c) 18%, transparent); border-color: color-mix(in srgb, var(--c) 65%, transparent); color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent), 0 8px 24px -10px var(--c); }
.fuel-pill.active span:first-child { color: var(--c); }

/* Segmented Control */
.seg { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); }
[data-theme="light"] .seg { background: rgba(15,17,21,.05); border-color: rgba(15,17,21,.08); }
.seg button { transition: all .15s ease; }
.seg button.active { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 6px 18px -6px rgba(99,102,241,.6); }

/* Range Slider */
input[type=range] { -webkit-appearance:none; appearance:none; height: 6px; border-radius: 999px; background: linear-gradient(90deg, #6366f1 var(--fill,50%), rgba(148,163,184,.25) var(--fill,50%)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; width: 22px; height: 22px; border-radius: 999px; background: #fff; border: 3px solid #6366f1; box-shadow: 0 4px 12px rgba(99,102,241,.5); cursor: pointer; transition: transform .12s ease; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius:999px; background:#fff; border:3px solid #6366f1; box-shadow: 0 4px 12px rgba(99,102,241,.5); cursor:pointer; }

/* Skeleton Loader */
.skel { background: linear-gradient(90deg, rgba(148,163,184,.12) 25%, rgba(148,163,184,.28) 50%, rgba(148,163,184,.12) 75%); background-size: 400px 100%; animation: shimmer 1.4s linear infinite; border-radius: 12px; }
@keyframes shimmer { 0% { background-position:-400px 0; } 100% { background-position:400px 0; } }

/* Toast */
.toast-item { animation: slideUp .3s ease-out both; }
@keyframes slideUp { 0% { transform:translateY(16px); opacity:0; } 100% { transform:translateY(0); opacity:1; } }

/* Card hover */
.station-card { transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.station-card:hover { transform: translateY(-2px); }
.station-card.active { border-color: rgba(129,140,248,.6); box-shadow: 0 0 0 3px rgba(129,140,248,.25), 0 14px 40px -14px rgba(0,0,0,.5); }

/* Status-Punkt */
.status-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.status-open { background: #34d399; box-shadow: 0 0 8px #34d399; }
.status-closed { background: #f87171; box-shadow: 0 0 8px #f87171; }

/* Preis-Delta */
.delta { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.delta-down { color: #34d399; background: rgba(52,211,153,.14); }
.delta-up { color: #f87171; background: rgba(248,113,113,.14); }

/* Marken-Avatar */
.brand-av { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 12px; font-weight: 800; color: #fff; flex-shrink: 0; letter-spacing: 0; text-transform: uppercase; box-shadow: inset 0 -2px 4px rgba(0,0,0,.18); }

/* Aufmerksamkeits-Puls (z.B. Refresh nötig, Karte verschoben) */
.btn-attn::after { content:''; position:absolute; inset:-3px; border-radius: inherit; border: 2px solid rgba(129,140,248,.75); animation: pulseSoft 1.8s ease-in-out infinite; pointer-events: none; }

/* Wartemodus: Tankerkönig-Limit – Suche wird automatisch fortgesetzt */
.wait-banner { display:flex; align-items:center; gap:10px; margin-top:12px; padding:10px 16px; border-radius:16px; background: rgba(245,158,11,.12); border:1px solid rgba(245,158,11,.4); color:#fbbf24; font-size:12.5px; font-weight:700; line-height:1.45; }
[data-theme="light"] .wait-banner { background: rgba(245,158,11,.16); border-color: rgba(217,119,6,.5); color:#92400e; }
.wait-badge { position:absolute; top:-8px; right:-8px; min-width:22px; text-align:center; background:#f59e0b; color:#111827; font-size:10px; font-weight:800; line-height:16px; padding:0 6px; border-radius:999px; box-shadow:0 2px 10px rgba(245,158,11,.55); z-index:6; pointer-events:none; font-variant-numeric: tabular-nums; }
[data-theme="light"] .wait-badge { background:#d97706; color:#fff; }
.wait-locked { cursor: progress; }

/* Weniger Bewegung, wenn es das System verlangt */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Countdown-Chip: nur während Cooldown UND ab Tablet sichtbar (JS steuert Klasse) */
#api-countdown-chip { display: none; }
@media (min-width: 768px) {
  #api-countdown-chip.on { display: flex; }
}

/* ===== Responsive: alle Geräte ===== */

/* Karte: Höhe an Viewport koppeln (dvh mit vh-Fallback, kein 100vh-Problem) */
.map-wrap { width: 100%; height: clamp(280px, 52vh, 560px); height: clamp(280px, 52dvh, 560px); }
.map-canvas { width: 100%; height: 100%; }

/* Sehr kleine Phones (≤360px): kompaktere Stat-Zahlen & Hero */
@media (max-width: 360px) {
  #stats-bar { gap: 6px; }
  #stats-bar .glass { padding: 10px 12px; }
  #stats-bar [id^="stat-"] { font-size: 20px; }
}

/* Querformat-Höhe knapp (Landscape-Phone): Karte flacher */
@media (max-height: 480px) and (orientation: landscape) {
  .map-wrap { height: 260px; }
}

/* Liste: Höhe dynamischer statt fix */
#station-list { max-height: clamp(320px, 52vh, 560px); max-height: clamp(320px, 52dvh, 560px); }

/* iOS: Über-Scroll-Bounce im Slider/Kartenbereich unterdrücken */
html, body { overflow-x: clip; }
body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }

/* Bottom-Sheet auf Mobil: dynamische Höhe + Handle zum Wischen */
.sheet { max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
.sheet-handle { display: flex; justify-content: center; padding: 10px 0 2px; cursor: grab; touch-action: none; }
.sheet-handle span { width: 44px; height: 5px; border-radius: 999px; background: rgba(148,163,184,.45); }
@media (min-width: 1024px) {
  .sheet-handle { display: none; }
}

/* Touch-Geräte: keine Hover-Sprünge, die auf Touch „kleben" */
@media (hover: none) {
  .station-card:hover { transform: none; }
}

/* Sichere Bereiche (Notch/Home-Bar) für Header & Toasts */
@media (max-width: 1023px) {
  header { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  main { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  #toasts { top: calc(env(safe-area-inset-top) + 4.5rem); }
}

/* Bottom Sheet (mobil) */
.sheet { position: fixed; left:0; right:0; bottom:0; z-index: 1200; transform: translateY(100%); transition: transform .35s cubic-bezier(.32,.72,.24,1); padding-bottom: env(safe-area-inset-bottom); }
.sheet.open { transform: translateY(0); }
@media (min-width: 1024px) {
  .sheet { position: static; transform: none; padding-bottom: 0; }
}

/* Details (Preisverlauf) – Standard-Pfeil unterdrücken */
#history-card summary::-webkit-details-marker { display: none; }
#history-card[open] summary { border-bottom: 1px solid rgba(255,255,255,.08); }
[data-theme="light"] #history-card[open] summary { border-bottom-color: rgba(15,17,21,.08); }

/* ===== Light-Theme-Remap =====
   Tailwind-Play-CDN generiert KEINE [data-theme]-Arbitrary-Variants – deshalb
   werden die dunkel-tunierte Utilities hier explizit für das Light-Theme
   umgemappt. (Wirkt nur unter [data-theme="light"], Dark bleibt unberührt.) */
[data-theme="light"] body { background: #f6f7fb; color: #1e293b; }
[data-theme="light"] .text-slate-300 { color: #475569; }
[data-theme="light"] .text-slate-400 { color: #64748b; }
[data-theme="light"] .text-slate-500 { color: #64748b; }
[data-theme="light"] .text-indigo-300, [data-theme="light"] .text-indigo-400 { color: #4f46e5; }
[data-theme="light"] .text-emerald-300, [data-theme="light"] .text-emerald-400 { color: #059669; }
[data-theme="light"] .text-sky-400 { color: #0369a1; }
[data-theme="light"] .text-amber-200, [data-theme="light"] .text-amber-300, [data-theme="light"] .text-amber-400 { color: #b45309; }
[data-theme="light"] .text-rose-300, [data-theme="light"] .text-rose-400 { color: #e11d48; }
[data-theme="light"] .bg-white\/5 { background-color: rgba(15,23,42,.04); }
[data-theme="light"] .hover\:bg-white\/10:hover { background-color: rgba(15,23,42,.08); }
[data-theme="light"] .border-white\/8, [data-theme="light"] .border-white\/10 { border-color: rgba(15,17,21,.1); }
[data-theme="light"] .border-white\/12, [data-theme="light"] .border-white\/20 { border-color: rgba(15,17,21,.12); }
[data-theme="light"] .glass { backdrop-filter: blur(18px) saturate(120%); }
[data-theme="light"] .station-card.active { border-color: rgba(99,102,241,.55); box-shadow: 0 0 0 3px rgba(99,102,241,.18), 0 14px 30px -14px rgba(15,23,42,.25); }
[data-theme="light"] .toast-item { box-shadow: 0 12px 32px -10px rgba(15,23,42,.4); }
[data-theme="light"] .btn-attn::after { border-color: rgba(79,70,229,.7); }
[data-theme="light"] .loc-dot { border-color: #fff; }
[data-theme="light"] .maplibregl-ctrl-group button { border-color: rgba(15,17,21,.12) !important; }
