/* ============================================================
   DESIGN-SYSTEM: CSS-VARIABLEN
   ============================================================ */
:root {
  --bg-primary:       #0a0a0a;
  --bg-secondary:     #141414;
  --bg-card:          #1a1a1a;
  --accent-red:       #e63946;
  --accent-red-hover: #ff6b6b;
  --accent-green:     #2ecc71;
  --text-primary:     #f0f0f0;
  --text-secondary:   #999999;
  --border-color:     #2a2a2a;
  --border-hover:     #e63946;
  --shadow:           0 4px 20px rgba(230, 57, 70, 0.15);
  --font-main:        'Inter', sans-serif;
  --radius-card:      12px;
  --transition:       all 0.2s ease;
}

/* ============================================================
   GLOBALE STILE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Benutzerdefinierte Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent-red); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-red-hover); }

/* Textauswahl */
::selection {
  background: var(--accent-red);
  color: #fff;
}

a {
  color: var(--accent-red);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Hilfsklasse */
.hidden { display: none !important; }

/* ============================================================
   HEADER
   ============================================================ */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-red);
  text-shadow: 0 0 20px rgba(230, 57, 70, 0.5);
  line-height: 1;
}

.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.update-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.update-label {
  margin-right: 4px;
}

.countdown {
  color: var(--accent-red);
  font-weight: 600;
}

/* ============================================================
   SUCHBEREICH
   ============================================================ */
.search-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

/* Gemeinsame Stile für Inputs und Selects */
#locationInput,
#fuelType,
#radius {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
}

#locationInput {
  flex: 1;
  min-width: 200px;
}

#locationInput:focus,
#fuelType:focus,
#radius:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.2);
}

#fuelType option,
#radius option {
  background: var(--bg-card);
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-red);
  border: 1px solid var(--accent-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-red-hover);
  border-color: var(--accent-red-hover);
  box-shadow: var(--shadow);
  transform: scale(1.02);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.btn-outline:hover {
  background: var(--accent-red);
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   API-KEY-WARNUNGS-BANNER
   ============================================================ */
.api-warning {
  display: none; /* wird per JS eingeblendet */
  background: rgba(230, 57, 70, 0.1);
  border-left: 4px solid var(--accent-red);
  color: var(--text-primary);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  max-width: 900px;
  margin: 0 auto 8px;
}

/* ============================================================
   STATISTIK-LEISTE
   ============================================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 20px;
}

.stat-tile {
  background: var(--bg-card);
  border-top: 3px solid var(--accent-red);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.stat-min { color: var(--accent-green); }
.stat-max { color: var(--accent-red); }

/* ============================================================
   HAUPTBEREICH (Liste + Karte)
   ============================================================ */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 32px;
  align-items: start;
}

.column-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

/* ============================================================
   TANKSTELLEN-KARTEN
   ============================================================ */
.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: default;
  transition: var(--transition);
}

.station-card:hover {
  border-color: var(--accent-red);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* Günstigste Tankstelle: grüner linker Rand */
.station-card.cheapest {
  border-left: 4px solid var(--accent-green);
  background: rgba(46, 204, 113, 0.04);
}

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

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-rank {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.station-card.cheapest .card-rank {
  background: rgba(46, 204, 113, 0.15);
  color: var(--accent-green);
}

.card-address {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.card-price {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.card-price.price-cheap  { color: var(--accent-green); }
.card-price.price-mid    { color: var(--text-primary); }
.card-price.price-exp    { color: var(--accent-red); }

.card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 3px 8px;
}

.badge-distance {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-open {
  background: rgba(46, 204, 113, 0.15);
  color: var(--accent-green);
}

.badge-closed {
  background: rgba(230, 57, 70, 0.15);
  color: var(--accent-red);
}

/* ============================================================
   LADEANIMATION
   ============================================================ */
.loader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(230, 57, 70, 0.2);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   FEHLERMELDUNG
   ============================================================ */
.error-msg {
  background: rgba(230, 57, 70, 0.1);
  border: 1px solid rgba(230, 57, 70, 0.4);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 12px;
}

/* ============================================================
   KARTE
   ============================================================ */
.map-column {
  position: sticky;
  top: 80px;
}

#map {
  height: 500px;
  border-radius: var(--radius-card);
  border: 1px solid var(--accent-red);
  overflow: hidden;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
  z-index: 1;
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 16px;
  color: var(--accent-red);
}

.modal-content h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 6px;
  color: var(--text-primary);
}

.modal-content p,
.modal-content li {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.6;
}

.modal-content ul {
  padding-left: 18px;
}

.modal-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--accent-red);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--accent-red-hover);
  transform: scale(1.2);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   COOKIE-BANNER
   ============================================================ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 2px solid var(--accent-red);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  z-index: 500;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.cookie-text {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
  line-height: 1.5;
}

.cookie-text strong {
  color: var(--text-primary);
}

.cookie-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.cookie-actions .btn {
  padding: 8px 20px;
  font-size: 13px;
}

@media (max-width: 768px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .cookie-actions {
    flex-direction: column;
  }
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ============================================================
   RESPONSIVE: < 768px
   ============================================================ */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    align-items: flex-start;
  }

  .main-content {
    grid-template-columns: 1fr;
  }

  .map-column {
    position: static;
    order: -1; /* Karte über der Liste auf Mobil */
  }

  #map {
    height: 300px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-value {
    font-size: 18px;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  #locationInput {
    min-width: unset;
  }
}
