/* =====================================================================
   COMPONENTS.CSS — wiederverwendbare Bausteine: Buttons, Formulare, Karten,
   Listen, Chips, Segmente, Dialoge, Toast.
   Am Ende: "Legacy"-Klassen, die von älteren Formularen (JS) noch erzeugt werden.
   ===================================================================== */

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-ui);
    background: var(--surface); color: var(--text);
    font-size: 16px; font-weight: 650; line-height: 1.2; text-decoration: none; text-align: center;
    transition: background-color .15s, border-color .15s;
}
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--raised); } }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (hover: hover) { .btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); } }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: var(--tap); padding: 0 14px; font-size: 14px; }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.btn-block:first-child { margin-top: 0; }

.link-btn {
    background: none; border: 0; padding: 0 8px; min-height: var(--tap);
    color: var(--info); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.link { display: inline-flex; align-items: center; min-height: var(--tap); font-size: 14px; font-weight: 600; color: var(--info); text-decoration: none; }
.link:hover { text-decoration: underline; }

.chip-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
    border-radius: 20px; border: 1px solid var(--border-ui);
    background: var(--raised); color: var(--text);
    font-size: 14px; font-weight: 600; list-style: none; cursor: pointer;
}
.chip-btn::-webkit-details-marker { display: none; }

.iconbtn {
    width: var(--tap); height: var(--tap); flex: none;
    display: inline-grid; place-items: center;
    border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); color: var(--text); text-decoration: none; padding: 0;
}
.iconbtn.flat { background: transparent; border-color: transparent; color: var(--muted); }
.iconbtn.alt { background: var(--raised); border-color: transparent; }
.iconbtn.sm { width: 36px; height: 36px; }
@media (hover: hover) { .iconbtn:hover:not(:disabled) { background: var(--raised); color: var(--text); } }

/* ---------- Formulare ---------- */

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.form-row > label, .form-row > .label, .fieldset > legend {
    font-size: 14px; font-weight: 600; color: var(--muted);
}
.form-row.compact { margin-bottom: 0; }

input:not([type=checkbox]):not([type=radio]):not([type=range]),
select, textarea {
    width: 100%; min-height: 48px; padding: 0 14px;
    background: var(--raised); color: var(--text);
    border: 1px solid var(--border-ui); border-radius: 12px;
    font-size: 16px;               /* ≥ 16px verhindert Zoom beim Fokussieren in iOS */
}
textarea { padding: 12px 14px; }
/* Eigener Auswahl-Pfeil (aus Textfarbe), damit er nicht am Rand abgeschnitten wird */
select:not([multiple]) {
    -webkit-appearance: none; appearance: none; cursor: pointer;
    padding-right: 42px; text-overflow: ellipsis;
    background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
    background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
    background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
select[multiple] { padding: 8px 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; border-radius: 12px; }
input:disabled, select:disabled { opacity: 0.55; }

input[type=checkbox], input[type=radio] {
    width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent);
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }

.hint { font-size: 14px; color: var(--muted); margin: 6px 0; }
.hint a { color: var(--info); }
.empty-line { padding: 6px 0; }

.notice {
    padding: 12px 14px; margin: 12px 0; border-radius: 12px;
    font-size: 14px; line-height: 1.4; background: var(--raised); color: var(--text);
    border-left: 4px solid var(--border-ui);
}
.notice.ok { background: var(--ok-soft); color: var(--ok); border-left-color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-left-color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-left-color: var(--warn); }

.fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.fieldset > legend { padding: 0; margin-bottom: 8px; }

.option-card {
    display: flex; align-items: center; gap: 12px; min-height: 52px;
    padding: 10px 14px; margin-bottom: 8px; border-radius: 12px;
    border: 1px solid var(--border-ui); background: var(--surface);
    font-size: 15px; cursor: pointer;
}
.option-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Karten ---------- */

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
    display: block; min-width: 0;
}
a.card { color: var(--text); text-decoration: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; min-height: 36px; }
.h2 { font-size: 15px; font-weight: 650; color: var(--muted); }
.h3 { font-size: 14px; font-weight: 650; color: var(--muted); margin: 14px 0 4px; }
.card > .h2 { margin-bottom: 8px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 2px; }

.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row.between { justify-content: space-between; }
.row.chips { gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.row.actions { margin-top: 14px; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- Listen ---------- */

.list { display: flex; flex-direction: column; }
.item {
    display: flex; align-items: center; gap: 14px;
    min-height: 64px; padding: 8px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text); text-decoration: none; min-width: 0;
}
.item:last-child { border-bottom: 0; }
.item-btn {
    width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
    text-align: left; font: inherit; cursor: pointer;
}
.item-btn:last-of-type { border-bottom: 0; }
.card .item, .card-list .item { margin: 0 -16px; padding-left: 16px; padding-right: 16px; width: auto; }
.card .item-btn, .sheet .item-btn { width: calc(100% + 32px); }
.sheet .item-btn { margin: 0 -16px; padding: 8px 16px; width: calc(100% + 32px); }
@media (hover: hover) {
    a.item:hover, .item-btn:hover { background: var(--raised); }
}

.card-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; overflow: hidden; }
.card-list .item { margin: 0 -16px; }

