/* ===========================================
   Sicherheitsbereich (admin.html)

   Ergänzt style.css und benutzt dessen Farb- und Abstandsvariablen –
   die Seite soll erkennbar zur Zeiterfassung gehören.

   Anders als die App ist das hier eine Schreibtischseite: breite Tabellen
   statt Kacheln. Unter 900 px kippen die Tabellen deshalb in eine
   Zeilendarstellung, sonst wäre sie am Handy unlesbar.
   =========================================== */

.admin-body {
    background: var(--color-bg);
    min-height: 100vh;
}

.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.admin-block {
    margin-bottom: var(--space-2xl);
}

.admin-block h2 {
    font-size: 1.15rem;
    margin-bottom: var(--space-xs);
}

.admin-fussnote {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: var(--space-md);
    max-width: 70ch;
}

.admin-hinweis {
    color: var(--color-text-muted);
    padding: var(--space-xl);
    text-align: center;
}

.admin-leer {
    color: var(--color-text-muted);
    padding: var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* ── Kacheln ──────────────────────────────────────────────────────────── */

.kachel-reihe {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.kachel {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.kachel-zahl {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.kachel-text {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: var(--space-xs);
}

.kachel-warnung { border-left-color: var(--color-error); }
.kachel-warnung .kachel-zahl { color: var(--color-error); }
.kachel-hinweis { border-left-color: var(--color-warning); }
.kachel-ruhig   { border-left-color: var(--color-success); }

/* ── Tabellen ─────────────────────────────────────────────────────────── */

.tabellen-rahmen {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.admin-tabelle {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-tabelle th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.admin-tabelle td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

/* Datum und Uhrzeit gehoeren zusammen und duerfen nicht umbrechen. */
.admin-tabelle td > span:first-child { white-space: nowrap; }
.admin-tabelle td.detail,
.admin-tabelle td.kennung,
.admin-tabelle td > span.kennung { white-space: normal; }

.admin-tabelle tbody tr:last-child td { border-bottom: none; }
.admin-tabelle tbody tr:hover { background: var(--color-bg-input); }

.zeile-gesperrt { background: var(--color-error-muted); }
.zeile-gesperrt:hover { background: var(--color-error-muted); }

/*
 * Kennungen (Anmeldenamen, IP-Adressen) in Festbreitenschrift.
 *
 * overflow-wrap statt word-break: break-all - letzteres zerlegt AUCH kurze
 * Werte, die problemlos in die Spalte passen. Im ersten Anlauf stand
 * "89.246.51.10 / 9" auf zwei Zeilen. So wird nur umbrochen, wenn es ohne
 * Umbruch wirklich nicht geht - etwa bei einem absurd langen Benutzernamen,
 * wie ihn ein Angreifer schickt.
 */
.kennung {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.85em;
    word-break: normal;
    overflow-wrap: anywhere;
}

/*
 * IP-Adressen nie umbrechen.
 *
 * "anywhere" oben ist fuer Anmeldenamen gedacht - ein Angreifer schickt auch
 * mal 200 Zeichen, und die muessen umbrechen duerfen, sonst sprengen sie die
 * Tabelle. Der Nebeneffekt: Die Regel erlaubt dem Browser, die ganze Spalte
 * schmaler zu rechnen, und dann stand "89.246.51.10 / 9" auf zwei Zeilen.
 * Eine zerrissene IP-Adresse ist beim Lesen aber wertlos.
 */
.kennung.ip {
    overflow-wrap: normal;
    white-space: nowrap;
}

.klarname {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.nebenzeit {
    display: block;
    color: var(--color-text-subtle);
    font-size: 0.75rem;
    margin-top: 2px;
    white-space: nowrap;
}

.zahl { white-space: nowrap; }

.detail {
    color: var(--color-text-muted);
    max-width: 46ch;
    line-height: 1.45;
}

.spalte-aktion { text-align: right; white-space: nowrap; }

/* ── Marken ───────────────────────────────────────────────────────────── */

.marke {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.marke-gesperrt,
.marke-alarm { background: var(--color-error-muted);   color: var(--color-error); }
.marke-warn  { background: var(--color-warning-muted); color: var(--color-primary-hover); }
.marke-info,
.marke-offen { background: var(--color-success-muted); color: var(--color-success); }

/* ── Filter ───────────────────────────────────────────────────────────── */

.filter-reihe {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.filter-reihe label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/*
 * width: auto muss sein - style.css setzt fuer alle select und input global
 * width: 100%, weil die Formulare der App einspaltig sind. Ohne die Angabe
 * belegt schon das Auswahlfeld die ganze Zeile und das Suchfeld rutscht
 * darunter.
 */
.filter-reihe select,
.filter-reihe input {
    width: auto;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-card);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.85rem;
}

.filter-reihe input { flex: 1; min-width: 180px; }

.filter-reihe select:focus,
.filter-reihe input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ── Knöpfe ───────────────────────────────────────────────────────────── */

.btn-klein {
    padding: 5px 12px;
    font-size: 0.8rem;
    width: auto;
    text-decoration: none;
    display: inline-block;
}

.btn-warnung {
    background: var(--color-error);
    border-color: var(--color-error);
    color: #fff;
}

/* ── Schmale Fenster ──────────────────────────────────────────────────────
   Tabellen werden zu Blöcken. Die Spaltenüberschrift steht dann links
   neben dem Wert, damit ohne Kopfzeile klar bleibt, was was ist. */

@media (max-width: 900px) {
    .admin-tabelle thead { display: none; }

    .admin-tabelle tr {
        display: block;
        padding: var(--space-sm) 0;
        border-bottom: 1px solid var(--color-border);
    }

    .admin-tabelle td {
        display: grid;
        grid-template-columns: 8.5rem 1fr;
        gap: var(--space-sm);
        border: none;
        padding: 4px var(--space-md);
    }

    .admin-tabelle td::before {
        content: attr(data-spalte);
        color: var(--color-text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .spalte-aktion { text-align: left; }
    .detail { max-width: none; }
}
