/**
 * app.css — Digitale Rendite Rechner, seitenspezifische Styles
 */

/* YAML-Import-Formular in der Bibliothek */
.yaml-import-form {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

.yaml-import-form input[type="file"] {
  font-size: var(--t-small-size);
  color: var(--t-text-secondary);
  max-width: 240px;
}

/* Beispiel uebernehmen: ein Auswahlfeld statt Kacheln (Issue #79) */
.beispiel-wahl {
  display: flex;
  flex-direction: column;
  gap: var(--t-form-label-gap);
  margin-bottom: var(--t-gap-section);
  max-width: 640px;
}

.beispiel-wahl-zeile {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.beispiel-wahl-zeile .metro-btn { flex-shrink: 0; }

/* Formular-Abschnitte */
.form-section { margin-bottom: var(--t-gap-section); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding-top: var(--t-gap-group);
}

/* Ergebnis-Seite */
.result-section {
  margin-bottom: var(--t-gap-section);
}

.empfehlung-box {
  background: var(--t-accent-light);
  padding: 20px 24px;
  border-radius: var(--t-radius-md);
  margin-top: var(--t-gap-group);
  font-size: var(--t-body-size);
  line-height: 1.6;
  max-width: 80ch;
}

/* Kosten-Vergleichstabelle */
.kosten-tabelle .delta-positiv { color: var(--t-red-text); }
.kosten-tabelle .delta-negativ { color: var(--t-green-text); font-weight: 700; }

.kosten-tabelle-hinweis {
  margin-top: 12px;
  font-size: var(--t-small-size);
  line-height: 1.5;
  color: var(--t-text-secondary);
}

/* Ratsvorlage Preview (gerendertes Markdown) */
.ratsvorlage-preview {
  background: var(--t-surface-white);
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius-md);
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  max-height: 480px;
  overflow-y: auto;
  font-family: var(--t-font-body);
}
.ratsvorlage-preview h1,
.ratsvorlage-preview h2,
.ratsvorlage-preview h3,
.ratsvorlage-preview h4 {
  font-family: var(--t-font-display);
  color: var(--t-accent);
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
}
.ratsvorlage-preview h1 { font-size: 1.5em; }
.ratsvorlage-preview h2 { font-size: 1.25em; }
.ratsvorlage-preview h3 { font-size: 1.1em; }
.ratsvorlage-preview > *:first-child { margin-top: 0; }
.ratsvorlage-preview p { margin: 0.6em 0; }
.ratsvorlage-preview ul,
.ratsvorlage-preview ol { margin: 0.6em 0; padding-left: 1.4em; }
.ratsvorlage-preview li { margin: 0.25em 0; }
.ratsvorlage-preview strong { font-weight: 600; }
.ratsvorlage-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.95em;
}
.ratsvorlage-preview th,
.ratsvorlage-preview td {
  border: 1px solid var(--t-border);
  padding: 6px 10px;
  text-align: left;
}
.ratsvorlage-preview th {
  background: var(--t-accent);
  color: #fff;
  font-weight: 600;
}
.ratsvorlage-preview tr:nth-child(even) td { background: var(--t-bg); }
.ratsvorlage-preview hr {
  border: none;
  border-top: 1px solid var(--t-border);
  margin: 1.2em 0;
}

/* Info-Icon mit Tooltip: nur noch in Tabellenzellen (Ergebnis, Detailansicht),
   wo kein Platz fuer eine Hilfezeile ist. Im Formular ersetzt .metro-hilfe ihn. */
.metro-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--t-accent);
  color: var(--t-accent);
  font-size: 12px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  position: relative;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
}

.metro-info-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  padding: 14px 16px;
  background: var(--t-surface-white);
  color: var(--t-text);
  border: 1.5px solid var(--t-border);
  font-family: var(--t-font-body);
  font-size: var(--t-small-size);
  font-weight: 400;
  line-height: 1.55;
  border-radius: var(--t-radius-md);
  box-shadow: var(--t-shadow-md);
  z-index: 100;
  pointer-events: none;
}

.metro-info-tip strong {
  color: var(--t-text);
  display: block;
  margin-top: 4px;
}

.metro-info:hover .metro-info-tip,
.metro-info:focus .metro-info-tip,
.metro-info:focus-visible .metro-info-tip {
  display: block;
  pointer-events: auto;
}

/* KI-Toggle */
.ki-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.ki-toggle input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--t-accent);
  cursor: pointer;
}

.ki-toggle-label {
  font-size: var(--t-body-size);
  font-weight: 700;
  color: var(--t-text);
}

