/*!
 * Download-Portal – Stylesheet
 * Copyright (c) 2026 Kevin Dieter Wachter. Alle Rechte vorbehalten.
 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #6b7484;
  --border: #e2e5ea;
  --accent: #2357d9;
  --accent-hover: #1a45b3;
  --accent-soft: #e8eefc;
  --ok: #1d7a46;   --ok-bg: #e3f4ea;
  --warn: #9a5b00; --warn-bg: #fdf0d9;
  --err: #b42323;  --err-bg: #fbe5e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --on-accent: #fff;
  color-scheme: light;
}
/* Dunkel: automatisch nach Systemeinstellung oder fest per <html data-theme="dark"> */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
  --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #9098a6; --border: #2c323d;
  --accent: #6d95ff; --accent-hover: #8aaaff; --accent-soft: #1f2a44; --on-accent: #fff;
  --ok: #5fd08e; --ok-bg: #173325; --warn: #f0b354; --warn-bg: #3a2c12; --err: #ff8080; --err-bg: #3c1a1a;
  --shadow: none; color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #9098a6; --border: #2c323d;
  --accent: #6d95ff; --accent-hover: #8aaaff; --accent-soft: #1f2a44; --on-accent: #fff;
  --ok: #5fd08e; --ok-bg: #173325; --warn: #f0b354; --warn-bg: #3a2c12; --err: #ff8080; --err-bg: #3c1a1a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.warn-text { color: var(--warn); font-weight: 600; }

