/* DiscordFit Web, Design 2.
   Idee: Die Seite verhält sich wie die Desktop-App, nicht wie eine Landingpage. Ein fester
   Viewport ohne Scrollen, drei Ansichten (Verkleinern / So funktioniert's / Desktop-App) als
   Tabs, rein per CSS über Radio-Inputs (.view-switch) geschaltet. Farb-Tokens 1:1 aus
   client/src/discordfit/gui/theme.py. Design 1 liegt unverändert unter static/v1/. */

:root {
  --bg: #1a1f27;
  --surface: #1e232b;
  --surface-2: #252b35;
  --surface-hover: #2c333f;
  --border: #323945;
  --text: #d7dae0;
  --text-dim: #8b95a5;
  --text-muted: #646d7c;
  --accent: #5865f2;
  --accent-hover: #6d78f5;
  --accent-dim: #3c45a8;
  --accent-wash: #232a3d;
  --success: #89ad23;
  --success-hover: #9ac22a;
  --error: #e06c75;
  --font-display: "Outfit", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --gutter: clamp(1rem, 3vw, 3rem);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; font-weight: 600; }
h1 { font-size: clamp(1.7rem, 2.4vw, 2.4rem); letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; }

/* ---------- Gerüst: Kopf / Bühne / Fuß, Bühne füllt den Rest des Viewports ---------- */

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-inline: var(--gutter);
}
@media (min-width: 900px) and (min-height: 600px) {
  .shell { height: 100dvh; overflow: hidden; }   /* kein Seiten-Scrollen am Desktop */
  .stage { min-height: 0; overflow: auto; }      /* Sicherheitsventil bei sehr niedrigen Fenstern */
}

/* Kopfzeile: Logo und Wortmarke groß, Ansichten rechts */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  padding-block: 1.25rem 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.9rem; text-decoration: none; }
.brand-logo { height: 56px; width: auto; display: block; }
.brand-word { height: 34px; width: auto; display: block; }

/* Ansichten-Umschalter: alle drei Einträge gleich hoch und gleich groß gesetzt, damit die
   Kopfzeile wie eine Leiste wirkt. Die beiden Tabs sitzen als Segment-Gruppe in einer
   dunklen Schiene, der App-Button daneben hat dieselbe Höhe. */