.ki-toggle-hint {
  font-size: var(--t-small-size);
  color: var(--t-text-secondary);
}

.ki-datenschutz-link {
  font-size: var(--t-small-size);
  color: var(--t-accent);
}

.ki-datenschutz-link:hover { text-decoration: underline; }

/* Optionale Felder Toggle */
.optional-toggle {
  font-size: var(--t-body-size);
  font-weight: 700;
  color: var(--t-accent);
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: var(--t-gap-group);
  user-select: none;
}

.optional-toggle:hover { text-decoration: underline; }

.optional-fields {
  display: none;
  animation: fadeIn 0.2s ease;
}

.optional-fields.visible { display: block; }

/* ============================================================
   Hilfe-Seite
   ============================================================ */
.hilfe-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  background: var(--t-surface);
  border-radius: var(--t-radius-md);
  margin-bottom: var(--t-gap-section);
}

.hilfe-nav a {
  font-size: var(--t-small-size);
  font-weight: 700;
  color: var(--t-text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--t-radius-sm);
  transition: all var(--t-transition);
}

.hilfe-nav a:hover {
  background: var(--t-accent-light);
  color: var(--t-accent);
}

.hilfe-section { scroll-margin-top: var(--t-header-offset); }
.hilfe-section h3 {
  font-family: var(--t-font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--t-text);
  margin: 20px 0 8px 0;
}

.hilfe-section p, .hilfe-section li {
  font-size: var(--t-body-size);
  max-width: 75ch;
  line-height: 1.7;
  color: var(--t-text);
}

.hilfe-section ul { padding-left: 20px; margin: 8px 0 16px 0; }
.hilfe-section li { margin-bottom: 4px; }

.hilfe-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0;
}

.hilfe-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  background: var(--t-surface);
  border-radius: var(--t-radius-md);
}

.hilfe-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--t-accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hilfe-card-text { font-size: var(--t-small-size); line-height: 1.5; }

.hilfe-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.hilfe-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 16px;
  background: var(--t-surface);
  border-radius: var(--t-radius-md);
}

.hilfe-step-nr {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--t-accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hilfe-step div { font-size: var(--t-body-size); line-height: 1.5; }

.hilfe-tipp {
  background: var(--t-accent-light);
  padding: 12px 16px;
  border-radius: var(--t-radius-md);
  margin: 16px 0;
  font-size: var(--t-small-size);
  line-height: 1.6;
}

.faq-item { margin-bottom: 20px; }
.faq-item h3 {
  font-size: var(--t-body-size);
  font-weight: 700;
  color: var(--t-text);
  margin-bottom: 4px;
}
.faq-item p { font-size: var(--t-body-size); line-height: 1.6; margin: 0; }

@media (max-width: 768px) {
  .hilfe-cards { grid-template-columns: 1fr; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Fortschritts-Overlay
   ============================================================ */
.progress-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(var(--t-ink-rgb), 0.72);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.progress-overlay.visible {
  display: flex;
}

.progress-card {
  background: var(--t-surface-white);
  border-radius: var(--t-radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 40px 48px;
  min-width: 420px;
  max-width: 500px;
  animation: fadeIn 0.3s ease;
}

.progress-title {
  font-family: var(--t-font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--t-text);
  margin: 0 0 24px 0;
}

.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--t-font-body);
  font-size: 15px;
  padding: 10px 14px;
  border-radius: var(--t-radius-md);
  transition: all 0.2s ease;
}

.progress-step.pending {
  color: var(--t-text-secondary);
  background: transparent;
}

.progress-step.running {
  color: var(--t-accent);
  background: var(--t-accent-light);
  font-weight: 700;
}

.progress-step.done {
  color: var(--t-green-text);
  background: var(--t-green-bg);
}

.step-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.progress-step.done .step-icon {
  font-weight: 700;
  font-size: 18px;
}

.step-label {
  flex: 1;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--t-accent-light);
  border-top-color: var(--t-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.progress-status {
  font-family: var(--t-font-body);
  font-size: 13px;
  color: var(--t-text-secondary);
  margin: 0;
  text-align: center;
}

/* Szenario-Bibliothek */
.metro-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--t-radius-pill);
  font-size: var(--t-caption-size);
  font-weight: 700;
  background: var(--t-surface);
  color: var(--t-text-secondary);
  border: 1px solid var(--t-surface);
}
.metro-badge.accent {
  background: var(--t-accent);
  color: #fff;
  border-color: var(--t-accent);
}
.szenario-aktionen { white-space: nowrap; }
.szenario-aktionen .metro-btn,
.szenario-aktionen form { margin-left: 4px; }

/* Szenario-Detailansicht: farbige Gruppenkopfzeile */
.szenario-gruppe {
  background: var(--t-accent-light);
  color: var(--t-text);
  font-family: var(--t-font-display);
  font-size: var(--t-body-size);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--t-radius-sm);
  margin: 1.6rem 0 0.4rem;
}
.szenario-gruppe:first-of-type { margin-top: 0.4rem; }

