/* ============================================================
   EFFEKTANK – Design
   Frosted Glass · Ersparnisse im Fokus · Intuitiv
   ============================================================ */

/* ── Design Tokens: Dark ────────────────────────────────────── */
:root, .theme-dark {
  --c-bg:          #0a0e14;
  --c-bg-soft:     rgba(10, 14, 20, 0.6);
  --c-surface:     rgba(18, 24, 34, 0.75);
  --c-surface-2:   rgba(22, 30, 44, 0.85);
  --c-border:      rgba(255, 255, 255, 0.08);
  --c-text:        #e8ecf2;
  --c-text-muted:  #8a9aad;
  --c-accent:      #f59e0b;
  --c-accent-soft: rgba(245, 158, 11, 0.2);
  --c-accent-dark: #1a0f00;
  --c-ok:          #34d399;
  --c-ok-soft:    rgba(52, 211, 153, 0.15);
  --c-warn:        #f5a820;
  --c-danger:     #f5524e;
}

/* ── Light Theme ───────────────────────────────────────────── */
.theme-light {
  --c-bg:          #eef1f6;
  --c-bg-soft:     rgba(238, 241, 246, 0.8);
  --c-surface:     rgba(255, 255, 255, 0.85);
  --c-surface-2:   rgba(255, 255, 255, 0.95);
  --c-border:      rgba(0, 0, 0, 0.08);
  --c-text:        #1a1d24;
  --c-text-muted:  #5c6478;
  --c-accent:      #d97706;
  --c-accent-soft: rgba(217, 119, 6, 0.15);
  --c-accent-dark: #ffffff;
  --c-ok:          #059669;
  --c-ok-soft:    rgba(5, 150, 105, 0.12);
}

:root {
  --header-h:      3.25rem;
  --nav-h:         3.75rem;
  --radius-s:      10px;
  --radius-m:      14px;
  --radius-l:      18px;
  --dur:           180ms;
  --glow:          0 0 20px rgba(245, 158, 11, 0.15);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  overflow: hidden;
  min-height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── App Shell ──────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* ── Frosted Glass ──────────────────────────────────────────── */
.glass {
  background: var(--c-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--c-border);
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 0.6rem) 1rem 0.6rem;
  background: var(--c-bg-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
  z-index: 20;
}

.app-header__top { display: contents; }

.app-header__title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--c-accent);
  line-height: 1.2;
}

.app-header__sub {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  line-height: 1.3;
}

.btn-theme {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  background: var(--c-surface);
  color: var(--c-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-theme .theme-icon { width: 1.2rem; height: 1.2rem; }
.btn-theme .theme-icon.hidden { display: none; }

/* ── Main ──────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.panel {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur) ease;
}

.panel--active {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

.panel-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 1rem 1rem 2rem;
}

/* ── Cards (Frosted) ───────────────────────────────────────── */
.card {
  background: var(--c-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.card-hint {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  margin: -0.3rem 0 0.6rem;
}

/* ── Form ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 0.75rem; }
.form-group:last-child { margin-bottom: 0; }

.form-hint {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 0.2rem;
}

.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-bottom: 0.25rem;
}

.input {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--c-text);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-s);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a9aad' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

.textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

.input-unit-wrap { position: relative; display: flex; align-items: center; }
.input-unit-wrap .input { padding-right: 3.5rem; }
.input-unit {
  position: absolute;
  right: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-text-muted);
  pointer-events: none;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur), opacity var(--dur), transform 80ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--c-accent);
  color: var(--c-accent-dark);
  border-color: var(--c-accent);
  box-shadow: var(--glow);
}

.btn--primary:hover {
  background: #fbbf24;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.25);
}

.btn--secondary {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn--ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: var(--c-border);
}

.btn--large { font-size: 1.05rem; min-height: 52px; }
.btn--full { width: 100%; }
.btn--icon { padding: 0.6rem 0.8rem; flex-shrink: 0; }
.btn-icon-svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Suche ──────────────────────────────────────────────────── */
.inline-row { display: flex; gap: 0.5rem; align-items: center; }
.select-inline { flex: 1; min-width: 0; }
.position-display { margin-bottom: 0.75rem; }
.info-line { font-size: 0.85rem; line-height: 1.4; padding: 0.08rem 0; }
.info-line--muted { color: var(--c-text-muted); }
.info-line--ok { color: var(--c-ok); }
.info-line--warn { color: var(--c-warn); }
.form-group--detour.hidden { display: none; }
.form-actions { display: flex; flex-direction: column; gap: 0.5rem; padding: 0 0 0.5rem; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--c-text-muted);
}

.empty-state__icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}
.empty-state__icon .ph { font-size: 1em; }

.empty-state__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 0.3rem;
}

.empty-state__hint { font-size: 0.85rem; }

/* ── Best Card (Ersparnis Hero) ─────────────────────────────── */
.best-card {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-l);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.08);
}

