/* Namensschild-Generator — CAM/Slicer Werkzeug-Oberfläche */

:root {
  color-scheme: dark;
  /* Oberflächen (dunkles Werkzeug-UI) */
  --bg-app: #141619;
  --bg-panel: #1b1e23;
  --bg-panel-alt: #20242b;
  --bg-input: #101215;
  --bg-stage: #0d0f12;

  /* Rahmen & Trennlinien */
  --border: #2c313a;
  --border-strong: #434b59;

  /* Text (WCAG AA+ auf --bg-panel / --bg-app) */
  --text: #e6e9ef;
  --text-muted: #9aa3b2;
  --text-dim: #7b8494;

  /* Funktionsfarben */
  --accent: #1c8550;
  --accent-hover: #229c5e;
  --accent-text: #ffffff;
  --focus: #58a6ff;

  --ok: #56c288;
  --warn: #f0a830;
  --warn-bg: #292112;
  --warn-border: #8c6218;
  --error: #ff7373;
  --error-bg: #2a1518;
  --error-border: #8f3038;

  /* Zweifarbiges Schild (Draufsicht: Platte hell, Schrift dunkel — später einstellbar) */
  --sign-plate: #f2f2ee;
  --sign-text: #181a1d;

  /* Typografie & Geometrie */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --radius: 2px;
  --topbar-h: 48px;
  --sidebar-w: 344px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.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;
}

.is-hidden {
  display: none !important;
}

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

/* App Shell */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* Fixierte Aktionsleiste oben */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}

.brand-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.summary-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.summary-badge {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}

.summary-badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.topbar-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Arbeitsbereich: schmale Sidebar links, große Vorschau rechts */
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 16px;
}

.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.section-heading {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-heading-label {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

.section-header-row .section-heading {
  margin-bottom: 0;
}

.section-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Formularelemente */
label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.label-note {
  font-size: 11px;
  color: var(--text-dim);
}

input[type="text"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 5px 8px;
  transition: border-color 0.1s ease;
}

input[type="text"]:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  outline: none;
}

input[type="text"]:disabled,
select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-bg);
}

.names-textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  min-height: 116px;
  max-height: 360px;
}

/* Eingabe mit Einheit */
.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.field {
  min-width: 0;
}

.field-full {
  margin-bottom: 8px;
}

.input-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-unit input {
  padding-right: 32px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.input-unit .unit {
  position: absolute;
  right: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  pointer-events: none;
}

.field-error {
  margin-top: 3px;
  font-size: 11px;
  color: var(--error);
  line-height: 1.3;
}

.field-error:empty {
  display: none;
}

/* Einpassungs-Radio-Gruppe */
.fit-mode-fieldset {
  margin: 0 0 8px 0;
  padding: 0;
  border: 0;
}

.fit-mode-fieldset legend {
  padding: 0;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.radio-option:has(input:checked) {
  border-color: var(--focus);
  background: var(--bg-panel-alt);
}

.radio-option input {
  margin: 0;
  accent-color: var(--focus);
}

/* Presets & CSV */
.preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.preset-save-row {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 6px;
}

.csv-box {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.csv-row {
  margin-bottom: 6px;
}

.csv-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.csv-input {
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
}

.csv-input::file-selector-button {
  margin-right: 8px;
  padding: 3px 8px;
  background: var(--bg-panel-alt);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 11px;
  cursor: pointer;
}

.csv-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  margin: 0;
  accent-color: var(--focus);
}

.inline-status {
  margin: 6px 0 0 0;
  font-size: 11px;
  line-height: 1.35;
}

.inline-status-ok {
  color: var(--ok);
}

.inline-status-error {
  color: var(--error);
}

.sidebar-footer-action {
  padding: 10px 12px 0 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

.btn:disabled {
  opacity: 1;
  background: #20242b;
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  padding: 6px 12px;
}

.btn-primary:disabled {
  background: #22262d;
  color: var(--text-muted);
  border-color: #343a46;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-panel-alt);
  color: var(--text);
  border-color: var(--border-strong);
  padding: 6px 11px;
}

.btn-secondary:disabled {
  background: #1a1d22;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #2b303a;
}

.btn-subtle {
  background: var(--bg-panel-alt);
  color: var(--text);
  border-color: var(--border);
}

.btn-subtle:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: #282d36;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-danger-ghost:hover:not(:disabled) {
  color: var(--error);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.btn-full {
  width: 100%;
}

/* Rechte Hauptfläche: Vorschau */
.main-area {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-app);
}

.preview-workspace {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.toolbar-metric {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.toolbar-metric-warn {
  color: var(--warn);
}

.toolbar-metric-ok {
  color: var(--ok);
}

.toolbar-dim {
  font-size: 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.toolbar-sep {
  color: var(--border-strong);
}

.busy-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.busy-label.htmx-request {
  opacity: 1;
}

/* Hinweise & Fehler */
.notice-block {
  margin: 12px 16px 0 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
}

.notice-block-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-color: var(--warn);
}

.notice-block-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  border-left-color: var(--error);
}

.notice-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--text);
}

.notice-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.notice-list li {
  margin: 2px 0;
}

.notice-item-warn {
  color: var(--warn);
}

.notice-item-error {
  color: var(--error);
  font-weight: 600;
}

/* Großes Vorschau-Raster */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 10px;
  padding: 14px 16px 24px 16px;
}

.preview-grid.only-problems .sign-cell[data-overflow="false"] {
  display: none;
}

.sign-cell {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

.sign-cell.is-overflow {
  border-color: var(--warn);
  box-shadow: inset 3px 0 0 var(--warn);
}

.sign-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  font-variant-numeric: tabular-nums;
}

.sign-cell.is-overflow .sign-meta {
  background: var(--warn-bg);
  border-bottom-color: var(--warn-border);
}

.sign-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sign-index {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  margin-right: 6px;
}

.sign-status {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sign-status-ok {
  color: var(--text-muted);
}

.sign-status-warn {
  color: var(--warn);
  font-weight: 700;
}

.sign-stage {
  background: var(--bg-stage);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sign-svg {
  width: 100%;
}

.sign-svg svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}

/* Zweifarbige Produktvorschau über CSS-Variablen (Platte hell, Schrift dunkel) */
.sign-svg svg path:first-of-type {
  fill: var(--sign-plate);
}

.sign-svg svg path:nth-of-type(2) {
  fill: var(--sign-text);
}

/* Leerer Zustand / Filter-Hinweis */
.empty-state {
  margin: 28px 24px;
  max-width: 560px;
  padding: 16px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.empty-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.filter-empty-note {
  margin: 16px;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
}

/* Schmalere Bildschirme (unter 900px) — darf nicht zerbrechen */
@media (max-width: 900px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .main-area {
    overflow: visible;
  }
}
