/* ==========================================================================
   WORD UP! – Redaktionsbereich
   Baut auf den Tokens aus site.css auf.
   ========================================================================== */

body.admin { background: var(--paper-2); }

/* --- Kopf ---------------------------------------------------------------- */

.admin-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink);
  color: #fff;
}
.admin-header__inner {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  width: min(100% - 2.5rem, 1320px);
  margin-inline: auto;
  min-height: 64px;
  padding-block: .5rem;
}
.admin-brand { display: inline-flex; align-items: center; gap: .6rem; flex: none; }
.admin-header .logo, .admin-header .logo:hover { color: var(--brand); }
.admin-header .logo__svg--logo { height: 30px; }

.admin-badge {
  padding: .15em .55em; border-radius: 6px;
  background: rgb(255 255 255 / .14);
  font-size: .62rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: #fff;
}

.admin-nav { display: flex; gap: .15rem; flex-wrap: wrap; margin-right: auto; }
.admin-nav a {
  padding: .45rem .8rem; border-radius: 999px;
  color: #cfcbd8; font-size: .92rem; font-weight: 600; text-decoration: none;
}
.admin-nav a:hover { background: rgb(255 255 255 / .1); color: #fff; }
.admin-nav a[aria-current="page"] { background: var(--brand); color: #fff; }

.admin-user { display: flex; align-items: center; gap: .7rem; font-size: .9rem; }
.admin-user a { color: #cfcbd8; text-decoration: none; }
.admin-user a:hover { color: #fff; }
.admin-user form { margin: 0; }
.admin-user .btn--ghost { --btn-fg: #fff; border-color: rgb(255 255 255 / .25); }
.admin-user .btn--ghost:hover { --btn-bg: rgb(255 255 255 / .12); }

/* --- Inhalt -------------------------------------------------------------- */

.admin-main {
  width: min(100% - 2.5rem, 1320px);
  margin-inline: auto;
  padding-block: 2rem 4rem;
}
.admin-main--centered {
  width: min(100% - 2.5rem, 440px);
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
}

.admin-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.8rem;
}
.admin-head h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); margin: 0; }
.admin-head p { margin: .3rem 0 0; color: var(--muted); font-size: .95rem; }
.admin-head__aktionen { display: flex; flex-wrap: wrap; gap: .6rem; }

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.4rem;
}
.admin-panel > h2 {
  font-size: .84rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 1.1rem;
}

/* --- Kennzahlen ---------------------------------------------------------- */

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.6rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem;
}
.stat strong { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: .85rem; color: var(--muted); }
.stat a { font-size: .85rem; font-weight: 600; }

/* --- Tabellen ------------------------------------------------------------ */

.admin-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.admin-table th {
  text-align: left; padding: 0 .8rem .6rem 0;
  font-size: .72rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
}
.admin-table td { padding: .75rem .8rem .75rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table .right { text-align: right; white-space: nowrap; }
.admin-table a.title { font-weight: 700; color: var(--ink); text-decoration: none; }
.admin-table a.title:hover { color: var(--brand-strong); }
.admin-table__thumb {
  width: 52px; height: 38px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line);
}

/* Sortierbare Spaltenkoepfe */
.admin-table--sortable th:has(a) { cursor: pointer; }
.admin-table--sortable th a {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .45rem; margin: -.2rem -.45rem;
  border-radius: 6px;
  color: inherit; text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.admin-table--sortable th a:hover {
  background: var(--paper-2);
  color: var(--brand-strong);
}
.admin-table--sortable th a:hover .sort-pfeil { opacity: 1; }
.admin-table--sortable th[aria-sort] a { color: var(--brand-strong); }

/* Die Kopfzeile ist klein und in Versalien - das Zeichen braucht etwas mehr
   Groesse und Deckkraft, sonst geht es darin unter. */
.sort-pfeil { font-size: 1em; line-height: 1; opacity: .55; }
.sort-pfeil--aktiv { opacity: 1; }
.admin-head .sort-pfeil { font-size: .95em; color: var(--brand); }

/* Sortierknoepfe: nur dort noetig, wo die Spaltenkoepfe ausgeblendet sind */
.filters--sort { display: none; }
@media (max-width: 760px) { .filters--sort { display: flex; } }

.pill {
  display: inline-block; padding: .12em .6em; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
}
.pill--draft { background: #fdeceb; color: #a52d20; }
.pill--live  { background: var(--mint-soft); color: var(--mint); }

@media (max-width: 760px) {
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table thead { display: none; }
  .admin-table tr { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; background: var(--surface); }
  .admin-table td { border: 0; padding: .2rem 0; }
  .admin-table .right { text-align: left; padding-top: .7rem; }
}

/* --- Formulare ----------------------------------------------------------- */

.form-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(12, 1fr); }
.field { grid-column: span 12; }
.field--6 { grid-column: span 6; }
.field--4 { grid-column: span 4; }
.field--3 { grid-column: span 3; }
@media (max-width: 720px) { .field--6, .field--4, .field--3 { grid-column: span 12; } }

.field label, .field > .label {
  display: block; margin-bottom: .35rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; color: var(--ink-2);
}
.field .hint { display: block; margin-top: .35rem; font-size: .82rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%;
  padding: .62rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: .96rem;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.6; font-family: var(--font-text); }
textarea.code { font-family: var(--font-mono); font-size: .88rem; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid rgb(226 117 26 / .25); outline-offset: 0; }

input[type="file"] { font-size: .9rem; }

.check-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.check {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .42rem .85rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); font-size: .9rem; cursor: pointer;
}
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.check input { accent-color: var(--brand); }

