/* Social Planner - single stylesheet, no external dependencies. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #d9dde3;
    --text: #1d2430;
    --muted: #6b7583;
    --accent: #2f6fed;
    --accent-dark: #1f57c6;
    --danger: #c8342c;
    --ok: #1c8a4b;

    --st-draft: #8a94a4;
    --st-scheduled: #2f6fed;
    --st-processing: #b8860b;
    --st-posted: #1c8a4b;
    --st-partial: #d97706;
    --st-failed: #c8342c;
    --st-cancelled: #5c6270;

    --radius: 8px;
    --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

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

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: var(--gap);
    flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
}

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

.mainnav {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.mainnav a {
    padding: 6px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--muted);
}

.mainnav a:hover { background: var(--bg); }
.mainnav a.active { background: var(--accent); color: #fff; }

.logout { display: flex; align-items: center; gap: 8px; margin: 0; }
.who { color: var(--muted); font-size: 13px; text-decoration: none; }
.who:hover { color: var(--accent); text-decoration: underline; }

.wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: var(--gap);
}

.card-narrow { width: min(380px, 100%); }

.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: var(--gap);
}

.spacer { flex: 1; }

/* ---------- forms ---------- */

label { display: block; }
label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=datetime-local], input[type=number], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea { min-height: 130px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(47, 111, 237, .35);
    border-color: var(--accent);
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }

.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.checkbox span { margin: 0; }