.views-nav { display: flex; align-items: stretch; gap: 0.75rem; flex-wrap: wrap; }
.views-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.views-nav a, .views-nav label {
  display: inline-flex;
  align-items: center;
  height: 44px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0 1.1rem;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.views-tabs a:hover, .views-tabs label:hover { color: var(--text); background: var(--surface-2); }

/* Desktop-App: bewusst kein dritter Tab, sondern ein umrandeter Button mit App-Icon, damit
   Besucher sofort sehen, dass es das Werkzeug auch als Windows-Programm gibt. */
.views-nav .nav-app {
  gap: 0.6rem;
  height: auto;               /* streckt sich auf die Höhe der Tab-Schiene */
  padding: 0 1.1rem 0 0.7rem;
  color: var(--text);
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  border-radius: 10px;
}
.views-nav .nav-app img { height: 28px; width: auto; border-radius: 7px; }
.views-nav .nav-app:hover { background: var(--accent-dim); border-color: var(--accent-hover); color: #fff; }

/* Sprachwahl: zwei kleine Flaggen rechts von den Ansichten. Die aktive ist voll sichtbar
   und umrandet, die andere gedimmt – ein Klick wechselt (Cookie, gleiche Seite). */
.lang { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.5rem; }
.lang a {
  display: inline-flex;
  height: auto;
  padding: 0.3rem;
  border-radius: 6px;
  border: 1px solid transparent;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}
.lang a svg { width: 28px; height: auto; display: block; border-radius: 3px; }
.lang a:hover { opacity: 0.85; background: var(--surface-2); }
.lang a.is-active { opacity: 1; border-color: var(--border); background: var(--surface); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Statusleiste, nach dem Vorbild der QStatusBar im Client: gut lesbarer Status-Text links
   (TEXT_DIM, normale Schriftgröße), rechts Version und der Kaffee-Hinweis. */
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  padding-block: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1.05rem;
}
.status-meta { display: flex; align-items: center; gap: 1rem; white-space: nowrap; }
.status-version { color: var(--text-muted); font-family: var(--font-display); }
.status-meta a { color: var(--text-dim); text-decoration: none; }
.status-meta a:hover { color: var(--accent-hover); }
.status-coffee { font-weight: 600; }

/* ---------- Ansichten schalten (Radio-Inputs stehen vor .top und .stage) ---------- */

.view-switch { position: absolute; opacity: 0; pointer-events: none; }
.view { display: none; height: 100%; }

#view-tool:checked ~ .stage .view-tool,
#view-how:checked  ~ .stage .view-how,
#view-app:checked  ~ .stage .view-app { display: block; }

#view-tool:checked ~ .top label[for="view-tool"],
#view-how:checked  ~ .top label[for="view-how"],
#view-app:checked  ~ .top label[for="view-app"] { color: #fff; background: var(--accent); border-color: var(--accent); }

.view-switch:focus-visible ~ .top label { outline: 2px solid var(--accent-hover); }

/* Seiten ohne Umschalter (Status, Admin) zeigen ihre eine Ansicht immer */
.view-jobs, .view-admin { display: block; }

.stage { padding-block: 0.75rem 1.25rem; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1.3rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.button:hover { background: var(--surface-hover); border-color: var(--accent); color: var(--text); }

.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.button-success { background: var(--success); border-color: var(--success); color: #10160a; }
.button-success:hover { background: var(--success-hover); border-color: var(--success-hover); color: #10160a; }

/* ---------- Ansicht 1: Werkzeug ---------- */

.tool {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1.25rem 1.5rem;
}
.tool-intro { grid-column: 1 / -1; max-width: 62ch; }
.tool-intro p { color: var(--text-dim); font-size: 1.1rem; margin-top: 0.5rem; }

/* Die Ablagefläche ist das eine laute Element der Seite. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 280px;
  border: 2px dashed var(--accent-dim);
  border-radius: 16px;
  background: var(--surface);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag-active { border-color: var(--accent); background: var(--accent-wash); }
.dropzone.has-files { border-style: solid; border-color: var(--success); }
.dropzone img { height: clamp(72px, 10vh, 120px); width: auto; margin-bottom: 0.75rem; }
.dropzone-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.dropzone-or { color: var(--text-muted); font-size: 0.9rem; }
.dropzone-limits { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.75rem; max-width: 100%; }

/* Gewählte Dateien als Karten – angelehnt an die Liste der Desktop-App: Vorschau links,
   Name und Größe daneben, Entfernen rechts. Alles entsteht im Browser (siehe app.js), der
   Server bekommt die Datei erst beim Absenden zu sehen. */
.dropzone-files {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(100%, 520px);
  text-align: left;
}
.file-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.file-card.is-oversized { border-color: var(--error); }

/* Vorschau-Kachel: zeigt bis zum Laden die Dateiendung, danach Bild bzw. Video-Frame. */
.file-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 42px;
  flex: none;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.file-thumb img, .file-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }

.file-text { display: flex; flex-direction: column; min-width: 0; gap: 0.15rem; }
.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta { color: var(--text-dim); font-size: 0.85rem; }
.is-oversized .file-meta { color: var(--error); }

.file-remove {
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.file-remove:hover { color: var(--text); background: var(--surface-hover); }

.file-summary { margin-top: 0.9rem; color: var(--text-dim); font-size: 0.95rem; }
.file-summary.has-problem { color: var(--error); max-width: 46ch; }

/* font-size 0 blendet den nativen "Keine Datei ausgewählt"-Text aus; die gewählten Dateien
   zeigt .dropzone-files (JS) bzw. der Button-Text selbst. */
input[type="file"] { font-size: 0; color: transparent; max-width: 100%; }
input[type="file"]::file-selector-button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.3rem;
  margin-right: 0.9rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--accent-hover); }

/* Rechte Spalte: Limit wählen, starten */
.tool-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}

.targets { border: 0; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.targets legend { font-weight: 600; margin-bottom: 0.75rem; padding: 0; }
.targets input { position: absolute; opacity: 0; pointer-events: none; }
.targets label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text-dim);
}
.targets label:hover { background: var(--surface-hover); border-color: var(--accent-dim); }
.targets input:checked + label { background: var(--accent); border-color: var(--accent); color: #fff; }
.targets input:focus-visible + label { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.target-name { font-weight: 600; }
.target-size { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; opacity: 0.85; }

.button-start { font-size: 1.1rem; padding: 0.9rem 1.5rem; margin-top: auto; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button:disabled:hover { background: var(--accent); border-color: var(--accent); }
.tool-note { color: var(--text-dim); font-size: 1rem; line-height: 1.45; }
.tool-note-app label { color: var(--accent); cursor: pointer; }
.tool-note-app label:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Ansicht 2: So funktioniert's ---------- */

.how {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.4fr;
  gap: 2rem 3rem;
  align-content: center;
}
.how-text p { color: var(--text-dim); font-size: 1.1rem; margin-top: 0.75rem; max-width: 46ch; }

.demo {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  max-width: 400px;
}
.demo-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.demo-file { color: var(--text-dim); font-size: 0.9rem; }
.demo-before { font-family: var(--font-display); font-weight: 600; color: var(--text-muted); text-decoration: line-through; }
.demo-after { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--success); }
.demo-bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 0.8rem 0; overflow: hidden; }
.demo-bar-fill { height: 100%; width: 9%; background: var(--success); }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.steps li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}
.steps img { height: clamp(56px, 8vh, 84px); width: auto; margin-bottom: 0.9rem; display: block; }
.steps p { color: var(--text-dim); font-size: 0.95rem; margin-top: 0.35rem; }

/* ---------- Ansicht 3: Desktop-App ---------- */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 26rem) minmax(0, 1fr);
  gap: 2rem 3rem;
  align-content: center;
  align-items: center;
}
.app-icon { height: clamp(64px, 9vh, 88px); width: auto; border-radius: 22%; margin-bottom: 1rem; display: block; }
.app-text > p { color: var(--text-dim); font-size: 1.1rem; margin-top: 0.75rem; }
.app-points { margin: 1.25rem 0 1.75rem; padding-left: 1.2rem; color: var(--text-dim); }
.app-points li { margin-bottom: 0.35rem; }
.app-soon { color: var(--text-muted); font-size: 1rem; }

