/* Paket «Daten bearbeiten»: Dialoge, Vorschau, Abschnitt im Bedienfeld. Nur Variablen der App. */

/* Bedienfeld */
.dt-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.dt-panel button { text-align: left; min-height: 38px; }

/* ---------- Gerüst der Paket-Dialoge ----------
   Für alle Dialoge der Pakete (Daten, Datei, Spalten, Vorlagen, Darstellung, Kalibrieren; Auswertung in
   auswertung.css): Kopfzeile oben und Knopfleiste unten bleiben stehen, dazwischen scrollt der Inhalt. */
/* Grund deckend (Glas über dem App-Grund), damit Kopf, Inhalt und Knopfleiste ruhig lesbar bleiben */
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen, .ausw-dialog) { --dlg-grund: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); background: var(--dlg-grund); }
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) { --dlg-pad: 20px; padding: 0; overflow: hidden; }
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form {
  display: flex; flex-direction: column; max-height: calc(100dvh - 26px); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--dlg-pad); scrollbar-width: thin;
}
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form > :is(h2:first-child, .dt-kopf) {
  position: sticky; top: 0; z-index: 3; flex: none; margin: 0 calc(-1 * var(--dlg-pad)) 10px; padding: 16px var(--dlg-pad) 10px;
  background: var(--dlg-grund); box-shadow: 0 1px 0 var(--line);
}
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form > .dialog-knoepfe {
  position: sticky; bottom: 0; z-index: 3; flex: none; align-items: center;
  margin: auto calc(-1 * var(--dlg-pad)) 0; padding: 12px var(--dlg-pad) 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--dlg-grund); border-top: 1px solid var(--line);
}
/* einzelne Knöpfe im Inhalt nicht auf die ganze Breite ziehen */
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form > :is(button, .chip) { align-self: flex-start; }
/* Abstand zwischen Inhalt und Knopfleiste */
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form > :nth-last-child(2) { margin-bottom: 14px; }
/* Segmente in den Dialogen: gleich breite Spalten über die ganze Breite */
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen, .ausw-dialog) .segment:not(.dt-umformungen) {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; justify-self: stretch;
}
:is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen, .ausw-dialog) .segment:not(.dt-umformungen) > button { min-width: 0; padding-left: 6px; padding-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-kopf h2 { margin: 0 0 4px; }
.dt-kopf .hinweis { margin: 0; }

.daten-dialog { width: min(560px, calc(100vw - 24px)); }
.dt-erklaerung { margin: 0 0 6px; color: var(--muted); }
.dt-inhalt { padding: 0; min-width: 0; }
.daten-dialog .dt-uebersicht { padding: 0; }
.dt-fehler { margin: 0 auto 0 0; flex: 1 1 200px; color: var(--err); font-size: var(--gr-panel); line-height: 1.4; }

.dt-feld { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 12px; align-items: center; margin: 10px 0; }
.dt-label { color: var(--muted); font-size: var(--gr-panel); line-height: 1.3; }
.dt-hilfe { grid-column: 2; margin: 0; }
.dt-feld > select, .dt-feld > input { width: 100%; min-width: 0; }
.dt-zahl { max-width: 160px; }
.dt-text { font-family: var(--schrift-text) !important; }
.dt-segment { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); width: 100%; }
.dt-segment button { white-space: normal; line-height: 1.25; }
.dt-bereich { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dt-bereich input { width: 96px; flex: 1 1 80px; }
.dt-bis { color: var(--muted); }
.dt-schalter { margin: 6px 0; }
.dt-liste { display: grid; gap: 2px; max-height: 200px; overflow: auto; }
.dt-liste .schalter { min-height: 34px; margin: 0; }
.dt-farbe { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.dt-spalteninfo { margin: 0; padding-left: 18px; font-size: var(--gr-panel); color: var(--muted); line-height: 1.5; }

.dt-vorschau { display: block; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--bg) 70%, transparent); margin: 12px 0 4px; }
.dt-info { min-height: 1.4em; margin: 4px 0 8px; }

/* Linearisieren: Umformungen mit R² */
.dt-umformungen { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.dt-umf { display: grid; gap: 1px; justify-items: center; min-width: 0; padding: 6px 2px; min-height: 48px; border: 0; background: transparent; border-radius: 8px; }
.dt-umf b { font-family: var(--schrift-mono); font-weight: 500; font-size: var(--gr-text); }
.dt-umf small { font-family: var(--schrift-mono); font-size: var(--gr-label); color: var(--muted); white-space: nowrap; }
.dt-umf[aria-checked="true"] { background: var(--btn-on); color: var(--btn-on-text); box-shadow: inset 0 0 0 1px var(--btn-on-edge); }
.dt-umf.best small { color: var(--ok); }
.dt-umf.best small::after { content: ' ✓'; }
.dt-wann { margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.dt-wann summary { border: 0; background: transparent; padding: 10px 0; min-height: 0; font-size: var(--gr-panel); color: var(--text); }
.dt-wann dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 12px; font-size: var(--gr-klein); line-height: 1.45; }
.dt-wann dt { font-family: var(--schrift-mono); color: var(--accent); white-space: nowrap; }
.dt-wann dd { margin: 0; color: var(--muted); }

/* Fehlerfortpflanzung: eine Zeile je benutzte Spalte */
.dt-fp { display: grid; gap: 8px; margin: 6px 0 10px; }
.dt-fp-zeile { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 2fr) 96px; gap: 8px; align-items: center; }
.dt-fp-zeile b { font-weight: 500; font-size: var(--gr-panel); overflow-wrap: anywhere; }
.dt-fp-zeile .dt-segment { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); }
.dt-fp-zeile input { width: 100%; }

/* Übersicht */
.dt-uebersicht { display: grid; gap: 8px; }
.dt-karte { display: grid; gap: 3px; text-align: left; padding: 10px 14px; min-height: 56px; border-radius: 12px; }
.dt-karte b { font-weight: 600; font-size: var(--gr-text); }
.dt-karte span { color: var(--muted); font-size: var(--gr-klein); line-height: 1.4; }

/* Schmal (Handy, Tablet hoch im Split View) */
@media (max-width: 560px) {
  :is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) { --dlg-pad: 14px; }
  /* Knopfleiste: gleich breite Knöpfe */
  :is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) > form > .dialog-knoepfe > :is(button, a) { flex: 1 1 0; white-space: nowrap; }
  .dialog-knoepfe > .dt-fehler { flex-basis: 100%; order: -1; }
  .dt-feld { grid-template-columns: 1fr; }
  .dt-hilfe { grid-column: 1; }
  .dt-fp-zeile { grid-template-columns: 1fr 96px; }
  .dt-fp-zeile b { grid-column: 1 / -1; }
  .dt-zahl { max-width: none; }
}

/* Touch: Ziele mindestens 44 px */
@media (pointer: coarse) {
  .dt-panel button, .dt-chip, .dt-segment button, .dt-umf, .dt-karte, .dt-bereich .chip, .dt-wann summary { min-height: 44px; }
  .dt-liste .schalter, .dt-schalter { min-height: 44px; }
  .daten-dialog input[type="checkbox"] { width: 22px; height: 22px; }
  :is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) :is(.chip, summary, .schalter) { min-height: 44px; }
  :is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen) .chip { min-width: 44px; }
  :is(.daten-dialog, .dt-dialog, .sp-dialog, .vl-dialog, .kal-dialog, .notiz-dialog, .d-optionen, .ausw-dialog) :is(.segment button, .sp-beispiel) { min-height: 44px; }
}
