/*
 * LabelCrop – Stylesheet
 *
 * Gleicher Look wie tourelleworks.de: Kopf- und Fußzeile in Nachtblau mit
 * Mondgelb, Inhalt auf leicht getöntem Hellgrau mit weißen Karten.
 * Farben nur über die Variablen auf :root – einmal definieren, überall nutzen.
 */

:root {
  --night: #0f1b33;        /* Nachtblau – Kopf- und Fußzeile, Überschriften, Buttons */
  --moon: #f2e6b3;         /* Mondgelb – Logo, Akzente auf Nachtblau */
  --bg: #eef1f6;           /* Seitenhintergrund: leicht blau getöntes Hellgrau */
  --surface: #ffffff;      /* Karten */
  --surface-soft: #f6f8fc; /* Eingabegruppen, Hover */
  --text: #1f2937;
  --text-muted: #5f6b80;
  --line: #d9dee8;
  --on-night: #e6e9f0;
  --on-night-muted: #a9b1c4;
  --warn-bg: #fff6d9;      /* Hinweise: Gelbton, passend zum Mondgelb */
  --warn-line: #f0d98a;
  --warn-text: #6b4a00;
  --error-bg: #fdecec;
  --error-line: #f3c2c2;
  --error-text: #8a1c1c;
  --max-width: 64rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

/* Das hidden-Attribut muss auch gegen Klassen mit display: grid/flex gewinnen –
   die Browser-Vorgabe hat sonst die geringere Spezifität. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Systemschriften: keine externen Server, keine Wartezeit. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--night);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

:focus-visible {
  outline: 2px solid var(--night);
  outline-offset: 3px;
}

.site-header :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--moon);
}

/* ---------- Kopf- und Fußzeile ---------- */

.site-header {
  background: var(--night);
  color: var(--on-night);
}

.site-header .inner,
.site-footer .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--moon);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.brand img {
  width: 1.9rem;
  height: 1.9rem;
}

.home-link {
  color: var(--on-night-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.home-link:hover,
.home-link:focus-visible {
  color: var(--moon);
}

.site-footer {
  background: var(--night);
  color: var(--on-night-muted);
  font-size: 0.9rem;
}

/* ---------- Inhalt ---------- */

.content {
  /* width: 100% ist nötig: als Flex-Kind mit margin auto wäre main sonst nur so breit wie sein Inhalt. */
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  box-shadow: 0 1px 2px rgba(15, 27, 51, 0.06);
  padding: 1.25rem;
}

.intro h1 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.intro p {
  margin: 0;
  color: var(--text-muted);
}

/* Kleine Abschnittstitel wie auf der Hauptseite. */
.settings h2,
.hints h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ---------- Ablagefläche ---------- */

.dropzone {
  border: 2px dashed var(--line);
  text-align: center;
  padding: 2.25rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone:hover,
body.dragging .dropzone {
  border-color: var(--night);
  background: var(--surface-soft);
}

.dropzone strong {
  display: block;
  font-size: 1.05rem;
  color: var(--night);
}

.dropzone span {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Einstellungen ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.9rem 1.25rem;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field select,
.field input {
  font: inherit;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--surface);
  min-width: 0;
}

.field select:disabled {
  color: var(--text-muted);
  background: var(--bg);
}

/* Zusatzfelder für "Eigener Bereich" / "Eigene Größe": volle Breite, eigener Kasten. */
.field-group {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.6rem 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-soft);
}

.hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Zwei Schritte in den Einstellungen: Label-Typ (woher), Drucker-Profil (wohin). */
.settings-block + .settings-block {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.settings-block h2 {
  margin-bottom: 0.7rem;
}

.settings-block h2 .muted {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

/* Feineinstellungen eingeklappt; die Zusammenfassung in der Kopfzeile zeigt, was gilt. */
.fine-tuning {
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface-soft);
}

.fine-tuning summary {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text);
  list-style: revert;
}

.fine-tuning summary span {
  color: var(--text-muted);
}

.fine-tuning[open] summary {
  border-bottom: 1px solid var(--line);
}

.fine-tuning .settings-grid {
  padding: 0.9rem;
}

.fine-tuning .hint {
  padding: 0 0.9rem 0.9rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Unsichtbarer Rahmen, aus dem heraus gedruckt wird (display: none würde das Drucken verhindern). */
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* Fußzeile der Einstellungen: Speicherstatus links, Knöpfe rechts. */
.settings-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.45rem;
  border: 1px solid var(--night);
  background: var(--surface);
  color: var(--night);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--surface-soft);
}

.btn.primary {
  background: var(--night);
  color: var(--moon);
}

.btn.primary:hover:not(:disabled) {
  background: #1a2b4f;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.link {
  border: none;
  background: none;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.3rem 0.4rem;
  text-decoration: underline;
}

.btn.link:hover {
  color: var(--night);
  background: none;
}

/* ---------- Meldungen ---------- */

.message {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.message.error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-text);
}

/* Kurze Zwischenmeldung (z. B. „Druck wird vorbereitet“), ruhig statt gelb. */
.message.info {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text-muted);
}

/* ---------- Ergebnisse ---------- */

.results-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.results-bar .count {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.result-name {
  font-size: 1.05rem;
  word-break: break-word;
}

.result-meta {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.result-status {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.has-error .result-status {
  color: var(--error-text);
}

.result-warnings {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.9rem 0.6rem 1.9rem;
  border-radius: 0.5rem;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.9rem;
}

.result-previews {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 40rem) {
  .result-previews {
    grid-template-columns: 1fr;
  }
}

.result-previews figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

/* Beide Vorschauen nutzen denselben Maßstab (5 px je mm); app.js setzt die
   CSS-Breite. max-width sorgt dafür, dass große Etiketten in die Spalte passen. */
.result-previews canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: var(--surface);
}

.result-previews figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.result-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  font-size: 0.9rem;
}

/* ---------- Hinweise ---------- */

.hints ul {
  margin: 0;
  padding-left: 1.2rem;
}

.hints li + li {
  margin-top: 0.4rem;
}
