/* Bildmotivgenerator – Grundstyles
   Farben angelehnt an das bisherige Tool (Knips-O-Mat-Blau, Orange als Akzent) */

:root {
  --blue: #2196f3;
  --blue-dark: #1976d2;
  --orange: #ffa53a;
  --red: #f4511e;
  --green: #2e7d32;
  --yellow: #f9a825;
  --text: #212121;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --bg: #eeeeee;
  --surface: #ffffff;
  --radius: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .08);
  --sidebar: 280px;
  --topbar: 64px;
  font-size: 16px;
}

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

html, body { margin: 0; }

body {
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue-dark); }
a:hover { color: var(--blue); }
code { font-family: "JetBrains Mono", Consolas, monospace; font-size: .875em; background: #f4f4f4; padding: .1em .35em; border-radius: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 500; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-top: 1.75rem; }
.muted { color: var(--muted); }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); padding: .5rem 1rem;
}
.skip-link:focus { left: 1rem; top: .5rem; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  height: var(--topbar);
  padding: 0 1.5rem;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
}
.brand { display: flex; align-items: center; width: calc(var(--sidebar) - 3rem); flex-shrink: 0; }
.brand img { display: block; height: 31px; width: auto; }
.app-title { font-size: 1.2rem; font-weight: 500; letter-spacing: .01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.topbar-actions form { margin: 0; }
.topbar-user { font-size: .9rem; opacity: .95; display: flex; align-items: center; gap: .5rem; }
.topbar-button {
  font: inherit; font-size: .85rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
  color: #fff; background: transparent; border: 1px solid rgba(255, 255, 255, .6);
  border-radius: var(--radius); padding: .35rem .8rem; cursor: pointer;
}
.topbar-button:hover { background: rgba(255, 255, 255, .15); }

.badge { display: inline-block; font-size: .7rem; line-height: 1; padding: .25em .5em; border-radius: 3px; font-weight: 500; }
.badge-admin { background: #e53935; color: #fff; }

/* ---------- Grundaufbau ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }

.sidebar {
  width: var(--sidebar); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.nav { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.nav-item {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .85rem 1.25rem;
  color: var(--text); text-decoration: none;
}
.nav-item:hover { background: #f5f5f5; color: var(--text); }
.nav-item.is-active { background: #e0e0e0; font-weight: 500; }
.nav-item.is-disabled { color: #9e9e9e; cursor: default; }
.nav-item.is-disabled:hover { background: transparent; }
.nav-icon { width: 22px; height: 22px; fill: #616161; flex-shrink: 0; }
.nav-item.is-disabled .nav-icon { fill: #bdbdbd; }
.nav-soon { margin-left: auto; font-size: .7rem; color: #9e9e9e; border: 1px solid #ddd; border-radius: 10px; padding: 0 .5rem; }
.sidebar-footer { padding: 1.25rem; font-size: .78rem; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 2rem; }

/* ---------- Seiten & Karten ---------- */
.page { max-width: 1100px; }
.page-header { margin-bottom: 1.5rem; }
.lead { margin: 0; color: var(--muted); font-size: 1.05rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-title { font-size: 1.1rem; margin-top: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem 2rem; margin: 0; }
.facts dt { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: .15rem 0 0; font-weight: 500; }

.notice {
  border-left: 4px solid var(--orange);
  background: #fff8ef;
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: 1rem 1.25rem; border-top: 3px solid var(--blue); }
.stat-value { display: block; font-size: 2rem; font-weight: 500; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .9rem; }

.roadmap { margin: 0; padding-left: 1.5rem; }
.roadmap li { padding: .35rem 0; color: var(--muted); }
.roadmap li strong { color: var(--text); font-weight: 500; }
.roadmap li.is-done { color: var(--green); }
.roadmap li.is-done strong { color: var(--green); }
.roadmap li.is-done::marker { content: "✓  "; }

/* ---------- Meldungen ---------- */
.alert { padding: .85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0; padding-left: 1.25rem; }
.alert-success { background: #e8f5e9; border-color: #c8e6c9; color: #1b5e20; }
.alert-info    { background: #e3f2fd; border-color: #bbdefb; color: #0d47a1; }
.alert-warn    { background: #fff8e1; border-color: #ffe082; color: #6d4c00; }
.alert-error   { background: #fdecea; border-color: #f5c6c0; color: #8e1c0e; }

/* ---------- Formulare ---------- */
.form { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .3rem; }
.field-label { font-size: .875rem; color: #424242; }
.field-label small { color: var(--muted); }
.field input {
  font: inherit; color: var(--text);
  padding: .6rem .75rem;
  border: 1px solid #c4c4c4; border-radius: var(--radius);
  background: #fff;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 150, 243, .2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 500; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .7rem 1.25rem;
  border: 0; border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow);
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); margin-bottom: 1.5rem; overflow: hidden; }
.table caption { text-align: left; font-weight: 500; padding: 0 0 .5rem; font-size: 1rem; }
.table th, .table td { text-align: left; padding: .6rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .9rem; }
.table th { font-size: .78rem; color: var(--muted); font-weight: 500; background: #fafafa; }
.table tr:last-child td { border-bottom: 0; }
.check-table td:first-child { width: 28%; }
.check-table td:nth-child(3) { width: 110px; }

.status { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 10px; }
.status-ok    { background: #e8f5e9; color: var(--green); }
.status-warn  { background: #fff8e1; color: #8d6e00; }
.status-error { background: #fdecea; color: #b71c1c; }

/* ---------- Seiten ohne Navigation ---------- */
.is-plain { display: flex; flex-direction: column; }
.plain-main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 3rem 1.5rem; }
.plain-footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 1.5rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

.auth-card { max-width: 420px; margin: 0 auto; padding: 2rem; border-top: 4px solid var(--blue); }
.auth-help { font-size: .85rem; margin: 1.25rem 0 0; }

.error-card { max-width: 560px; margin: 0 auto; text-align: center; }
.error-code { font-size: 3.5rem; font-weight: 300; color: var(--blue); margin: 0; line-height: 1; }

.install .card.form { max-width: 520px; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .topbar { gap: .75rem; padding: 0 1rem; }
  .brand { width: auto; }
  .app-title { display: none; }
  .topbar-user { display: none; }
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; overflow-x: auto; border-bottom: 0; }
  .nav-item { gap: .5rem; padding: .75rem 1rem; white-space: nowrap; }
  .nav-soon { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 1.25rem 1rem; }
  .check-table td:nth-child(4), .check-table th:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Admin-Benutzerverwaltung ---------- */
.user-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.user-page-header .btn { flex-shrink: 0; }
.user-filters { display: flex; align-items: flex-end; gap: .75rem; padding: 1rem; }
.user-filters .field { margin: 0; }
.search-field { flex: 1; min-width: 220px; }
.status-field { min-width: 190px; }
.user-filters input, .user-filters select, .field select, .field textarea {
  width: 100%; font: inherit; color: var(--text); padding: .6rem .75rem;
  border: 1px solid #c4c4c4; border-radius: var(--radius); background: #fff;
}
.field textarea { resize: vertical; min-height: 5rem; }
.user-filters input:focus, .user-filters select:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33, 150, 243, .2);
}
.btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #d0d0d0; box-shadow: none; }
.btn-secondary:hover { background: #e9e9e9; color: #111; }
.btn-small { padding: .4rem .7rem; font-size: .78rem; }
.table-summary { margin: 0 0 .6rem; color: var(--muted); font-size: .9rem; }
.table-summary strong { color: var(--text); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.users-table { min-width: 850px; }
.users-table th { white-space: nowrap; }
.users-table td { vertical-align: middle; }
.user-subline, .table-subline { display: flex; align-items: center; gap: .45rem; margin-top: .2rem; font-size: .8rem; color: var(--muted); }
.table-subline { display: block; }
.access-pill { display: inline-block; padding: .2rem .6rem; border-radius: 99px; background: #e3f2fd; color: #145b8d; font-size: .78rem; white-space: nowrap; }
.access-pill.is-permanent { background: #e8f5e9; color: #25652a; }
.access-pill.is-expired { background: #fdecea; color: #a5271a; }
.user-expired { background: #fffafa; }
.text-danger { color: #b71c1c; }
.actions-cell { text-align: right !important; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.25rem 0; font-size: .9rem; }
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state h2 { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.user-form-page { max-width: 900px; }
.back-link { display: inline-block; margin-bottom: .6rem; font-size: .9rem; text-decoration: none; }
.user-meta { display: flex; gap: 1.5rem; font-size: .82rem; margin: -.7rem 0 1rem; }
.user-form { padding: 0; overflow: hidden; }
.form-section { border: 0; border-top: 1px solid var(--line); padding: 1.5rem; margin: 0; min-width: 0; }
.form-section legend { padding: 0 .5rem 0 0; font-weight: 600; font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.field-wide { grid-column: 1 / -1; }
.required { color: #c62828; }
.field-help { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.password-row { display: flex; gap: .5rem; }
.password-row input { flex: 1; min-width: 0; }
.password-row .btn { flex-shrink: 0; }
.check-field { display: flex; align-items: flex-start; gap: .65rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fafafa; }
.check-field input { margin-top: .25rem; width: 1rem; height: 1rem; accent-color: var(--blue); }
.check-field strong, .check-field small { display: block; }
.check-field small { margin-top: .15rem; color: var(--muted); font-size: .8rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.5rem; background: #fafafa; border-top: 1px solid var(--line); }
.is-hidden { display: none !important; }
.is-muted { opacity: .55; }
.danger-zone { margin: 1.5rem 0 2rem; padding: 1.25rem 1.5rem; border: 1px solid #efb7b1; border-left: 4px solid #d84335; background: #fffafa; border-radius: var(--radius); }
.danger-zone h2 { margin: 0 0 .4rem; color: #9d261b; }
.danger-zone p { color: #6f3b36; }
.delete-form { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.delete-form .field { flex: 1; min-width: 240px; }

@media (max-width: 700px) {
  .user-page-header { flex-direction: column; }
  .user-page-header .btn { width: 100%; }
  .user-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .user-filters > .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .user-meta { flex-direction: column; gap: .15rem; }
  .form-section { padding: 1.1rem; }
  .form-actions { padding: 1rem 1.1rem; }
  .delete-form { align-items: stretch; flex-direction: column; }
  .delete-form .btn { width: 100%; }
  .users-table { min-width: 0; box-shadow: none; }
  .users-table thead { display: none; }
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; width: 100%; }
  .users-table tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; padding: .35rem .85rem; }
  .users-table td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .5rem; border-bottom: 1px solid #eee; padding: .55rem 0; text-align: left !important; }
  .users-table td:last-child { border-bottom: 0; }
  .users-table td::before { content: attr(data-label); font-size: .76rem; color: var(--muted); }
  .users-table td:first-child { display: block; padding-top: .65rem; }
  .users-table td:first-child::before { display: none; }
  .users-table .actions-cell { display: block; }
  .users-table .actions-cell::before { display: none; }
}

.input-action-row { display: flex; align-items: center; gap: .5rem; }
.input-action-row input { flex: 1; min-width: 0; width: 100%; }
@media (max-width: 700px) {
  .input-action-row { align-items: stretch; flex-direction: column; }
  .input-action-row .btn { width: 100%; }
}

/* ---------- Produkt- und Basislayout-Verwaltung ---------- */
.page-header-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.page-header-actions .btn { flex-shrink: 0; }
.catalog-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.catalog-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.catalog-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 250px; }
.catalog-card h2 { margin: .6rem 0; }
.catalog-card p { color: var(--muted); flex: 1; }
.catalog-card-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--blue); background: #e3f2fd; font-size: 1.6rem; border-radius: 50%; }
.catalog-secondary-link { margin-top: .8rem; font-size: .88rem; text-decoration: none; }
.catalog-note { margin-top: 1rem; }
.catalog-table { min-width: 760px; }
.catalog-actions { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.catalog-actions form { margin: 0; }
.small-note { font-size: .82rem; }
.form-page-narrow { max-width: 760px; }
.catalog-form { padding: 1.5rem; }
.catalog-form .form-actions { margin: .25rem -1.5rem -1.5rem; }

.layout-editor-page { max-width: 1200px; }
.layout-form { display: grid; gap: 1.25rem; }
.layout-basics { padding: 0; }
.layout-basics .form-grid { padding: 1.4rem; }
.slot-editor-card { padding: 1.35rem; }
.section-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-heading-row h2 { margin: 0 0 .25rem; }
.section-heading-row p { margin: 0; }
.slot-editor-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr); gap: 1.25rem; align-items: start; }
.slot-canvas-wrap { min-width: 0; background: #f6f7f8; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); }
#slot-canvas { display: block; width: 100%; height: auto; background: #fff; border: 1px solid #cfd8dc; touch-action: none; cursor: grab; }
#slot-canvas:active { cursor: grabbing; }
.slot-canvas-legend { display: flex; align-items: center; gap: .5rem; margin: .6rem .15rem .1rem; color: var(--muted); font-size: .8rem; }
.legend-box { display: inline-block; width: 18px; height: 13px; border: 2px solid #2196f3; background: rgba(33, 150, 243, .16); }
.slot-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.slot-select-button { border: 1px solid #b8c8d2; background: #fff; color: #344955; border-radius: 3px; padding: .35rem .7rem; cursor: pointer; font: inherit; font-size: .82rem; }
.slot-select-button:hover, .slot-select-button.is-selected { border-color: var(--blue); background: #e3f2fd; color: #0b5c93; }
.slot-controls { display: grid; gap: .85rem; }
.slot-controls-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.slot-controls .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.slot-controls input { width: 100%; }
.slot-controls .notice { font-size: .9rem; }
.slot-fields { gap: .8rem; }
.assignment-section { padding: 0; }
.assignment-section legend { margin-bottom: .85rem; }
.product-assignment-card { padding: 1.35rem; }
.product-checklist { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .65rem; }
.product-checklist .check-field { min-width: 0; }
.product-checklist .check-field.is-muted { opacity: .7; }
.layout-form-actions { padding: .25rem 0 1rem; }

@media (max-width: 850px) {
  .slot-editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .page-header-actions { align-items: stretch; flex-direction: column; }
  .page-header-actions .btn { width: 100%; }
  .catalog-cards { grid-template-columns: 1fr; }
  .catalog-card { min-height: auto; }
  .section-heading-row { align-items: stretch; flex-direction: column; }
  .section-heading-row .btn { width: 100%; }
  .layout-basics .form-grid { padding: 1rem; }
  .slot-editor-card, .product-assignment-card { padding: 1rem; }
  .catalog-actions { justify-content: flex-start; flex-wrap: wrap; }
}