.btn {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #e7bfbc; }
.btn-danger:hover { background: #fdf2f1; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: 4px 8px; font-size: 13px; }

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

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid;
}

.flash-success { background: #e8f6ee; border-color: #b6e0c6; color: #17643a; }
.flash-error { background: #fdecea; border-color: #f2c2bd; color: #8d251f; }

/* Ueberfaellig ist kein Fehler, sondern eine Warnung: irgendwo steht die
   Auslieferung. Deshalb Bernstein statt Rot - Rot ist hier schon vergeben
   fuer "Posten fehlgeschlagen", und die beiden darf man nicht verwechseln. */
.flash-warn { background: #fdf4e3; border-color: #e8cf9a; color: #7a5312; }

.errors {
    background: #fdecea;
    border: 1px solid #f2c2bd;
    color: #8d251f;
    border-radius: var(--radius);
    padding: 12px 14px 12px 30px;
    margin-bottom: var(--gap);
}

.errors li { margin: 2px 0; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfc; }

/* ---------- status ---------- */

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    color: #fff;
    white-space: nowrap;
}

.badge-draft { background: var(--st-draft); }
.badge-scheduled { background: var(--st-scheduled); }
.badge-processing { background: var(--st-processing); }
.badge-posted { background: var(--st-posted); }
.badge-partial { background: var(--st-partial); }
.badge-failed { background: var(--st-failed); }
.badge-cancelled { background: var(--st-cancelled); }

/* Kein Status, sondern ein Zusatz: das Abzeichen steht NEBEN dem Status und
   sagt, dass der Termin verstrichen ist, ohne dass etwas passiert waere. */
.badge-overdue { background: #b06f0c; }

.pill {
    display: inline-block;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 11px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: #fff;
}

.pill.ok { border-color: #b6e0c6; color: var(--ok); }
.pill.err { border-color: #f2c2bd; color: var(--danger); }
.pill.skip { border-color: #ddd; color: var(--muted); text-decoration: line-through; }

/* Beleg der Veroeffentlichung: wann es rausging, und der Klick zum Beitrag.
   Die Zeit steht in der Erfolgsfarbe - sie erscheint nur, wenn wirklich
   gepostet wurde, und ist damit selbst schon die gute Nachricht. */

.posted-at { color: var(--ok); margin-top: 2px; }

.post-links { margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.post-links a { white-space: nowrap; }

/* ---------- week grid ---------- */

.week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 160px;
    padding: 8px;
}

.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.day h3 { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.day h3 .num { color: var(--text); font-size: 15px; font-weight: 700; }

.entry {
    display: block;
    border: 1px solid var(--border);
    border-left: 4px solid var(--st-draft);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 6px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    font-size: 13px;
}

.entry:hover { background: #f7f9ff; }
.entry .time { font-weight: 700; }
.entry .company { color: var(--muted); font-size: 12px; display: block; }
.entry .platforms { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }

.entry.s-draft { border-left-color: var(--st-draft); }
.entry.s-scheduled { border-left-color: var(--st-scheduled); }
.entry.s-processing { border-left-color: var(--st-processing); }
.entry.s-posted { border-left-color: var(--st-posted); }
.entry.s-partial { border-left-color: var(--st-partial); }
.entry.s-failed { border-left-color: var(--st-failed); }

/* Ueberfaellig schlaegt die Statusfarbe am linken Rand - beim Ueberfliegen
   der Woche soll genau das ins Auge springen, nicht "eingeplant". */
.entry.overdue { border-left-color: #b06f0c; background: #fdf9f1; }
.entry.overdue:hover { background: #fbf3e4; }

tr.row-overdue > td { background: #fdf9f1; }
.entry.s-cancelled { border-left-color: var(--st-cancelled); }

/* ---------- post editor ---------- */

.editor { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: var(--gap); align-items: start; }

.platforms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--gap); }

.platform-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.platform-card.off { opacity: .55; }
.platform-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.platform-card header h3 { margin: 0; flex: 1; }

.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--danger); font-weight: 700; }

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    color: var(--muted);
    background: #fbfcfd;
    cursor: pointer;
}

.dropzone.dragover { border-color: var(--accent); background: #eef4ff; color: var(--accent); }

.focal-wrap { position: relative; display: inline-block; max-width: min(100%, 460px); cursor: crosshair; }
.focal-wrap img { display: block; max-width: 100%; border-radius: var(--radius); }

.focal-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
    pointer-events: none;
}

.previews { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.preview { text-align: center; font-size: 11px; color: var(--muted); }

/* Fixed box so the captions line up even though the crops differ in height. */
.preview > div { height: 86px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 4px; }
.preview img { display: block; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.preview .square img { width: 72px; height: 72px; }
.preview .portrait img { width: 64px; height: 80px; }
.preview .pin img { width: 56px; height: 84px; }
.preview .landscape img { width: 92px; height: 48px; }
.preview .story img { width: 48px; height: 85px; }
.preview img { object-fit: cover; }

/* ---------- selected media strip ---------- */

.media-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.media-strip.empty { display: none; }

.strip-tile {
    position: relative;
    width: 92px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    background: #fff;
    cursor: pointer;
}

.strip-tile.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 111, 237, .25); }
.strip-tile img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 4px; display: block; }

.strip-order {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(29, 36, 48, .8);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 4px;
}

.strip-controls { display: flex; gap: 2px; margin-top: 4px; }
.strip-controls button { flex: 1; padding: 2px 0; font-size: 11px; }
.strip-controls button:disabled { opacity: .4; cursor: default; }

.video-thumb {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #1d2430;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
}

#video-player {
    width: 100%;
    max-width: 320px;
    max-height: 420px;
    border-radius: var(--radius);
    background: #000;
    display: block;
}

#video-meta { margin-top: 10px; grid-template-columns: 130px 1fr; }

.warnings {
    background: #fff8e6;
    border: 1px solid #f0dca8;
    color: #7a5600;
    border-radius: var(--radius);
    padding: 12px 14px 12px 30px;
    margin-bottom: var(--gap);
}

.warnings li { margin: 2px 0; }

.format-hint:empty { display: none; }

/* ---------- password field with reveal toggle ---------- */

.password-field { position: relative; display: block; }
.password-field input { padding-right: 42px; }

.password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 34px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.password-toggle:hover { background: var(--bg); color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); }

.password-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
}

/* ---------- roles ---------- */

.role-option { align-items: flex-start; gap: 10px; padding: 8px 0; }
.role-option input { margin-top: 3px; }
.role-option span { margin: 0; }

/* ---------- help page ---------- */

.help-toc ol { margin: 8px 0 0; padding-left: 20px; }
.help-toc li { margin: 3px 0; }

.help-steps { padding-left: 20px; margin: 0; }
.help-steps li { margin-bottom: 10px; }

.help-list { padding-left: 20px; margin: 8px 0; }
.help-list li { margin: 4px 0; }

.help-faq dt { color: var(--text); font-weight: 600; margin-top: 10px; }
.help-faq dd { margin-bottom: 10px; }

/* The anchors from the table of contents must not hide under the top bar. */
[id] { scroll-margin-top: 16px; }

@media (max-width: 640px) {
    .kv, .help-faq { grid-template-columns: 1fr; }
    .kv dt { margin-top: 8px; }
}

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

.media-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    padding: 6px;
    text-align: center;
    font-size: 12px;
}

.media-tile img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 4px; display: block; }
.media-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 111, 237, .25); }
.media-tile button { width: 100%; margin-top: 4px; }
.media-tile .warn { color: #a15c00; }

.picker { max-height: 320px; overflow: auto; margin-top: 10px; }

details.help summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* Aufklappbare Erklaerung direkt am Feld - etwa "wo finde ich die
   Seiten-ID?". Zugeklappt darf sie nur eine Zeile kosten, sonst waere die
   Plattform-Karte nicht mehr zu ueberblicken. */
details.hinweis { margin: -2px 0 10px; }
details.hinweis summary { cursor: pointer; color: var(--accent); }
details.hinweis > *:not(summary) { color: var(--muted); }
details.hinweis ol { padding-left: 18px; margin: 6px 0; }
details.hinweis li { margin: 3px 0; }
details.hinweis p { margin: 6px 0 0; }

.token-box {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.token-box input { flex: 1 1 320px; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.board-row { display: flex; gap: 8px; margin-bottom: 6px; }
.board-row input { flex: 1; }

@media (max-width: 1100px) {
    .editor { grid-template-columns: 1fr; }
    .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .week { grid-template-columns: 1fr; }
    .wrap { padding: 12px; }
}
