/* Kalkulator ECM-Blue — Kalkulator-Oberflaeche (PR 3)
 * Abgeleitet aus der verifizierten HTML-Vorstufe (scratchpad/hk1_app/styles.css).
 * Farben/Tokens kommen aus theme.css (CI + Excel-Farbsprache); diese Datei
 * enthaelt nur das Layout der Kalkulator-Seite (Ergebnistabelle, Tabs, Eingaben).
 */

* { box-sizing: border-box; }
html { margin: 0; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 32px; }

h1, h2, h3 { margin: 0 0 8px 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p.hinweis-block { margin: 4px 0 8px 0; font-style: italic; color: #667; }

.kopf { padding: 12px 16px 0; }

.warnungen-box {
  background: var(--panel-bg);
  color: var(--rot);
  border: 2px solid var(--rot);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 13px;
}
.warnungen-box[hidden] { display: none; }
.warnungen-box strong { display: block; margin-bottom: 2px; }
.warnungen-box ul { margin: 0; padding-left: 18px; }

.aktive-einstellungen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 8px 0;
  font-size: 13px;
}
.aktive-einstellungen span.label { color: var(--text-2); margin-right: 4px; }
.aktive-einstellungen strong { font-weight: bold; }
.aktive-einstellungen .flag-manuell { color: var(--rot); font-weight: bold; }
.aktive-einstellungen .flag-berechnet { color: #2E7D32; }

.knopfleiste { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }

.status-zeile { margin: 8px 0 0 0; font-size: 13px; min-height: 1.2em; }
.status-zeile[hidden] { display: none; }

/* -------------------------------------------------------------- HK1-Ergebnis --- */
section.ergebnis { margin: 12px 0 18px; background: var(--bg); }
.ergebnis-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--kopf-bg); color: #fff; padding: 4px 10px;
}
.ergebnis-kopf h2 { margin: 0; padding: 2px 0; color: #fff; }
.ergebnis-kopf .knopf.klein { padding: 3px 10px; font-size: 12px; background: #fff; color: var(--ozas-brand); }
.ergebnis-kopf .knopf.klein:hover { background: var(--ozas-surface); }
#ergebnis-tabelle-wrap { overflow: auto; max-height: calc(100vh - 200px); }

/* Runde 2: Die FactBox (HK1-Ergebnis rechts neben den Reitern) bleibt ab 900 px unter der
 * klebenden Kopfleiste stehen; im Ergebnis-Dialog bleibt der Tabellenkopf sichtbar. */
@media (min-width: 900px) {
  aside.factbox {
    position: sticky; top: 72px; z-index: 30;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  }
  table.ergebnistabelle thead th { position: sticky; top: 0; z-index: 1; }
}
/* Eingeklappt: nur Kernzeilen (Rohstoff, Gebinde, POE, Lizenz, HK1 je Einheit/Liter). */
section.ergebnis.ergebnis-kompakt tr.detail-zeile { display: none; }

table.ergebnistabelle, table.datentabelle {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}
table.ergebnistabelle th, table.ergebnistabelle td,
table.datentabelle th, table.datentabelle td {
  border: 1px solid var(--rand);
  padding: 4px 8px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.ergebnistabelle th:first-child, table.ergebnistabelle td:first-child,
table.datentabelle th:first-child, table.datentabelle td:first-child {
  text-align: left; white-space: normal; min-width: 180px;
}
table.ergebnistabelle thead th, table.datentabelle thead th { background: var(--grau-bg); font-weight: bold; }
table.ergebnistabelle tr.hk1-einheit td { background: var(--hellblau); font-weight: bold; color: #1A2233; }
table.ergebnistabelle td.dash { color: #999; text-align: center; }

/* ---------------------------------------------------------------------- Tabs --- */
nav.tabs {
  display: flex; flex-wrap: wrap; gap: 2px;
  border-bottom: 2px solid var(--kopf-bg); margin: 12px 0;
}
nav.tabs button {
  background: var(--grau-bg);
  border: 1px solid var(--rand);
  border-bottom: none;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  color: var(--text);
  font-family: inherit;
}
nav.tabs button.aktiv { background: var(--kopf-bg); color: #fff; font-weight: bold; }

.tab-panel { display: none; overflow-x: auto; }
.tab-panel.aktiv { display: block; }
.tab-panel h2 { margin-bottom: 4px; }

/* --------------------------------------------------------------------- Eingaben --- */
input.eingabe, select.eingabe {
  background: var(--gelb);
  border: 1px solid #BF9000;
  padding: 3px 5px;
  font-size: 13px;
  width: 100%;
  min-width: 70px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: #1A1A1A;
}
input.eingabe.override::placeholder { color: #8A7000; font-style: italic; }

td.zelle-eingabe { background: var(--gelb); padding: 2px 4px; }
td.zelle-berechnet { background: var(--panel-bg); }
td.zelle-fix { background: var(--grau-bg); color: var(--text); }

.status-offen, .warnung, .text-rot { color: var(--rot); font-weight: bold; }

table.datentabelle td.status-zelle, table.datentabelle td.quelle-zelle {
  text-align: left; white-space: normal; font-size: 12px; color: #556;
}

.flag-manuell { color: var(--rot); font-weight: bold; }
.flag-berechnet { color: #2E7D32; }

/* ----------------------------------------------------------- Artikel & Export --- */
.artikel-stueckliste-block { margin-bottom: 18px; }
.artikel-stueckliste-block h4 { margin: 10px 0 4px; font-size: 13px; }

/* ------------------------------------------------------------- Quellen & Offen --- */
ul.offene-punkte { margin: 8px 0; padding-left: 20px; }
ul.offene-punkte li { color: var(--rot); margin-bottom: 6px; }
.meta-info { font-size: 12px; color: #667; margin-bottom: 14px; }
.legende { font-size: 12px; margin-top: 18px; }
.legende span.swatch { display: inline-block; width: 14px; height: 14px; vertical-align: middle; border: 1px solid #999; margin-right: 4px; }

footer.fuss { padding: 10px 16px 24px; font-size: 11px; color: #778; border-top: 1px solid var(--rand-hell); }

/* ------------------------------------------------------- Bearbeitungssperre (UI) --- */
.sperr-hinweis { margin: 4px 0; font-size: 14px; color: var(--text); }
.sperr-hinweis[hidden], .bearbeitungs-band[hidden] { display: none; }
.bearbeitungs-band {
  background: var(--gelb); color: #6B5300; border: 1px solid #BF9000; border-left: 6px solid #BF9000;
  border-radius: 4px; padding: 8px 12px; margin: 8px 0; font-size: 13px; font-weight: 600;
}
button.bearbeiten-knopf.aktiv { background: var(--gelb); color: #6B5300; border-color: #BF9000; }
input.eingabe.bearbeitung-gesperrt, select.eingabe.bearbeitung-gesperrt {
  background: var(--rand-hell); color: var(--text); cursor: not-allowed; border-color: var(--rand);
  padding-right: 20px;
}
td.zelle-eingabe.zelle-gesperrt { background: var(--grau-bg); position: relative; }
option.option-veraltet { color: var(--rot); font-style: italic; }

/* Barrierearm: sichtbarer Fokus zusaetzlich zu theme.css (spezifischer fuer .eingabe) */
input.eingabe:focus-visible, select.eingabe:focus-visible {
  outline: 3px solid var(--ozas-brand);
  outline-offset: 0;
}

/* --------------------------------------------------------------------- Responsive --- */
@media (max-width: 400px) {
  main { padding: 8px 8px 24px; }
  table.ergebnistabelle, table.datentabelle { min-width: 0; font-size: 12px; }
  nav.tabs button { padding: 6px 9px; font-size: 12px; }
}

/* --------------------------------------------------------------------- Druck --- */
@media print {
  .app-kopfzeile, .knopfleiste, .status-zeile, nav.tabs { display: none !important; }
  .tab-panel { display: block !important; page-break-inside: avoid; }
  section.ergebnis { page-break-inside: avoid; position: static !important; box-shadow: none !important; }
  #ergebnis-tabelle-wrap { max-height: none !important; overflow: visible !important; }
  section.ergebnis.ergebnis-kompakt tr.detail-zeile { display: table-row !important; }
  .ergebnis-kopf button, .sperr-hinweis, .bearbeitungs-band { display: none !important; }
  table.ergebnistabelle th, table.ergebnistabelle td,
  table.datentabelle th, table.datentabelle td { border: 1px solid #000; }
  input.eingabe, select.eingabe {
    border: 1px solid #000; background: #FFF2CC !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  table.ergebnistabelle tr.hk1-einheit td {
    background: #DDEBF7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