/* Detailansicht: (i)-Icon vor dem Parameter-Label, ruhige linke Spalte */
.szenario-param .metro-info { margin-left: 0; margin-right: 8px; }

/* Neuigkeiten-Seite und Was-ist-neu-Dialog (Paket web-changelog).
   Markup und Layout liefert die Bibliothek; hier werden nur ihre Tokens auf
   die Design-Tokens dieser Anwendung gelegt, damit die Seite im
   Design der Anwendung bleibt. Kommen neue Rubriken dazu, braucht es hier
   nichts: die Bibliothek bringt die Klassen wc-badge-<art> selbst mit. */
.wc-root {
  --wc-akzent: var(--t-accent, #1C4195);
  --wc-akzent-subtil: var(--t-accent-light, #EAF0FB);
  --wc-gruen: var(--t-green-text, #1B5E20);
  --wc-gruen-bg: var(--t-green-bg, #E6F4EC);
  --wc-bg: var(--t-bg, #FAFAF8);
  --wc-flaeche: var(--t-surface-white, #FFFFFF);
  --wc-flaeche-alt: var(--t-surface, #F2F1EC);
  --wc-text: var(--t-text, #1A1A1A);
  --wc-text-schwach: var(--t-text-secondary, #6B6B63);
  --wc-text-leise: var(--t-text-secondary, #4A5A80);
  --wc-rand: var(--t-border, #E2E1DC);
  --wc-rand-leicht: var(--t-border-light, #E6E4DD);
  --wc-radius: var(--t-radius-md, 8px);
  --wc-radius-pill: var(--t-radius-pill, 999px);
  --wc-font-mono: var(--t-font-mono, monospace);
  --wc-schatten: var(--t-shadow-md, 0 2px 8px rgba(0, 0, 0, 0.08));
}
/* Anmeldeseite: schmale, ruhige Spalte statt Formular ueber die volle Breite.
   Feldaufbau und Aktionszeile kommen aus .metro-field und .form-actions;
   hier nur die Abstaende der beiden Hinweistexte darum herum. */
.anmelden-tile { max-width: 32rem; }
.anmelden-tile > .metro-hint { margin-bottom: var(--t-gap-group); }
.anmelden-tile > .metro-hint:last-child { margin: var(--t-gap-group) 0 0; }

/* TCO-/Strategievergleich-Editor */
.tco-szenario { border-left: 4px solid var(--t-accent); }
.tco-szenario-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.tco-positionen { width: 100%; }
.tco-positionen td { padding: 3px 4px; }
.tco-positionen input, .tco-positionen select { width: 100%; }
.tco-nwa { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.75rem; }
.tco-nwa label { display: flex; flex-direction: column; font-size: 0.8rem; gap: 2px; }
.tco-nwa input { width: 64px; }
.tco-ampel-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.tco-bar { height: 10px; border-radius: 5px; background: var(--t-accent); }

/* ============================================================
   Nutzwertanalyse: Eingabe der Kommune (Issue #28)
   ============================================================ */
.nwa-eingabe { margin-top: 12px; }
.nwa-zeile { border-top: 1px solid var(--t-border-light); padding: 14px 0 6px; }
.nwa-zeile:first-child { border-top: 0; padding-top: 0; }
.nwa-zeile-kopf { margin-bottom: 6px; }
.nwa-zeile-felder {
  display: grid;
  grid-template-columns: 150px 150px 110px minmax(0, 1fr);
  gap: var(--t-gap-group, 12px);
  align-items: end;
}
.nwa-zeile-felder .metro-field { margin: 0; }
.nwa-begruendung textarea { min-height: 42px; }
@media (max-width: 900px) {
  .nwa-zeile-felder { grid-template-columns: 1fr 1fr; }
  .nwa-begruendung { grid-column: 1 / -1; }
}

/* Ampelpunkt in Ergebnistabellen */
.nwa-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px;
}
.nwa-dot-rot { background: var(--t-red); }
.nwa-dot-gelb { background: var(--t-amber); }
.nwa-dot-gruen { background: var(--t-green); }
.nwa-herkunft { font-size: var(--t-caption-size); color: var(--t-text-secondary); white-space: nowrap; }
