/*
 * Wespa Anzeigenwerkzeug
 *
 * Gestaltung adaptiert von www.wespa.de (Weser-Elbe Sparkasse):
 * Markenrot #ee0000, weisse Flaechen, klare Linien, zurueckhaltende Radien.
 *
 * Hinweis zur Schrift: die Hausschriften SparkasseWeb / SparkasseHeadWeb sind
 * lizenzpflichtig und werden hier bewusst nicht mitgeliefert. Verwendet wird
 * die Fallback-Kette, die auch wespa.de im font-family-Stack fuehrt.
 */

:root {
    --brand: #ee0000;
    --brand-dark: #c00000;
    --brand-soft: #fdecec;

    --ink: #292929;
    --muted: #565656;
    --line: #e3e3e3;
    --line-strong: #bebebe;

    --surface: #ffffff;
    --surface-sunken: #f5f5f5;
    --surface-alt: #f0f0f0;

    --ok: #1f7a3d;
    --ok-soft: #e8f4ec;
    --warn: #8a5a00;
    --warn-soft: #fdf3e2;
    --danger: #c00000;
    --danger-soft: #fdecec;

    --radius: 4px;
    --radius-lg: 6px;

    --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--surface-sunken);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

/* ---------------------------------------------------------------- Kopfbereich */

.site-header {
    background: var(--surface);
    border-bottom: 3px solid var(--brand);
}

.site-header-inner {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 14px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--ink);
}

.brand img {
    width: 190px;
    height: auto;
    display: block;
}

.brand-text {
    display: grid;
    line-height: 1.2;
}

.brand-title {
    font-weight: 700;
    font-size: 1rem;
}

.brand-sub {
    font-size: 0.82rem;
    color: var(--muted);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.site-nav a,
.site-nav button {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.site-nav a:hover,
.site-nav button:hover { background: var(--surface-alt); }

.site-nav a.is-active {
    color: var(--brand);
    box-shadow: inset 0 -2px 0 var(--brand);
    border-radius: 0;
}

.site-nav form { display: inline; margin: 0; gap: 0; }

/* ---------------------------------------------------------------- Grundraster */

.shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 56px;
}

.hero {
    margin-bottom: 20px;
}

.hero-top,
.toolbar,
.pagination {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    align-items: start;
}

.panels { display: grid; gap: 20px; }

.grid-2,
.grid-3,
.meta-grid,
.stats,
.slot-grid,
.media-grid,
.audit-grid {
    display: grid;
    gap: 14px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3,
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.meta-grid,
.slot-grid,
.media-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.stack { display: grid; gap: 12px; }

/* Positionen einer Anzeige stehen nebeneinander, solange der Platz reicht.
   Jede Position ist eine Karte; Kopf, Inhalt und Historie liegen darin. */
.block-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    align-items: start;
    margin-top: 8px;
}

.position-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px 16px 16px;
    display: grid;
    gap: 12px;
    min-width: 0;
}

.position-card:target {
    border-color: var(--brand);
}

.position-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px 12px;
    flex-wrap: wrap;
}

.position-head h3 {
    margin: 2px 0 0;
    font-size: 1.05rem;
    line-height: 1.3;
}

.block-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.block-actions form { display: inline; }

/* Kompakt, damit die Aktionen auch in der schmalen Spalte in eine Zeile passen. */
.block-actions .ghost {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 0.8125rem;
}

.block-actions .icon-button {
    width: 30px;
    padding: 0;
}

.icon-button svg { display: block; }

.position-slot + .position-slot,
.position-media + .position-media {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.position-meta {
    font-size: 0.8125rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.position-text {
    margin-top: 6px;
    font-size: 0.875rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.position-media {
    margin: 0;
}

.position-media img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: var(--surface-sunken);
    border-radius: var(--radius);
}

.position-media figcaption {
    margin-top: 6px;
}

/* Auf dem Telefon: groessere Trefferflaechen, die Aktionen teilen sich die Zeile. */
@media (max-width: 480px) {
    .block-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 44px 44px 1fr;
    }

    .block-actions form,
    .block-actions .ghost { width: 100%; }

    .block-actions .ghost,
    .block-actions .icon-button {
        min-height: 40px;
        padding: 4px 6px;
    }
}

/* Die Historie sitzt in der Karte und braucht keine eigenen Rahmen. */
.position-card .audit-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}

.position-card .audit-grid .meta-card {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    padding: 10px 0 0;
}