/* --- Bausteine ------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem;
}
.card.narrow { max-width: 460px; }
.card.highlight { border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.card-head p { margin: .25rem 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent; border-radius: 8px;
  padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: transparent; color: var(--err); border-color: var(--border); }
.btn-danger:hover { background: var(--err-bg); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; font-weight: 500; }
.btn-disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-disabled:hover { background: var(--border); }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { color: var(--text); }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 0 .25rem; }
.icon-btn:hover { color: var(--accent); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: .4rem; }
input.tiny { width: 5.5rem; display: inline-block; padding: .25rem .4rem; }
textarea { resize: vertical; }
label { display: block; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0 .35rem; }

.stack > * + * { margin-top: .9rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 0 1 auto; }
.row > .grow { flex: 1 1 220px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .btn { margin-top: 1.25rem; }
form.inline { display: inline; }

.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; padding: .2rem 0; }
.radios { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.checklist { display: flex; flex-direction: column; gap: .1rem; max-height: 220px; overflow: auto; }
.checklist.tall { max-height: 360px; }
.filter { margin-bottom: .5rem; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--err-bg); color: var(--err); }

.tag, .pill {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; border: 0; font-family: inherit;
}
.pill { cursor: pointer; }
.tag-ok, .tag-redeem, .pill-on { background: var(--ok-bg); color: var(--ok); }
.tag-warn, .tag-invalid, .tag-login_failed { background: var(--warn-bg); color: var(--warn); }
.tag-blocked { background: var(--err-bg); color: var(--err); }
.tag-muted, .tag-login, .pill-off { background: var(--border); color: var(--muted); }

.kind {
  display: inline-block; min-width: 3.6rem; text-align: center; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; padding: .2rem .4rem; border-radius: 6px;
  background: var(--border); color: var(--muted);
}
.kind-bild { background: #e7f6ef; color: #1d7a46; }
.kind-video { background: #efe9fd; color: #6236c9; }
.kind-audio { background: #fdecef; color: #b4234b; }
.kind-pdf { background: #fdebe3; color: #b43d12; }
.kind-archiv { background: #fdf3d9; color: #8a5a00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .kind-bild { background: #173325; color: #5fd08e; }
  :root:not([data-theme=light]) .kind-video { background: #2a2147; color: #b49bff; }
  :root:not([data-theme=light]) .kind-audio { background: #3c1a26; color: #ff8fae; }
  :root:not([data-theme=light]) .kind-pdf { background: #3c2419; color: #ff9f73; }
  :root:not([data-theme=light]) .kind-archiv { background: #3a2c12; color: #f0b354; }
}
:root[data-theme=dark] .kind-bild { background: #173325; color: #5fd08e; }
:root[data-theme=dark] .kind-video { background: #2a2147; color: #b49bff; }
:root[data-theme=dark] .kind-audio { background: #3c1a26; color: #ff8fae; }
:root[data-theme=dark] .kind-pdf { background: #3c2419; color: #ff9f73; }
:root[data-theme=dark] .kind-archiv { background: #3a2c12; color: #f0b354; }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th.num { text-align: right; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }
.row-muted { opacity: .55; }
.row-new { background: var(--accent-soft); }
td.actions { text-align: right; }
td.actions .btn, td.actions form { margin-left: .25rem; }
td.ua { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .82rem; }

.meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--border); margin-right: .5rem; vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }

/* --- Öffentliche Seite ------------------------------------------------ */
.public-wrap { max-width: 640px; margin: 0 auto; padding: 3rem 16px; }
.public-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.public-head h1 { margin: 0; font-size: 1.4rem; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.code-form { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.code-form input {
  flex: 1 1 220px; font-family: var(--mono); font-size: 1.2rem; letter-spacing: .12em; text-transform: uppercase; padding: .7rem .9rem;
}
.code-form .btn { flex: 0 0 auto; padding: .7rem 1.3rem; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { display: flex; align-items: center; gap: .9rem; padding: .85rem 0; border-top: 1px solid var(--border); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-meta strong, .file-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .muted { font-size: .85rem; }
.file-meta .desc { font-size: .88rem; margin-top: .2rem; }
@media (max-width: 520px) {
  .file-list li { flex-wrap: wrap; }
  .file-list li .btn { width: 100%; }
}

/* --- Admin ------------------------------------------------------------ */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
.brand span { color: var(--muted); font-weight: 500; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 6px; }
.topbar nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar nav form { margin-left: .5rem; }
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); color: var(--muted); font-size: .88rem; }
.stat span { display: block; font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat small { display: block; font-size: .78rem; }
.stat-warn span { color: var(--warn); }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.filters .row { grid-column: 1 / -1; }
.tabs { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; color: var(--muted); }
.tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); border: 1px solid var(--border); }
.tabs .muted { margin-left: auto; font-size: .88rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1rem; }
.code-editor > .btn { margin-top: 1.25rem; }
#newcodes { font-size: .85rem; white-space: pre; }

/* --- Code-Option beim Hochladen / Footer ------------------------------ */
.code-option .code-option-body > * + * { margin-top: .75rem; }
.code-option .radios + .code-option-body { margin-top: .75rem; }
.field-label { display: block; font-weight: 500; margin-bottom: .3rem; }
[hidden] { display: none !important; }
.site-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 1.5rem 16px 2rem; }
.public .site-footer { margin-top: -1.5rem; }
.site-footer .sep { margin: 0 .35rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* --- Changelog --------------------------------------------------------- */
.changelog > p { margin-top: 0; }
.changelog .release + .release { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1.25rem; }
.changelog h2 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.changelog h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .35rem; }
.changelog ul { margin: 0; padding-left: 1.2rem; }
.changelog li + li { margin-top: .25rem; }

/* --- Logo & Einbettung -------------------------------------------------- */
.brand-logo { display: block; width: auto; max-width: min(100%, 320px); object-fit: contain; }
.public-head .brand-logo + h1 { margin-left: .25rem; }
.brand img { height: 26px; width: auto; vertical-align: middle; margin-right: .5rem; }
body.embed { background: transparent; display: flow-root; }
.embed .public-wrap { max-width: none; padding: 2px 2px 0; }
.embed .public-head { margin-bottom: 1rem; }
.embed .site-footer { margin-top: -.5rem; padding: 0 0 .5rem; font-size: .75rem; }

/* --- Admin: Anpassen ----------------------------------------------------- */
.logo-preview { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem; border: 1px dashed var(--border); border-radius: 8px; }
.logo-preview img { max-height: 80px; max-width: 260px; }
input[type=color] { width: 3.2rem; height: 2.4rem; padding: .15rem; cursor: pointer; }
.snippet { position: relative; }
.snippet textarea { font-family: var(--mono); font-size: .82rem; white-space: pre; }
.snippet .btn { position: absolute; top: .4rem; right: .4rem; }
.embed-preview { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg); }
.embed-preview iframe { display: block; width: 100%; height: 320px; border: 0; }
