/* Feuerwehr Holtriem — Redaktion (Admin) */
:root {
    --red: #d81f2a; --red-dark: #a8121b; --ink: #14161c; --grey: #5c626e;
    --line: #e3e6ec; --bg: #f3f4f7; --white: #fff; --radius: 12px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body.admin { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
a { color: var(--red-dark); }

/* Sidebar */
.admin-side { background: #14161c; color: #c8ccd6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.admin-brand { display: flex; gap: .6rem; align-items: center; color: #fff; text-decoration: none; padding: 1.2rem 1.3rem; font-weight: 800; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-brand__mark { font-size: 1.5rem; }
.admin-brand small { color: #8b909c; font-weight: 500; font-size: .72rem; }
.admin-nav { display: flex; flex-direction: column; padding: .8rem .7rem; gap: .15rem; flex: 1; }
.admin-nav a { color: #c8ccd6; text-decoration: none; padding: .6rem .8rem; border-radius: 8px; font-weight: 600; font-size: .92rem; }
.admin-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav a.is-active { background: var(--red); color: #fff; }
.admin-side__foot { padding: 1rem 1.3rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: .55rem; }
.admin-side__foot a { color: #b9bdc7; text-decoration: none; font-size: .85rem; }
.admin-side__foot a:hover { color: #fff; }

/* Main */
.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-top { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: .9rem 1.6rem; border-bottom: 1px solid var(--line); }
.admin-top strong { margin-right: .6rem; }
.admin-content { padding: 1.8rem; max-width: 1000px; }
.admin-content h1 { margin-top: 0; }

.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge--red { background: #fbe9ea; color: var(--red-dark); }
.badge--grey { background: #eceef2; color: var(--grey); }

/* Buttons */
.btn-sm { background: var(--ink); color: #fff; border: 0; padding: .5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: .88rem; }
.btn-sm:hover { background: #000; }
.btn-red { background: var(--red); color: #fff; border: 0; padding: .6rem 1.2rem; border-radius: 8px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-red:hover { background: var(--red-dark); }
.btn-line { background: #fff; border: 1px solid var(--line); padding: .5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); font-size: .88rem; }
.btn-danger { background: #fff; border: 1px solid #f0c8c8; color: var(--red-dark); padding: .4rem .8rem; border-radius: 8px; cursor: pointer; font-size: .85rem; }
.btn-danger:hover { background: #fdecec; }

/* Cards / Stats */
.a-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); margin-bottom: 2rem; }
.a-stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.a-stat strong { display: block; font-size: 2rem; color: var(--red); }
.a-stat span { color: var(--grey); font-size: .9rem; }

/* Table */
.a-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; gap: 1rem; flex-wrap: wrap; }
.a-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.a-table th, .a-table td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); font-size: .93rem; }
.a-table th { background: #fafbfc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grey); }
.a-table tr:last-child td { border-bottom: 0; }
.a-table td .actions { display: flex; gap: .4rem; }

/* ---- Drag & Drop-Sortierung ---- */
.a-table.is-sortable .drag-cell { width: 2.2rem; text-align: center; padding-left: .6rem; padding-right: .6rem; }
.drag-handle {
    cursor: grab; color: #9aa1ab; font-size: 1.1rem; line-height: 1; user-select: none;
    display: inline-block; padding: .15rem .2rem; border-radius: 4px;
}
.drag-handle:hover { color: var(--red, #c1121f); background: #f3f4f6; }
.a-table.is-sortable tr.is-dragging { opacity: .55; background: #fff6f6; }
.a-table.is-sortable tr.is-dragging td { border-color: var(--red, #c1121f); }
.reorder-status { margin: .5rem 0 0; font-size: .85rem; min-height: 1.1em; }
.reorder-status.is-ok { color: #1e7a37; }
.reorder-status.is-err { color: var(--red, #c1121f); }

/* Form */
.a-form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; max-width: 760px; }
.a-form .field { margin-bottom: 1.2rem; }
.a-form label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.a-form input[type=text], .a-form input[type=email], .a-form input[type=date], .a-form input[type=datetime-local],
.a-form input[type=password], .a-form input[type=number], .a-form select, .a-form textarea {
    width: 100%; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .95rem; background: #fff;
}
.a-form textarea { min-height: 220px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; }
.a-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.a-form .hint { color: var(--grey); font-size: .82rem; margin-top: .3rem; }
.a-form .checkbox { display: flex; align-items: center; gap: .5rem; }
.a-form .checkbox input { width: auto; }
.veh-picker { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; max-height: 320px; overflow-y: auto; }
.veh-picker__group { margin-bottom: .8rem; }
.veh-picker__group:last-child { margin-bottom: 0; }
.veh-picker__group strong { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--grey); margin-bottom: .4rem; }
.veh-picker__item { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; font-size: .92rem; font-weight: 400; cursor: pointer; }
.veh-picker__item input { width: auto; }

.img-field__preview {
    width: 220px; height: 140px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin-bottom: .6rem;
}
.img-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.img-field__preview.is-empty { background: repeating-linear-gradient(45deg, #f3f4f7, #f3f4f7 10px, #eceef2 10px, #eceef2 20px); }
.img-field__placeholder { color: var(--grey); font-size: .85rem; }
.img-field__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.img-field__input { margin-top: .6rem; width: 100%; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .88rem; }

.img-field--sm { display: flex; align-items: center; gap: .6rem; }
.img-field--sm .img-field__preview { width: 56px; height: 56px; margin-bottom: 0; border-radius: 6px; }
.img-field--sm .img-field__placeholder { font-size: .62rem; padding: 0 .3rem; text-align: center; }
.img-field--sm .img-field__actions { flex-wrap: nowrap; }
.img-field--sm .img-field__upload, .img-field--sm .img-field__remove { font-size: .78rem; padding: .35rem .6rem; white-space: nowrap; }

.gal-field__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); gap: .6rem; margin-bottom: .8rem; }
.gal-field__grid:empty { display: none; }
.gal-field__item { position: relative; margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.gal-field__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-field__remove {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
    background: rgba(20,22,28,.7); color: #fff; border: 0; cursor: pointer; font-size: .8rem; line-height: 1;
}
.gal-field__remove:hover { background: var(--red); }

.specs-field__rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .7rem; }
.specs-field__row { display: flex; gap: .5rem; align-items: center; }
.specs-field__key { flex: 0 0 40%; }
.specs-field__val { flex: 1; }
.specs-field__remove { flex: 0 0 auto; padding: .4rem .7rem; }
.a-actions { display: flex; gap: .7rem; align-items: center; margin-top: 1.4rem; }

.flash { padding: .8rem 1.1rem; border-radius: 8px; margin-bottom: 1.2rem; font-weight: 600; }
.flash--success { background: #e7f6ec; color: #1c7a3e; }
.flash--error { background: #fdecec; color: #b3261e; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 1rem; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0; cursor: pointer; transition: .15s; position: relative; }
.media-item:hover { box-shadow: var(--shadow); border-color: #c9ccd3; }
.media-item.is-copied { outline: 2px solid #1c7a3e; }
.media-item.is-copied::after { content: "Pfad kopiert ✓"; position: absolute; top: 8px; left: 8px; background: #1c7a3e; color: #fff; font-size: .7rem; padding: .15rem .5rem; border-radius: 6px; z-index: 3; }
.media-item__thumb { position: relative; aspect-ratio: 1; background: #f3f4f7; }
.media-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item__pdf { width: 100%; height: 100%; display: grid; place-items: center; font-weight: 800; color: var(--red); font-size: 1.1rem; }
.media-item__badge { position: absolute; bottom: 6px; right: 6px; background: rgba(20,22,28,.78); color: #fff; font-size: .62rem; font-weight: 700; padding: .1rem .4rem; border-radius: 5px; letter-spacing: .04em; }
.media-item figcaption { padding: .5rem .6rem; display: flex; flex-direction: column; gap: .1rem; }
.media-item__name { font-size: .76rem; font-weight: 600; word-break: break-all; line-height: 1.25; }
.media-item__meta { font-size: .68rem; color: var(--grey); word-break: break-all; }
.media-item__actions { display: flex; gap: .3rem; padding: 0 .6rem .6rem; }
.media-item__actions form { display: inline; }

/* Login */
.login-wrap { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(120deg,#14161c,#2a1416 60%,var(--red-dark)); font-family: var(--font); }
.login-card { background: #fff; padding: 2.2rem; border-radius: 16px; width: min(400px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { margin: 0 0 .3rem; font-size: 1.5rem; }
.login-card .sub { color: var(--grey); margin-bottom: 1.4rem; font-size: .92rem; }
.login-card .field { margin-bottom: 1rem; }
.login-card label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.login-card input { width: 100%; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.login-card button { width: 100%; margin-top: .6rem; padding: .8rem; background: var(--red); color: #fff; border: 0; border-radius: 999px; font-weight: 700; font-size: 1rem; cursor: pointer; }
.login-card button:hover { background: var(--red-dark); }

@media (max-width: 720px) {
    body.admin { grid-template-columns: 1fr; }
    .admin-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
    .a-form .row { grid-template-columns: 1fr; }
}

/* ---- Live-Vorschau Split-View (Paket 12) ---- */
.a-head__actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.editor-split.has-preview.is-preview-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.4rem;
    align-items: start;
}
.editor-split.is-preview-open .a-form { max-width: none; }
.editor-preview {
    position: sticky; top: 1rem;
    display: flex; flex-direction: column;
    height: calc(100vh - 2rem);
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.editor-preview__bar {
    display: flex; align-items: baseline; gap: .6rem;
    padding: .6rem .9rem; border-bottom: 1px solid var(--line); background: #fafafa;
}
.editor-preview__hint { color: var(--grey); font-size: .8rem; }
.editor-preview__frame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 1100px) {
    .editor-split.has-preview.is-preview-open { grid-template-columns: 1fr; }
    .editor-preview { position: static; height: 70vh; }
}

/* ---- Vorschau: Bildschirmbreiten-Presets + Stage ---- */
.editor-preview__bar { flex-wrap: wrap; gap: .5rem .8rem; }
.editor-preview__sizes { display: flex; gap: .25rem; margin-left: auto; }
.editor-preview__sizes button {
    font: 600 .74rem/1 system-ui, sans-serif; padding: .35rem .55rem;
    border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; color: #444;
}
.editor-preview__sizes button.is-active { background: var(--ink, #1a1c22); border-color: var(--ink, #1a1c22); color: #fff; }
.editor-preview__stage { flex: 1; overflow: auto; background: #fff; }
.editor-preview__stage.has-device { background: #e8e8ec; padding: 16px; }
.editor-preview__stage.has-device .editor-preview__frame {
    display: block; background: #fff; border-radius: 6px; box-shadow: 0 2px 14px rgba(0,0,0,.18);
}
.editor-preview__frame { border: 0; width: 100%; height: 100%; }

/* ---- Medien-Picker (Paket 11) ---- */
.mp-overlay {
    position: fixed; inset: 0; z-index: 1000; background: rgba(20, 22, 28, .55);
    display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.mp-overlay[hidden] { display: none; }
.mp-dialog {
    background: #fff; border-radius: var(--radius); width: min(860px, 100%);
    max-height: min(80vh, 700px); display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.mp-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.mp-search { flex: 1; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; }
.mp-close { border: 0; background: none; font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem; color: #666; }
/* Masonry-Layout: Spalten fester Breite, Bilder behalten ihr natürliches
   Seitenverhältnis (kein Zuschnitt mehr). CSS-Multicol packt die Kacheln
   dicht — ohne JS-Reflow-Bibliothek und ohne appendBatch() anzurühren. */
.mp-grid {
    flex: 1; overflow: auto; padding: 1rem;
    column-width: 150px; column-gap: .7rem;
}
.mp-status { column-span: all; color: var(--grey); text-align: center; padding: 2rem 0; }
.mp-item {
    margin: 0 0 .7rem; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer;
    background: #fafafa; display: block; width: 100%;
    break-inside: avoid; -webkit-column-break-inside: avoid;
}
.mp-item:hover { border-color: #999; }
.mp-item.is-selected { border-color: var(--red, #c1121f); box-shadow: 0 0 0 2px rgba(193,18,31,.25); }
.mp-item img { width: 100%; height: auto; display: block; }
.mp-item__video { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; font-size: 2rem; background: #26282e; color: #fff; }
.mp-item figcaption {
    font-size: .68rem; padding: .3rem .4rem; color: #555;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem 1rem; border-top: 1px solid var(--line); }

/* ---- Änderungsprotokoll (Audit-Log) ---- */
.badge--green { background: #e6f4ea; color: #1e7a37; }
.badge--blue  { background: #e6effa; color: #1a4d8f; }
.audit-table td { vertical-align: top; font-size: .85rem; }
.audit-table details summary { cursor: pointer; color: var(--grey); font-size: .8rem; }
.audit-diff { margin: .5rem 0 0; font-size: .8rem; }
.audit-diff dt { font-weight: 700; margin-top: .4rem; }
.audit-diff dd { margin: 0 0 .2rem; overflow-wrap: anywhere; }
.audit-diff__old { color: #a3242c; text-decoration: line-through; }
.audit-diff__new { color: #1e7a37; }

/* ---- Medien aufräumen: kompakte Vorschau ---- */
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.mc-grid .media-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0; background: #fafafa; }
.mc-grid .media-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.mc-grid .media-item__doc { display: flex; align-items: center; justify-content: center; height: 110px; background: #26282e; color: #fff; font-weight: 700; }
.mc-grid figcaption { padding: .4rem .5rem; display: flex; flex-direction: column; gap: .15rem; }
.mc-grid .media-item__name { font-size: .72rem; word-break: break-all; }