/* Screenshot der Windows-App: schlichter Rahmen, damit das Bild als Fenster lesbar bleibt und
   nicht in den Seitenhintergrund ausfranst. Höhe begrenzt, damit die Ansicht nicht scrollt. */
.app-shot { margin: 0; min-width: 0; }
.app-shot img {
  width: 100%;
  height: auto;
  max-height: min(62vh, 620px);
  object-fit: contain;
  object-position: left center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  display: block;
}

/* ---------- Statusseite ---------- */

.view-jobs { max-width: 760px; }
.jobs-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem 1.5rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.job-name { font-weight: 600; overflow-wrap: anywhere; }
.job-phase { color: var(--text-dim); font-size: 0.9rem; grid-column: 1; }
.job .button { grid-row: 1 / span 2; grid-column: 2; }
.job-done, .job-downloaded { border-color: var(--success); }
.job-downloaded .job-phase { color: var(--success); }
.job-failed { border-color: var(--error); }
.job-failed .job-phase { color: var(--error); }
.progress { grid-column: 1 / -1; background: var(--surface-2); border-radius: 3px; height: 6px; overflow: hidden; }
.progress-bar { background: var(--accent); height: 100%; transition: width 0.3s ease; }

/* ---------- Admin ---------- */

.view-admin { max-width: 640px; }
.view-admin h1 { margin-bottom: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.hint { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.75rem; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-dim); font-weight: 600; font-size: 0.85rem; }

/* ---------- Schmale Fenster: Spalten stapeln, Scrollen erlaubt ---------- */

@media (max-width: 899px) {
  .brand-logo { height: 44px; }
  .brand-word { height: 26px; }
  .views-nav a, .views-nav label { height: 38px; font-size: 0.95rem; padding: 0 0.8rem; }
  .lang a svg { width: 24px; }
  .views-nav .nav-app { padding: 0 0.8rem 0 0.5rem; }
  .views-nav .nav-app img { height: 22px; }
  .statusbar { font-size: 0.95rem; }
  .tool-note { font-size: 0.95rem; }
  /* minmax(0, 1fr) statt 1fr: sonst zwingt die Mindestbreite des Datei-Inputs die Spalte über den Viewport */
  .tool, .how, .app { grid-template-columns: minmax(0, 1fr); height: auto; }
  .app-shot img { max-height: none; }
  .tool-settings { padding: 1.25rem; }
  .dropzone { min-height: 220px; }
  .steps { grid-template-columns: 1fr; }
  .app { justify-items: start; }
}
@media (max-width: 540px) {
  .steps, .jobs { gap: 0.6rem; }
  .job { grid-template-columns: 1fr; }
  .job .button { grid-row: auto; grid-column: 1; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Admin: Überschrift über der Live-Tabelle */
.admin-h2 { font-family: var(--font-display); font-size: 1.15rem; margin: 1.5rem 0 0.75rem; }
