/*
 * Was kostet mein Auto? – Haupt-Stylesheet
 * Alle visuellen Stile der Anwendung.
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
header h1 { font-size: 1.3rem; font-weight: 700; }
header nav a {
  color: #89b4fa;
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 0.9rem;
}
header nav a:hover { text-decoration: underline; }

/* ── Main ────────────────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }

/* ── Flash ───────────────────────────────────────────────────────────────── */
.flash-notice {
  background: #a6e3a1;
  color: #1e1e2e;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.flash-alert {
  background: #f38ba8;
  color: #1e1e2e;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #eff1f5;
  color: #1e1e2e;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6c6f85;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input,
.form-group select {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #dce0e8;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #1a1a1a;
  background: #fafafa;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #89b4fa;
  background: #fff;
}
.field_with_errors input { border-color: #f38ba8 !important; }
.form-group .hint {
  font-size: 0.75rem;
  color: #9ca0b0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: #89b4fa; color: #1e1e2e; }
.btn-secondary { background: #eff1f5; color: #4c4f69; }
.btn-danger    { background: #f38ba8; color: #1e1e2e; }
.btn-sm        { padding: 0.35rem 0.9rem; font-size: 0.85rem; }

.btn-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Ergebnistabelle ─────────────────────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.result-tile {
  background: #eff1f5;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.result-tile .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c6f85;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.result-tile .value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #1e1e2e;
}
.result-tile.highlight { background: #1e1e2e; }
.result-tile.highlight .label { color: #a6adc8; }
.result-tile.highlight .value { color: #89b4fa; }
.result-tile .sub {
  font-size: 0.78rem;
  color: #9ca0b0;
  margin-top: 2px;
}
/* Depreciation tile – red accent signals the inflation-adjusted loss */
.result-tile.depreciation {
  background: #fef0f2;
  border: 1.5px solid #f38ba8;
}
.result-tile.depreciation .label { color: #b5394f; }
.result-tile.depreciation .value { color: #d20f39; }
.result-tile.depreciation .sub   { color: #c0435a; }

/* ── Aufschlüsselungstabelle ─────────────────────────────────────────────── */
.breakdown table { width: 100%; border-collapse: collapse; }
.breakdown td,
.breakdown th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eff1f5;
  font-size: 0.9rem;
}
.breakdown th { color: #6c6f85; font-size: 0.8rem; text-transform: uppercase; }
.breakdown td:last-child { text-align: right; font-weight: 600; }
.breakdown tr.total td { font-weight: 800; font-size: 1rem; border-top: 2px solid #dce0e8; }
/* Depreciation rows are tinted red so the loss stands out */
.breakdown tr.depreciation-row td { color: #d20f39; }

/* ── Cars-Tabelle ────────────────────────────────────────────────────────── */
.cars-table { width: 100%; border-collapse: collapse; }
.cars-table th,
.cars-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eff1f5;
  font-size: 0.9rem;
}
.cars-table th { background: #eff1f5; font-size: 0.8rem; text-transform: uppercase; color: #6c6f85; }
.cars-table td:not(:first-child) { text-align: right; }
.cars-table th:not(:first-child) { text-align: right; }
.cars-table tr:hover td { background: #f9f9fb; }

/* ── Jahreswerte ─────────────────────────────────────────────────────────── */
.yearly-section {
  margin-top: 1.25rem;
  border: 1.5px dashed #dce0e8;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.yearly-section summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #5c5f77;
  user-select: none;
}
.yearly-section summary::marker { color: #89b4fa; }
.yearly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
/* Label above each yearly-grid row (field name + currency hint) */
.yearly-field-label {
  font-weight: 600;
  font-size: .85rem;
  margin: .75rem 0 .25rem;
  color: #4c4f69;
}

/* ── Page-title cards (reduced bottom margin) ────────────────────────────── */
.card--title { margin-bottom: 0.5rem; }

/* ── Result card (added top spacing to separate from the form) ───────────── */
.card--result { margin-top: 2rem; }

/* ── Breakdown table: right-align the last header cell ──────────────────── */
.breakdown th:last-child { text-align: right; }

/* ── Car show: action-button row ─────────────────────────────────────────── */
.car-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }

/* ── Cars index: empty-state paragraph ──────────────────────────────────── */
.cars-empty-message { color: #6c6f85; margin: 1rem 0; }

/* ── Subtle paragraph text ───────────────────────────────────────────────── */
.text-muted { color: #6c6f85; }

/* ── Error list inside validation flash ──────────────────────────────────── */
.form-error-list { margin-top: .5rem; padding-left: 1.25rem; }

/* ── Compact flash (smaller font, used in tight auth forms) ──────────────── */
.flash-alert--compact { font-size: .85rem; }

/* ── Form: full-width field spanning all grid columns ───────────────────── */
.form-group--full { grid-column: 1 / -1; max-width: 420px; }

/* ── Hint with extra bottom spacing (outside a .form-group) ─────────────── */
.hint--spaced { margin-bottom: .75rem; }

/* ── Error pages ─────────────────────────────────────────────────────────── */
.error-card { text-align: center; padding: 3rem 2rem; }
.error-icon { font-size: 3rem; margin-bottom: 1rem; }
.error-body { margin: 1rem 0 2rem; }

/* ── Header-Right / User ─────────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 0.25rem 0.75rem 0.25rem 0.4rem;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #89b4fa;
  color: #1e1e2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
}
.user-name {
  font-size: 0.82rem;
  color: #cdd6f4;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  background: transparent;
  border: 1.5px solid rgba(205,214,244,.2);
  color: #a6adc8;
  padding: 0.28rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  line-height: 1.5;
}
.btn-logout:hover { border-color: #f38ba8; color: #f38ba8; }

/* ── Locale-Umschalter ───────────────────────────────────────────────────── */
.pref-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.pref-btn {
  background: transparent;
  border: 1.5px solid rgba(205,214,244,.2);
  color: #a6adc8;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pref-btn:hover       { border-color: #89b4fa; background: rgba(137,180,250,.08); }
.pref-btn.pref-active { border-color: #89b4fa; background: rgba(137,180,250,.15); }

/* ── Save Row ────────────────────────────────────────────────────────────── */
.save-row {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 1.25rem 2rem;
  margin-bottom: 1.5rem;
}
.save-row-inner {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.car-name-input {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #dce0e8;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #1a1a1a;
  background: #fafafa;
  transition: border-color .15s;
}
.car-name-input:focus {
  outline: none;
  border-color: #89b4fa;
  background: #fff;
}
.btn-save { background: #a6e3a1; color: #1e1e2e; white-space: nowrap; }
.save-row .hint {
  display: block;
  font-size: 0.75rem;
  color: #9ca0b0;
  margin-top: 0.4rem;
}

/* ── Save Card (unauthenticated) ────────────────────────────────────────── */
.save-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
}
.save-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e1e2e;
  margin: 0 0 0.3rem;
}
.save-subtitle {
  font-size: 0.85rem;
  color: #6c6f85;
  margin: 0 0 1.1rem;
}
.save-card .car-name-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1rem;
}
.save-auth-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.save-auth-buttons .btn {
  flex: 1;
  min-width: 130px;
  justify-content: center;
}
.btn-google-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: #fff;
  border: 1.5px solid #dce0e8;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn-google-save:hover {
  border-color: #89b4fa;
  box-shadow: 0 2px 8px rgba(137,180,250,.2);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: #1e1e2e;
  color: #6c6f85;
  padding: 1.5rem 2rem;
  margin-top: 3rem;
  font-size: 0.82rem;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a {
  color: #6c6f85;
  text-decoration: none;
  transition: color .15s;
}
.footer-links a:hover { color: #cdd6f4; }

/* ── Auth / Login ────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-card h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1e1e2e;
  text-align: center;
  margin-bottom: 0.3rem;
}
.login-subtitle {
  text-align: center;
  color: #6c6f85;
  font-size: 0.88rem;
  margin-bottom: 1.75rem;
}
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6c6f85;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid #dce0e8;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #1a1a1a;
  background: #fafafa;
  transition: border-color .15s;
}
.auth-form input:focus {
  outline: none;
  border-color: #89b4fa;
  background: #fff;
}
.auth-hint { font-size: .75rem; color: #9ca0b0; margin-top: 2px; display: block; }
.remember-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: #4c4f69;
}
.remember-row input[type="checkbox"] { accent-color: #89b4fa; }
.btn-submit {
  width: 100%;
  padding: 0.7rem 1.5rem;
  background: #89b4fa;
  color: #1e1e2e;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-submit:hover { opacity: 0.85; }
.or-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: #9ca0b0;
  font-size: 0.8rem;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #dce0e8;
}
.google-form { margin: 0; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 1.5rem;
  background: #fff;
  border: 1.5px solid #dce0e8;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.btn-google:hover {
  border-color: #89b4fa;
  box-shadow: 0 2px 12px rgba(137,180,250,.2);
}
.btn-google svg { flex-shrink: 0; }
.auth-links {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: #6c6f85;
  line-height: 1.8;
}
.auth-links a {
  color: #89b4fa;
  text-decoration: none;
  font-weight: 600;
}
.auth-links a:hover { text-decoration: underline; }
.auth-pending-notice {
  background: #cba6f7;
  color: #1e1e2e;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

/* ── Account-Einstellungen ───────────────────────────────────────────────── */
.account-section {
  border-bottom: 1.5px solid #eff1f5;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.account-section:last-of-type { border-bottom: none; margin-bottom: 0; }
.account-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4c4f69;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.google-notice {
  background: #eff1f5;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: #6c6f85;
}

/* ── Impressum / Statische Seiten ────────────────────────────────────────── */
.prose { max-width: 680px; }
.prose h2 { font-size: 1.05rem; font-weight: 700; color: #1e1e2e; margin: 1.25rem 0 0.4rem; }
.prose p  { color: #4c4f69; line-height: 1.7; margin-bottom: 0.75rem; }
.prose a  { color: #89b4fa; }

/* ── Sales Optimizer ─────────────────────────────────────────────────────── */

/* "Wann verkaufe ich am besten?" button – teal accent */
.btn-optimizer { background: #a6e3a1; color: #1e1e2e; }

.optimizer-header-meta {
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
  color: #6c6f85;
}

/* ── Optimal recommendation card ── */
.optimizer-best-card { border: 2px solid #a6e3a1; background: #f2fbf2; }
.optimizer-best-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.optimizer-best-header h2 { margin: 0; }
.optimizer-best-signal  { font-size: 1.75rem; }
.optimizer-best-year-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e1e2e;
  margin-bottom: 1rem;
}
.optimizer-best-stats { margin-top: 0; }

/* ── 10-year timeline ── */
.optimizer-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.optimizer-year {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
}
.optimizer-year--green  { background: #f2fbf2; border-color: #a6e3a1; }
.optimizer-year--yellow { background: #fdf6e3; border-color: #f9c74f; }
.optimizer-year--red    { background: #fef0f2; border-color: #f38ba8; }
.optimizer-year--best   { border-width: 2px; box-shadow: 0 2px 8px rgba(166,227,161,.35); }

.optimizer-year__signal { font-size: 1.4rem; padding-top: 2px; flex-shrink: 0; }

.optimizer-year__body { flex: 1; min-width: 0; }

.optimizer-year__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.optimizer-year__n {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e1e2e;
}
.optimizer-year__calendar {
  font-size: 0.82rem;
  color: #6c6f85;
  font-weight: 400;
}

/* Optimal badge */
.optimizer-year__badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #1e1e2e;
  color: #a6e3a1;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Traffic light label pill */
.optimizer-traffic-label {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-left: auto;
}
.optimizer-traffic-label--green  { background: #a6e3a1; color: #1e1e2e; }
.optimizer-traffic-label--yellow { background: #f9c74f; color: #1e1e2e; }
.optimizer-traffic-label--red    { background: #f38ba8; color: #1e1e2e; }

.optimizer-year__cost {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1e1e2e;
  margin-bottom: 0.15rem;
}

.optimizer-year__meta {
  font-size: 0.78rem;
  color: #6c6f85;
}

.optimizer-footnote { background: #eff1f5; }
.optimizer-footnote p { font-size: 0.82rem; color: #9ca0b0; margin: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .user-name { display: none; }
  .cars-table td:nth-child(n+4),
  .cars-table th:nth-child(n+4) { display: none; }
}
