/* ─────────────────────────────────────────────
   TKS Cheapest – Tankstellen Widget
   Google Font: Barlow Condensed (Nummern), Barlow (Text)
───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700&family=Barlow:wght@400;500;600&display=swap');

/* Leere WordPress-Paragraphen um den Shortcode verstecken */
.tks-cheapest-widget + p:empty,
p:empty + .tks-cheapest-widget,
p:has(> .tks-cheapest-widget) {
  margin: 0;
  padding: 0;
}
/* WordPress Theme-Reset: Bullet-Punkte und Striche neben dem Widget entfernen */
li:has(> .tks-cheapest-widget) {
  list-style: none !important;
  margin-left: 0 !important;
  padding-left: 0 !important;
}
ul:has(> li > .tks-cheapest-widget),
ul:has(> .tks-cheapest-widget) {
  list-style: none !important;
  padding-left: 0 !important;
  margin-left: 0 !important;
}

/* ── CSS Custom Properties ───────────────── */
.tks-cheapest-widget {
  --tks-bg:          #ffffff;
  --tks-bg-subtle:   #f8f9fb;
  --tks-border:      #e2e6ea;
  --tks-accent:      #e8390e;
  --tks-accent-dark: #c4300b;
  --tks-text:        #1a1d21;
  --tks-muted:       #6b7280;
  --tks-green:       #16a34a;
  --tks-red:         #dc2626;
  --tks-gold:        #d97706;
  --tks-radius:      14px;
  --tks-shadow:      0 2px 16px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);

  font-family: 'Barlow', -apple-system, sans-serif;
  font-size: 15px;
  color: var(--tks-text);
  background: var(--tks-bg);
  border: 1.5px solid var(--tks-border);
  border-radius: var(--tks-radius);
  padding: 20px 22px 18px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: var(--tks-shadow);
  box-sizing: border-box;
}