.best-card__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1rem;
}

.best-card__saving-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.best-card__saving-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--c-accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.best-card__saving-value--negative {
  color: var(--c-danger);
}

.best-card__saving-hint {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-top: 0.25rem;
}

.best-card__station {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--c-border);
}

.best-card__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
}

.best-card__place {
  font-size: 0.85rem;
  color: var(--c-text-muted);
}

.best-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--c-border);
  font-size: 0.8rem;
  color: var(--c-text-muted);
}

.best-card__meta-item strong { color: var(--c-text); }

/* ── Result Cards (Ersparnis zuerst) ───────────────────────── */
.results-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0.5rem 0 0.4rem;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-card {
  background: var(--c-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  padding: 0.85rem 1rem;
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  grid-template-rows: auto auto auto auto;
  column-gap: 0.75rem;
  row-gap: 0.15rem;
  align-items: center;
}

.result-card__saving {
  grid-column: 1;
  grid-row: 2;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--c-accent);
  text-align: center;
  line-height: 1.1;
}

.result-card__saving--negative {
  color: var(--c-danger);
}

.result-card__saving-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.result-card__body {
  grid-column: 2;
  grid-row: 1 / 3;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.result-card__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-card__sub {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 0.2rem;
}

.result-card__total {
  grid-column: 3;
  grid-row: 1 / 3;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text);
  text-align: right;
}

.result-card__toggle {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0;
  border: none;
  background: transparent;
  color: var(--c-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-s);
  transition: color var(--dur), background var(--dur);
}

.result-card__toggle:hover {
  color: var(--c-accent);
  background: var(--c-accent-soft);
}

.result-card__toggle-icon {
  width: 1rem;
  height: 1rem;
  transition: transform var(--dur) ease;
}

.result-card__toggle[aria-expanded="true"] .result-card__toggle-icon {
  transform: rotate(180deg);
}

.result-card__details {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: var(--c-surface-2);
  border-radius: var(--radius-s);
  border: 1px solid var(--c-border);
}

.result-card__detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--c-text-muted);
  padding: 0.25rem 0;
}

.result-card__detail-row span { flex: 1; min-width: 0; }
.result-card__detail-row strong { flex-shrink: 0; color: var(--c-text); }

.result-card__detail-row--total {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--c-border);
  font-weight: 600;
  color: var(--c-text);
}

/* ── Map ───────────────────────────────────────────────────── */
.map-container {
  height: 180px;
  border-radius: var(--radius-m);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
}

.map-marker { background: none !important; border: none !important; }
.map-marker--user { font-size: 1.3rem; }
.map-marker--station .map-marker__label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--c-accent);
  color: var(--c-accent-dark);
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 50%;
  border: 2px solid var(--c-surface);
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
}
.map-tooltip { font-size: 0.8rem; padding: 0.4rem 0.5rem; }

/* ── Bottom Nav ────────────────────────────────────────────── */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--c-bg-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 20;
}

.bottom-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: var(--nav-h);
  padding: 0.4rem 0.25rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--dur);
}

.bottom-nav__btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2.5px;
  background: var(--c-accent);
  border-radius: 0 0 3px 3px;
  transform: scaleX(0);
  transition: transform var(--dur) ease;
}

.bottom-nav__btn--active {
  color: var(--c-accent);
}

.bottom-nav__btn--active::after { transform: scaleX(1); }
.bottom-nav__btn:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.nav-icon { width: 1.3rem; height: 1.3rem; }
.nav-label { font-size: 0.68rem; font-weight: 500; }

/* ── Loading ───────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: 0.95rem; color: var(--c-text-muted); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  left: 50%;
  transform: translateX(-50%) translateY(0.75rem);
  background: var(--c-surface-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  max-width: min(88vw, 360px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--ok     { border-color: var(--c-ok);     color: var(--c-ok); }
.toast--error  { border-color: var(--c-danger);  color: var(--c-danger); }
.toast--warn   { border-color: var(--c-warn);    color: var(--c-warn); }

.hidden { display: none !important; }

/* ── Desktop ───────────────────────────────────────────────── */
@media (min-width: 641px) {
  body { background: #050810; }
  .app {
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
    box-shadow: 0 0 60px rgba(0,0,0,0.4);
  }
}