/* ---------------------------------------------------------------- Flaechen */

.panel,
.card,
.sidebar,
.meta-card,
.stat,
.slot-card,
.media-card,
.version,
.preview {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}

.panel,
.sidebar { padding: 20px; }

.card,
.meta-card,
.stat,
.slot-card,
.media-card,
.preview { padding: 16px; }

.version {
    padding: 18px;
    margin-bottom: 16px;
    display: grid;
    gap: 16px;
}

.version .version-head { margin-bottom: 0; }

/* Anzeigenkopf: Titel, Vorgaenge, Eckdaten und Historie mit gleichmaessigem Abstand. */
.ad-head {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.ad-head .hero-top { align-items: flex-start; }

/* Die sechs Eckdaten passen auf breiten Schirmen in eine Zeile. */
.ad-head .meta-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.ad-head .meta-card {
    hyphens: auto;
    overflow-wrap: break-word;
}

/* Neue Zeile: vom Inhalt der Version abgesetzt. */
.new-line {
    border-top: 1px solid var(--line);
    padding-top: 16px;
    display: grid;
    gap: 10px;
}

.sidebar {
    position: sticky;
    top: 20px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.section { margin-bottom: 24px; }

/* ---------------------------------------------------------------- Typografie */

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font);
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}

h1 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); }

/* Anzeigentitel aus dem Altsystem bestehen oft aus einem einzigen langen
   Wort mit Unterstrichen; ohne Umbruch schieben sie die Seite breiter als
   den Bildschirm. */
h1 { overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p {
    margin: 8px 0 0;
    color: var(--muted);
}

/* Freitext aus dem Bestand steht in <pre> und bringt beliebig lange Zeilen mit.
   Ohne Umbruch schiebt eine einzige davon die ganze Seite in die Breite. */
pre {
    text-wrap: wrap;
}

a { color: var(--brand); }

.eyebrow,
.meta-label,
.nav-group-label,
.group-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
}

.eyebrow { color: var(--brand); }

.muted { color: var(--muted); }

.hint {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted);
}

.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
}

.title-link {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}

.title-link:hover { color: var(--brand); }

/* ---------------------------------------------------------------- Bedienelemente */

.actions,
.filter-row,
.link-row,
.quick-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.button,
.ghost,
.logout,
.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
}

.button {
    color: #ffffff;
    background: var(--brand);
}

.button:hover { background: var(--brand-dark); }

.ghost,
.logout,
.pagination a,
.pagination span {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.ghost:hover,
.logout:hover,
.pagination a:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.pagination span {
    color: var(--muted);
    border-color: var(--line);
    cursor: default;
}

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

form { display: grid; gap: 14px; }

.form-grid,
.filter-grid {
    display: grid;
    gap: 14px;
}

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filter-grid { grid-template-columns: 1.6fr 1fr 1fr auto; }

.form-grid .span-2,
.span-2 { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 6px;
    /* Ohne start dehnt ein Feld neben einem mit Hinweistext seine Zeilen
       und sitzt tiefer als der Nachbar. */
    align-content: start;
    font-size: 0.92rem;
    font-weight: 600;
}

label.inline {
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
    gap: 10px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font: inherit;
    /* Feldinhalt in normaler Schrift, nicht in der fetten der Beschriftung. */
    font-weight: 400;
    color: var(--ink);
    background: var(--surface);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 0;
    border-color: var(--line-strong);
}

textarea { min-height: 110px; }

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

/* Formular als Stapel: Zeilen und Abschnitte mit gleichem Abstand. */
.form-stack {
    display: grid;
    gap: 20px;
    margin-top: 24px;
}

/* Abschnitte setzen sich mit mehr Luft nach oben ab als zu ihrem Inhalt. */
.form-stack > .section {
    margin: 12px 0 0;
}

/* Felder mit ihrem Hinweis: eng zusammen, zum Rest mit normalem Abstand. */
.field-group {
    display: grid;
    gap: 8px;
}

.field-group > .hint { margin: 0; }

/* Zeile bearbeiten: Textfelder breit genug zum Schreiben, nebeneinander,
   wenn mehrere passen. */
.slot-editor {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.slot-editor textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.5;
}

/* Formatierter Editor fuer Anzeigentexte: Leiste oben, Feld darunter. */
.field {
    display: grid;
    gap: 6px;
    align-content: start;
}

.field-label {
    font-size: 0.92rem;
    font-weight: 600;
}

.markup-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.markup-bar .ghost {
    min-height: 32px;
    min-width: 36px;
    padding: 4px 10px;
    font-size: 0.8125rem;
}

.markup-editor {
    min-height: 180px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-weight: 400;
    line-height: 1.5;
    /* Mehrfache Leerzeichen richten im Druck Werte aus; sie bleiben sichtbar. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    cursor: text;
}

.markup-editor.is-line { min-height: 44px; }

.markup-editor:focus {
    outline: 2px solid var(--brand);
    outline-offset: 0;
}

.markup-editor b { font-weight: 700; }

/* Checkbox in einer Feldzeile: auf Hoehe der Eingabefelder daneben. */
.field-check {
    align-self: start;
    min-height: 44px;
    margin-top: calc(0.92rem * 1.5 + 6px);
    align-content: center;
    font-weight: 600;
}

/* ---------------------------------------------------------------- Rueckmeldungen */

.status,
.error {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.92rem;
}

.status {
    background: var(--ok-soft);
    border: 1px solid #bcdcc7;
    color: var(--ok);
}

.error {
    padding: 0;
    background: none;
    color: var(--danger);
    font-size: 0.85rem;
}

.pill,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
}

.pill {
    background: var(--brand-soft);
    color: var(--brand);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--surface-alt); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.delta { font-weight: 700; }
.check { color: var(--ok); font-weight: 700; }

.empty {
    padding: 32px 0;
    text-align: center;
    color: var(--muted);
}

/* ---------------------------------------------------------------- Tabellen */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 12px 12px 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}