.badge {
    width: 52px; height: 52px; border-radius: var(--radius-sm); flex: none;
    display: grid; place-items: center; font-size: 19px; font-weight: 700;
}
.datebox {
    width: 52px; height: 52px; border-radius: var(--radius-sm); flex: none;
    background: var(--raised); color: var(--text);
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.datebox b { font-size: 19px; }
.datebox small { font-size: 12px; color: var(--muted); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

.chip {
    display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
    border-radius: 14px; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none;
    background: var(--raised); color: var(--text);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.delta { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; }
.delta.ok { color: var(--ok); }
.delta.bad { color: var(--bad); }

.check {
    display: flex; align-items: center; gap: 14px; min-height: 52px;
    border-bottom: 1px solid var(--line); font-size: 16px; cursor: pointer;
}
.check:last-child { border-bottom: 0; }
.check input { width: 24px; height: 24px; }

.progress { height: 6px; border-radius: 3px; background: var(--raised); margin: 12px 0 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state p { margin-bottom: 14px; }

/* ---------- Segmente (Umschalter) ---------- */

.seg { display: flex; padding: 4px; gap: 4px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.seg > button, .seg > a {
    flex: 1; min-height: 40px; padding: 0 10px; display: grid; place-items: center;
    border: 0; border-radius: 12px; background: transparent;
    font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.seg > .on { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-ui); font-weight: 700; }
.seg-compact > button { min-height: 36px; padding: 0 12px; }
.seg-tabs { margin: 4px 0 16px; }

/* ---------- Dialoge / Sheets ---------- */

.overlay {
    position: fixed; inset: 0; z-index: 60; background: var(--scrim);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
    position: relative; width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-bottom: 0;
    border-radius: 28px 28px 0 0;
    padding: 10px 16px calc(24px + var(--safe-bottom));
    overscroll-behavior: contain;
}
.sheet-form { max-width: 680px; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border-ui); margin: 0 auto 14px; }
.sheet-close { position: sticky; top: 0; float: right; z-index: 2; margin: 0 0 -44px 8px; }
.h-sheet { font-size: 22px; font-weight: 650; line-height: 1.2; margin: 6px 48px 16px 0; letter-spacing: -0.01em; }
#modal-box > .eyebrow { margin-top: 12px; }

.quick-todo {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 6px 6px 8px;
}
.quick-todo input { border: 0; background: transparent; min-height: 44px; }
.quick-todo .btn { min-height: 44px; border-radius: 12px; white-space: nowrap; }

@media (min-width: 720px) {
    .overlay { align-items: center; padding: 24px; }
    .sheet { border-radius: 24px; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
}

@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.overlay:not(.hidden) .sheet { animation: sheet-in .2s ease-out; }

/* ---------- Toast ---------- */

.toast {
    position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); z-index: 90;
    transform: translateX(-50%) translateY(8px);
    background: var(--raised); color: var(--text); border: 1px solid var(--border-ui);
    padding: 12px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 15px;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* =====================================================================
   LEGACY: Klassen, die ältere Formular-/Wizard-Templates im JS noch benutzen.
   Hier auf das neue Design abgebildet, damit alle Funktionen unverändert laufen.
   ===================================================================== */

.req-meta { font-size: 14px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.req-meta b, .req-meta strong { color: var(--text); }
.log-line { font-size: 14px; margin: 10px 0; color: var(--text); }
.panel {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 12px;
}
.panel-title { font-size: 14px; font-weight: 650; color: var(--muted); margin-bottom: 8px; }
.stat-label { font-size: 13px; color: var(--muted); }
.btn-sm.btn-primary { min-height: var(--tap); }
.segmented { display: inline-flex; gap: 4px; padding: 3px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.segmented button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented button.active { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-ui); font-weight: 700; }
.tag {
    display: inline-flex; align-items: center; height: 24px; padding: 0 8px; margin-right: 4px;
    border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--text);
}
.tag-probe { background: var(--warn-soft); color: var(--warn); }
.tag-bestanden { background: var(--ok-soft); color: var(--ok); }
.tag-nicht-bestanden { background: var(--bad-soft); color: var(--bad); }
.wizard-check-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; min-height: 48px;
}
.wizard-check-row:last-child { border-bottom: 0; }
.wizard-check-row select { min-height: 44px; width: auto; max-width: 100%; }
.wizard-step-label { font-size: 13px; color: var(--muted); text-align: right; }
.req-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