/* ── Widget-Titel ────────────────────────── */
.tks-widget-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--tks-text);
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tks-widget-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 20px;
  background: var(--tks-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Haupt-Button ────────────────────────── */
.tks-cheapest-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--tks-accent);
  color: #fff;
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 22px;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background .18s ease, transform .14s ease, box-shadow .18s ease;
  box-shadow: 0 3px 10px rgba(232,57,14,.30);
  white-space: nowrap;
}
.tks-cheapest-btn::before {
  content: '📍';
  font-size: 16px;
}
.tks-cheapest-btn:hover:not(:disabled) {
  background: var(--tks-accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(232,57,14,.35);
}
.tks-cheapest-btn:active:not(:disabled) {
  transform: translateY(0);
}
.tks-cheapest-btn:disabled,
.tks-cheapest-btn.tks-btn--loading {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Spinner ─────────────────────────────── */
@keyframes tks-spin {
  to { transform: rotate(360deg); }
}
.tks-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(232,57,14,.25);
  border-top-color: var(--tks-accent);
  border-radius: 50%;
  animation: tks-spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Status-Box ──────────────────────────── */
.tks-status {
  display: none;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}
.tks-status--loading {
  background: #fff7f5;
  color: var(--tks-accent);
  border: 1px solid #fcd5c9;
}
.tks-status--error {
  background: #fef2f2;
  color: var(--tks-red);
  border: 1px solid #fecaca;
}
.tks-status--empty {
  background: var(--tks-bg-subtle);
  color: var(--tks-muted);
  border: 1px solid var(--tks-border);
}

/* ── Ergebnis-Container ──────────────────── */
.tks-cheapest-result {
  margin-top: 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s ease, transform .3s ease;
}
.tks-cheapest-result.tks-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Ergebnis-Header ─────────────────────── */
.tks-result-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tks-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
}
.tks-fuel-icon {
  font-size: 16px;
}

/* ── Stations-Liste ──────────────────────── */
.tks-stations {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1.5px solid var(--tks-border);
  border-radius: var(--tks-radius);
  overflow: hidden;
}

/* ── Einzelne Tankstelle ─────────────────── */
.tks-station {
  display: flex;
  align-items: flex-start;
  gap: 0;
  background: var(--tks-bg);
  border-bottom: 1px solid var(--tks-border);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .25s ease var(--delay, 0ms), transform .25s ease var(--delay, 0ms), background .15s ease;
}
/* Leichter Kraftstoff-Farbton im Ergebnis-Bereich */
.tks-cheapest-result .tks-station,
.tks-overview-section .tks-station {
  background: color-mix(in srgb, var(--tks-fuel-bg, #e8390e) 4%, var(--tks-bg));
}
.tks-cheapest-result .tks-station:hover,
.tks-overview-section .tks-station:hover {
  background: color-mix(in srgb, var(--tks-fuel-bg, #e8390e) 9%, var(--tks-bg));
}
@supports not (color: color-mix(in srgb, red 4%, white)) {
  .tks-cheapest-result .tks-station,
  .tks-overview-section .tks-station { background: var(--tks-bg-subtle); }
}
.tks-station:last-child {
  border-bottom: none;
}
.tks-station--visible {
  opacity: 1;
  transform: translateX(0);
}
.tks-station:hover {
  background: var(--tks-bg-subtle);
}

/* Rang-Badge links */
.tks-station__rank {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #c0c8d0;
  min-width: 44px;
  padding: 14px 0 14px 16px;
  line-height: 1;
  user-select: none;
}
.tks-station:nth-child(2) .tks-station__rank { color: #9ba5b0; }
.tks-station:nth-child(3) .tks-station__rank { color: #9ba5b0; }
.tks-station:nth-child(4) .tks-station__rank { color: #9ba5b0; }
.tks-station:nth-child(5) .tks-station__rank { color: #9ba5b0; }
.tks-station:first-child .tks-station__rank {
  color: var(--tks-gold);
}

/* Body */
.tks-station__body {
  flex: 1;
  padding: 13px 16px 13px 8px;
  min-width: 0;
}

/* Header: Name + Preis */
.tks-station__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.tks-station__name {
  font-weight: 600;
  font-size: 15px;
  color: var(--tks-text);
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}
.tks-station__brand {
  font-size: 12px;
  font-weight: 400;
  color: var(--tks-muted);
  background: var(--tks-bg-subtle);
  border: 1px solid var(--tks-border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Preis: groß und auffällig */
.tks-station__price {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--tks-accent);
  white-space: nowrap;
  line-height: 1;
}
.tks-station:first-child .tks-station__price {
  font-size: 30px;
}
.tks-station__price sup {
  font-size: 14px;
  vertical-align: super;
  font-weight: 600;
}

/* Adresse */
.tks-station__addr {
  font-size: 13px;
  color: var(--tks-muted);
  margin: 5px 0 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Meta-Zeile */
.tks-station__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tks-meta-item {
  font-size: 12px;
  color: var(--tks-muted);
  font-weight: 500;
}

/* ── Badges ──────────────────────────────── */
.tks-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .2px;
}
.tks-badge--open {
  background: #dcfce7;
  color: var(--tks-green);
  border: 1px solid #bbf7d0;
}
.tks-badge--closed {
  background: #fee2e2;
  color: var(--tks-red);
  border: 1px solid #fecaca;
}
.tks-badge--cheapest {
  background: #fef3c7;
  color: var(--tks-gold);
  border: 1px solid #fde68a;
}

/* ── Maps-Link ───────────────────────────── */
.tks-maps-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tks-accent);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid rgba(232,57,14,.2);
  transition: background .15s, color .15s;
}
.tks-maps-link:hover {
  background: var(--tks-accent);
  color: #fff;
  border-color: var(--tks-accent);
}

/* ── Attribution ─────────────────────────── */
.tks-attribution {
  margin-top: 12px;
  font-size: 11px;
  color: var(--tks-muted);
  opacity: .75;
  letter-spacing: .2px;
}
.tks-attribution a {
  color: var(--tks-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Dark-Mode-Support ───────────────────── */
@media (prefers-color-scheme: dark) {
  .tks-cheapest-widget {
    --tks-bg:        #1e2126;
    --tks-bg-subtle: #252930;
    --tks-border:    #323740;
    --tks-text:      #f0f1f3;
    --tks-muted:     #8b95a1;
  }
  .tks-station__brand {
    background: var(--tks-bg-subtle);
  }
  .tks-badge--open    { background: #14532d; border-color: #166534; color: #4ade80; }
  .tks-badge--closed  { background: #450a0a; border-color: #7f1d1d; color: #f87171; }
  .tks-badge--cheapest{ background: #451a03; border-color: #92400e; color: #fbbf24; }
  .tks-status--loading{ background: #2a1a16; border-color: #7f3a28; }
  .tks-status--error  { background: #2d1515; border-color: #7f2020; }
  .tks-status--empty  { background: var(--tks-bg-subtle); }
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 460px) {
  .tks-cheapest-widget { padding: 16px 14px 14px; }
  .tks-station__price  { font-size: 22px; }
  .tks-station:first-child .tks-station__price { font-size: 26px; }
  .tks-station__rank   { min-width: 34px; padding-left: 12px; font-size: 18px; }
  .tks-station__addr   { white-space: normal; }
}

/* ── Overview-Widget ─────────────────────── */
.tks-overview-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.tks-overview-section {
  border: 1.5px solid var(--tks-border);
  border-radius: 12px;
  overflow: hidden;
}

.tks-overview-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--fuel-color, #e8390e);
  background: color-mix(in srgb, var(--fuel-color, #e8390e) 8%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--fuel-color, #e8390e) 18%, transparent);
}

.tks-overview-radius {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  opacity: .7;
  font-family: 'Barlow', sans-serif;
  text-transform: none;
  letter-spacing: 0;
}

.tks-overview-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--tks-muted);
}

/* Im Overview-Widget: Stationen kompakter */
.tks-overview-section .tks-station__rank {
  font-size: 18px;
  min-width: 36px;
  padding-left: 12px;
}
.tks-overview-section .tks-station__price {
  font-size: 22px;
}
.tks-overview-section .tks-station:first-child .tks-station__price {
  font-size: 25px;
}

/* color-mix Fallback für ältere Browser */
@supports not (color: color-mix(in srgb, red 10%, white)) {
  .tks-overview-header {
    background: rgba(0,0,0,.04);
    border-bottom-color: var(--tks-border);
  }
}

/* ── PLZ-Eingabe & Input-Zeile ───────────── */
.tks-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tks-or {
  font-size: 13px;
  color: var(--tks-muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.tks-plz-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--tks-border);
  border-radius: 9px;
  overflow: hidden;
  transition: border-color .18s;
  flex: 1;
  min-width: 160px;
  max-width: 220px;
}
.tks-plz-wrap:focus-within {
  border-color: var(--tks-accent);
}

.tks-plz-input {
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  background: var(--tks-bg);
  color: var(--tks-text);
  width: 100%;
  min-width: 0;
}
.tks-plz-input::placeholder {
  color: var(--tks-muted);
  opacity: .7;
}
.tks-plz-input.tks-plz-highlight {
  animation: tks-plz-pulse 1.2s ease 2;
}
@keyframes tks-plz-pulse {
  0%,100% { background: var(--tks-bg); }
  40%      { background: #fff3f0; }
}

.tks-plz-btn {
  border: none;
  border-left: 1.5px solid var(--tks-border);
  background: var(--tks-bg-subtle);
  color: var(--tks-accent);
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.tks-plz-btn:hover:not(:disabled) {
  background: var(--tks-accent);
  color: #fff;
  border-left-color: var(--tks-accent);
}
.tks-plz-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

@media (max-width: 420px) {
  .tks-input-row  { flex-direction: column; align-items: stretch; }
  .tks-or         { text-align: center; }
  .tks-plz-wrap   { max-width: 100%; }
  .tks-cheapest-btn { width: 100%; justify-content: center; }
}