tbody tr:hover { background: var(--surface-sunken); }

/* ---------------------------------------------------------------- Seitennavigation */

.nav-group { margin-bottom: 16px; }
.nav-group:last-child { margin-bottom: 0; }
.nav-group-label { margin-bottom: 6px; }

.nav-link {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.93rem;
}

.nav-link + .nav-link { margin-top: 2px; }
.nav-link:hover { background: var(--surface-alt); color: var(--brand); }

.nav-link.is-active {
    background: var(--brand-soft);
    color: var(--brand);
    box-shadow: inset 3px 0 0 var(--brand);
}

/* ---------------------------------------------------------------- Arbeitslisten */

.group { margin-bottom: 16px; }
.group:last-child { margin-bottom: 0; }
.group-label { margin-bottom: 8px; }

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

.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.chip:hover { border-color: var(--brand); }

.chip-count {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.chip.is-active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.chip.is-empty { color: var(--muted); }
.chip.is-empty .chip-count { color: var(--line-strong); }

/* ---------------------------------------------------------------- Detailbausteine */

.stat {
    display: grid;
    gap: 2px;
    align-content: start;
}

/* Im Kennzahlenraster ist die Signalfarbe zu laut, hier reicht die Grauabstufung. */
.stat .eyebrow { color: var(--muted); }

.stat strong {
    font-size: 1.6rem;
    font-variant-numeric: tabular-nums;
}

.version-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.audit-changes {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 0.88rem;
    color: var(--muted);
}

/* Liste der abgelegten Dokumente: Dateiname und Groesse gehoeren zum Eintrag,
   nicht in eine eigene Spalte. */
.plain-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.plain-list li + li {
    margin-top: 4px;
}

.plain-list .muted {
    font-size: 0.85rem;
}

.media-card img,
.preview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    display: block;
}

/* ---------------------------------------------------------------- Anmeldung */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background: var(--surface-sunken) url('../img/onetag-bg.jpg') left center / cover no-repeat;
}

/* Die Zeitung liegt links im Bild; das Anmeldefeld steht rechts im hellen Teil. */
@media (min-width: 961px) {
    .auth-wrap {
        justify-items: end;
        padding-right: 8vw;
    }
}

.auth-card {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.auth-brand {
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-bottom: 24px;
    text-align: center;
}

.auth-brand img {
    height: 120px;
    width: auto;
}

.auth-foot {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
    text-align: center;
}

/* ---------------------------------------------------------------- Schmale Ansichten */

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .form-grid,
    .filter-grid,
    .grid-2,
    .grid-3,
    .stats { grid-template-columns: 1fr; }
}

/* Kennzahlkachel als Sprungziel */
a.stat { color: inherit; }
a.stat:hover { border-color: var(--brand); }
a.stat:hover strong { color: var(--brand); }
