/* FeuerwehrWiki – Grundlayout (ohne Framework) */

:root {
    --rot: #c8102e;
    --rot-dunkel: #9e0b23;
    --rot-hell: #fdecee;
    --text: #1f2328;
    --text-leise: #5f6670;
    --flaeche: #ffffff;
    --hintergrund: #f3f4f6;
    --rand: #dfe2e6;
    --gruen: #1e7d3c;
    --schatten: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .05);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--hintergrund);
    line-height: 1.45;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.kopf {
    background: var(--rot);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.kopf-inhalt {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.kopf-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
}
.kopf-name { font-size: 1.35rem; font-weight: 700; letter-spacing: .02em; }

.kopf-benutzer {
    margin-left: auto;
    font-size: .9rem;
    color: rgba(255, 255, 255, .85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.kopf-abmelden {
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    flex-shrink: 0;
}
.kopf-abmelden:hover { background: rgba(255, 255, 255, .25); }
.kopf-link { text-decoration: none; }

/* ---------- Tabelle (Benutzerverwaltung) ---------- */
.tabelle-karte { padding: 0; overflow: hidden; }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th {
    text-align: left;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-leise);
    background: var(--hintergrund);
    padding: 10px 16px;
}
.tabelle td { padding: 12px 16px; border-top: 1px solid var(--rand); vertical-align: middle; }
.tabelle tr.inaktiv .benutzer-name { color: var(--text-leise); text-decoration: line-through; }
.tabelle .leise { color: var(--text-leise); font-size: .9rem; }
.benutzer-name { font-weight: 600; overflow-wrap: anywhere; }
.benutzer-login { font-size: .85rem; color: var(--text-leise); overflow-wrap: anywhere; }
.benutzer-aktionen { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn.klein { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.flach:disabled:hover { background: transparent; }

.badge {
    display: inline-block;
    font-size: .8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--hintergrund);
    color: var(--text-leise);
    white-space: nowrap;
}
.badge.admin { background: var(--rot-hell); color: var(--rot-dunkel); }
.badge.superadmin { background: var(--rot); color: #fff; }
.badge.ok { background: #e3f4e8; color: var(--gruen); }
.badge.aus { background: #eceef1; color: #6b7280; }

.unsichtbar {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

dialog label.checkbox-zeile { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
dialog label.checkbox-zeile input { width: 20px; height: 20px; accent-color: var(--rot); }

/* Handy: Tabelle als Karten untereinander */
@media (max-width: 720px) {
    .tabelle thead { display: none; }
    .tabelle, .tabelle tbody, .tabelle tr, .tabelle td { display: block; width: 100%; }
    .tabelle tr { padding: 12px 16px; border-top: 1px solid var(--rand); }
    .tabelle tr:first-child { border-top: none; }
    .tabelle td { border: none; padding: 4px 0; }
    .tabelle td[data-label]::before {
        content: attr(data-label) ": ";
        font-size: .8rem;
        color: var(--text-leise);
    }
    .tabelle td:first-child::before { content: none; }
    .benutzer-aktionen { justify-content: flex-start; padding-top: 8px !important; }
}

@media (max-width: 520px) {
    .kopf-name { font-size: 1.1rem; }
    .kopf-benutzer { display: none; }
    .kopf-name { margin-right: auto; }
}

.kopf-zurueck {
    color: #fff;
    text-decoration: none;
    font-size: 1.4rem;
    padding: 0 6px;
    border-radius: 6px;
}
.kopf-zurueck:hover { background: rgba(255, 255, 255, .15); }

/* ---------- Inhalt ---------- */
.inhalt {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.zeile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.aktionen { display: flex; gap: 8px; flex-wrap: wrap; }

.karte {
    background: var(--flaeche);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.beschreibung { margin: 0; color: var(--text-leise); white-space: pre-line; }
.leer { margin: 0; color: var(--text-leise); font-style: italic; }

/* ---------- Buttons ---------- */
.btn {
    font: inherit;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    background: var(--rot);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--rot-dunkel); }
.btn:focus-visible, .btn-icon:focus-visible, .chip:focus-visible, .kachel:focus-visible {
    outline: 3px solid #f5a623;
    outline-offset: 2px;
}

.btn.flach { background: transparent; color: var(--text); border: 1px solid var(--rand); }
.btn.flach:hover { background: var(--hintergrund); }
.btn.flach.gefahr { color: var(--rot); }

.btn-icon {
    font: inherit;
    font-size: 1.05rem;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}
.btn-icon:hover { background: var(--hintergrund); }
.btn-icon.gefahr:hover { background: var(--rot-hell); }

/* ---------- Kacheln ---------- */
.kachel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.kachel {
    font: inherit;
    text-align: left;
    color: inherit;
    text-decoration: none;
    background: var(--flaeche);
    border: none;
    border-top: 5px solid var(--rot);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 20px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}
.kachel:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }

.kachel-titel { font-size: 1.25rem; }
.kachel-text {
    margin: 0;
    color: var(--text-leise);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.kachel-info { margin-top: auto; font-size: .85rem; color: var(--rot); font-weight: 600; }

.kachel-neu {
    border: 2px dashed var(--rand);
    background: transparent;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    color: var(--text-leise);
    font-weight: 600;
}
.kachel-neu:hover { border-color: var(--rot); color: var(--rot); box-shadow: none; }
.kachel-plus { font-size: 2rem; line-height: 1; }

/* ---------- Jahre ---------- */
.chip-leiste { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-leiste:empty { display: none; }

.chip {
    font: inherit;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid var(--rand);
    background: var(--flaeche);
    cursor: pointer;
}
.chip:hover { border-color: var(--rot); }
.chip.aktiv { background: var(--rot); border-color: var(--rot); color: #fff; }

/* ---------- Fortschritt ---------- */
.fortschritt { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--text-leise); }
.fortschritt-spur { flex: 1; height: 8px; background: var(--hintergrund); border-radius: 999px; overflow: hidden; }
.fortschritt-balken { height: 100%; width: 0; background: var(--gruen); transition: width .25s ease; }

/* ---------- Checkliste ---------- */
.checkliste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.punkt {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--rand);
}
.punkt:last-child { border-bottom: none; }

.punkt-haken { padding-top: 2px; }
.punkt-haken input { width: 22px; height: 22px; accent-color: var(--gruen); cursor: pointer; }

.punkt-inhalt { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.punkt-titel { font-weight: 600; overflow-wrap: anywhere; }
.punkt-text { margin: 0; color: var(--text-leise); white-space: pre-line; overflow-wrap: anywhere; }
.punkt.erledigt .punkt-titel { text-decoration: line-through; color: var(--text-leise); }

/* Wer hat den Punkt angelegt / gelöscht */
.punkt-meta { font-size: .8rem; color: var(--text-leise); }
.punkt-meta .geloescht-info { color: var(--rot-dunkel); font-weight: 600; }

/* Gelöschte Punkte: rot durchgestrichen und blass, Haken gesperrt */
.punkt.geloescht { background: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(200, 16, 46, .03) 8px 16px); }
.punkt.geloescht .punkt-titel,
.punkt.geloescht .punkt-text {
    text-decoration: line-through;
    text-decoration-color: var(--rot);
    text-decoration-thickness: 2px;
    color: var(--text-leise);
}
.punkt.geloescht .punkt-haken input { cursor: not-allowed; opacity: .4; }
.punkt.geloescht .foto-vorschau { opacity: .5; }

.punkt-aktionen { display: flex; gap: 2px; }

.foto-reihe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.foto-vorschau {
    padding: 0;
    border: 1px solid var(--rand);
    border-radius: 8px;
    overflow: hidden;
    width: 84px;
    height: 84px;
    cursor: zoom-in;
    background: var(--hintergrund);
}
.foto-vorschau img { width: 100%; height: 100%; object-fit: cover; display: block; }

.neuer-punkt { display: grid; grid-template-columns: 2fr 3fr auto; gap: 8px; padding-top: 6px; }

/* ---------- Formulare & Dialoge ---------- */
input, textarea, select {
    font: inherit;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--rand);
    border-radius: 8px;
    background: var(--flaeche);
    color: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--rot); outline-offset: -1px; border-color: var(--rot); }
textarea { resize: vertical; }

dialog {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: min(480px, calc(100vw - 32px));
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }

dialog form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }

.dialog-aktionen { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }

.foto-dialog { width: min(1000px, calc(100vw - 32px)); background: #111; color: #fff; }
.foto-dialog img { display: block; max-width: 100%; max-height: calc(100vh - 140px); margin: 0 auto; }
.foto-dialog .dialog-aktionen { padding: 12px 16px; }
.foto-dialog .btn.flach { color: #fff; border-color: #555; }
.foto-dialog .btn.flach:hover { background: #333; }
.foto-name { margin-right: auto; font-size: .9rem; color: #ccc; overflow-wrap: anywhere; }

/* ---------- Spinner & Meldungen ---------- */
.spinner-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .4);
    z-index: 100;
}
.spinner-overlay.aktiv { display: flex; }
.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--rand);
    border-top-color: var(--rot);
    border-radius: 50%;
    animation: drehen .8s linear infinite;
}
@keyframes drehen { to { transform: rotate(360deg); } }

.meldungen {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 110;
    width: min(480px, calc(100vw - 32px));
}
.meldung { padding: 12px 16px; border-radius: 8px; color: #fff; box-shadow: var(--schatten); }
.meldung.fehler { background: var(--rot-dunkel); }
.meldung.ok { background: var(--gruen); }

/* ---------- Handy ---------- */
@media (max-width: 640px) {
    h1 { font-size: 1.35rem; }
    .karte { padding: 16px; }
    .neuer-punkt { grid-template-columns: 1fr; }
    .punkt { grid-template-columns: auto 1fr; }
    .punkt-aktionen { grid-column: 2; }
}