.switch { display: inline-flex; align-items: center; gap: .5rem; font-size: .95rem; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

.form-actions {
  display: flex; flex-wrap: wrap; gap: .7rem; align-items: center;
  margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line);
}
.form-actions .spacer { margin-left: auto; }

.btn--danger { --btn-bg: #fff; --btn-fg: #a52d20; border-color: #e8c4bf; }
.btn--danger:hover { --btn-bg: #a52d20; --btn-fg: #fff; }

/* --- Bildauswahl --------------------------------------------------------- */

/* Suchfeld im Kopfbereich einer Liste */
.suche { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.suche input[type="search"] { width: min(320px, 60vw); }

.media-picker {
  display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  max-height: 420px; overflow-y: auto;
  margin-top: .5rem;
  padding: .6rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper);
}
.media-picker__leer { grid-column: 1 / -1; margin: 0; padding: 1.2rem; text-align: center; color: var(--muted); }

.media-pick { position: relative; margin: 0; }
.media-pick img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 8px; border: 2px solid transparent;
  display: block;
}
.media-pick figcaption {
  font-size: .72rem; color: var(--muted); margin-top: .2rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Punkt links = Titelbild, Haekchen rechts = Galerie */
.media-pick__radio, .media-pick__check {
  position: absolute; top: .3rem;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgb(255 255 255 / .9);
  box-shadow: 0 1px 3px rgb(23 22 28 / .35);
  cursor: pointer;
}
.media-pick__radio { left: .3rem; }
.media-pick__check { right: .3rem; border-radius: 7px; }
.media-pick__radio input, .media-pick__check input { margin: 0; width: 16px; height: 16px; accent-color: var(--brand); }

.media-pick:has(input[type="radio"]:checked) img {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgb(226 117 26 / .28);
}
.media-pick:has(input[type="checkbox"]:checked) img { border-color: var(--mint); }
.media-pick:has(input[type="radio"]:checked):has(input[type="checkbox"]:checked) img {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgb(15 127 99 / .3);
}

/* Kachel "kein Titelbild" */
.media-pick--none .media-pick__none {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; aspect-ratio: 4/3;
  border: 2px dashed var(--line-strong); border-radius: 8px;
  font-size: .78rem; color: var(--muted); text-align: center; cursor: pointer;
}
.media-pick--none:has(input:checked) .media-pick__none {
  border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft);
}
.media-pick--none input { accent-color: var(--brand); }

.media-item__meta { font-size: .78rem; color: var(--muted); margin: 0 0 .8rem; }

/* Ein Eintrag je Bild: Auswahlflaeche, Vorschauen, Angaben */
.media-list { display: grid; gap: 1.6rem; }
.media-edit {
  display: grid; gap: 1.4rem;
  grid-template-columns: minmax(220px, 300px) minmax(160px, 220px) minmax(240px, 1fr);
  align-items: start;
  padding: 1.2rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
@media (max-width: 900px) { .media-edit { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .media-edit { grid-template-columns: 1fr; } }

.media-edit__fields { display: grid; gap: .35rem; align-content: start; }
.media-edit__fields label {
  font-size: .78rem; font-weight: 700; color: var(--ink-2); margin-top: .4rem;
}
.media-edit__fields input { font-size: .9rem; padding: .45rem .65rem; }
.media-edit__actions { margin-top: .8rem; }
.media-edit__delete { margin: -1rem 0 0; text-align: right; }

/* Klickflaeche: das ganze Bild, unbeschnitten */
.focus-pick {
  position: relative; display: block; cursor: crosshair;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--paper-2);
  touch-action: manipulation;
}
.focus-pick img { width: 100%; height: auto; display: block; }
.focus-pick__dot {
  position: absolute; width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid #fff; border-radius: 50%;
  background: rgb(226 117 26 / .55);
  box-shadow: 0 0 0 1.5px rgb(23 22 28 / .55), 0 2px 6px rgb(23 22 28 / .45);
  pointer-events: none;
}

.focus-previews { display: grid; gap: .5rem; }
.focus-previews .label {
  display: block; font-size: .78rem; font-weight: 700; color: var(--ink-2);
}
.focus-previews figure { margin: 0; }
.focus-previews img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.focus-previews__wide img { aspect-ratio: 21 / 9; }
.focus-previews figcaption { font-size: .72rem; color: var(--muted); margin-top: .2rem; }

.focus-readout {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin: .8rem 0 0; font-size: .8rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Anmeldung ----------------------------------------------------------- */

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem 2rem 2.2rem;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.login-card p.sub { color: var(--muted); font-size: .93rem; margin-bottom: 1.6rem; }
.login-brand { display: flex; justify-content: center; margin-bottom: 1.4rem; }
.login-mark { height: 46px; width: auto; color: var(--brand); }

/* Direktlink von der Redaktion auf die oeffentliche Seite */
.admin-viewsite {
  display: inline-flex; align-items: center; gap: .4rem;
  white-space: nowrap; font-weight: 600;
}
