/* Printer Lab Admin - Farben aus dem WPF-Client uebernommen */
:root {
  --bg: #1E1E1E;
  --bg-2: #252525;
  --bg-3: #2D2D2D;
  --line: #383838;
  --primary: #00D9FF;
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #FF6B6B;
  --purple: #9C27B0;
  --text: #FFFFFF;
  --text-dim: #B0B0B0;
  --text-faint: #767676;

  --st-order_created: #ffaa00;
  --st-production: #0066ff;
  --st-ready: #00cc44;
  --st-completed: #00cc44;
  --st-cancelled: #ff3333;
  --st-pending: #ffaa00;
  --st-approved: #00cc44;
  --st-rejected: #ff3333;

  --radius: 12px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- Start ---------- */
.boot {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  background: var(--bg); z-index: 50;
}
.boot-logo {
  width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #06232b; font-weight: 800; font-size: 24px; letter-spacing: 1px;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--bg-3); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---------- Anmeldung ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  overflow-y: auto;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px;
}
.login-card h2 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }

/* Code-Felder */
.code-row { display: flex; gap: 8px; justify-content: space-between; margin: 8px 0 4px; }
.code-row input {
  width: 100%; min-width: 0; aspect-ratio: 3 / 4;
  text-align: center; font-size: 22px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase; padding: 0;
}

/* ---------- Formularelemente ---------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
  font-family: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
textarea { resize: vertical; min-height: 84px; }

button {
  font-family: inherit; font-size: 15px; font-weight: 600;
  border: none; border-radius: 10px; padding: 12px 16px;
  background: var(--bg-3); color: var(--text); cursor: pointer;
  min-height: 44px; /* Touch-Ziel */
}
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: #06232b; }
.btn-danger  { background: var(--danger);  color: #2b0606; }
.btn-success { background: var(--success); color: #062b10; }
.btn-ghost   { background: transparent; border: 1px solid var(--line); color: var(--text-dim); }
/* Zerstörendes in der zweiten Reihe: erkennbar, aber nicht der auffälligste
   Knopf der Karte. Gefüllt rot bleibt der Bestätigen-Knopf im Dialog. */
.btn-danger-quiet {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(255,107,107,.32); flex-grow: 0;
}
.btn-block   { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn-row > button, .btn-row > a.btn { flex: 1 1 140px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; }

.form-error {
  margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-size: 14px;
  background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.35); color: var(--danger);
}
.form-note {
  margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-size: 14px;
  background: rgba(0,217,255,.10); border: 1px solid rgba(0,217,255,.3); color: var(--primary);
}

/* ---------- Grundgeruest ---------- */
.app { min-height: 100dvh; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 8px 0;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 17px; text-align: center; }
.icon-btn {
  background: transparent; color: var(--text-dim);
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 10px;
}
.icon-btn:active { background: var(--bg-3); }
#refresh-btn.busy svg { animation: spin .8s linear infinite; }

.sidebar {
  position: fixed; z-index: 30;
  top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
  padding: calc(18px + var(--safe-t)) 14px calc(18px + var(--safe-b));
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; margin-bottom: 18px; padding: 0 8px;
}
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #06232b; font-weight: 800; font-size: 14px;
}
.sidebar a {
  color: var(--text-dim); padding: 13px 14px; border-radius: 10px; font-weight: 500;
}
.sidebar a[aria-current="page"] { background: var(--bg-3); color: var(--primary); }
.sidebar-logout {
  margin-top: auto; background: transparent; color: var(--danger);
  border: 1px solid rgba(255,107,107,.3); text-align: center;
}

.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.55); }

.view {
  padding: calc(var(--topbar-h) + var(--safe-t) + 16px) 16px calc(28px + var(--safe-b));
  max-width: 1100px; margin: 0 auto;
}
.view:focus { outline: none; }

/* ---------- Karten und Listen ---------- */
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-head h2 { font-size: 16px; }

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.stat.accent .value { color: var(--primary); }
.stat.good .value { color: var(--success); }
.stat.warn .value { color: var(--warning); }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; color: inherit;
  min-height: 64px;
}
.row:active { background: var(--bg-3); }
.row-thumb {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 9px;
  background: var(--bg-3); object-fit: cover;
  display: grid; place-items: center; color: var(--text-faint); font-size: 11px;
}
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.row-end { text-align: right; flex: 0 0 auto; }
.row-price { font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  background: var(--bg-3); color: var(--text-dim); white-space: nowrap;
}
.badge[data-status] { color: #06232b; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; }
.filters button {
  flex: 0 0 auto; padding: 9px 14px; min-height: 40px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text-dim);
  font-size: 14px; border-radius: 999px;
}
.filters button[aria-pressed="true"] { background: var(--primary); color: #06232b; border-color: var(--primary); }

.kv { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-word; }

.empty, .loading { text-align: center; padding: 44px 16px; color: var(--text-dim); }
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .6; }

.detail-thumb {
  width: 100%; max-height: 260px; object-fit: contain;
  background: var(--bg-3); border-radius: var(--radius); margin-bottom: 14px;
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 14px; margin-bottom: 14px; min-height: 44px;
}

/* ---------- Material ---------- */
.color-chip {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 26px;
  border: 1px solid rgba(255,255,255,.22);
}
.stock-bar { height: 5px; border-radius: 3px; background: var(--bg-3); margin-top: 7px; overflow: hidden; }
.stock-bar > i { display: block; height: 100%; background: var(--success); }
.stock-bar.low > i { background: var(--warning); }
.stock-bar.out > i { background: var(--danger); }

/* ---------- Dialoge ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal {
  width: 100%; max-width: 460px; max-height: 88dvh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
}
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .modal-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 8px; }

/* ---------- Hinweise ---------- */
.toasts {
  position: fixed; z-index: 70;
  left: 12px; right: 12px; bottom: calc(14px + var(--safe-b));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  max-width: 460px; width: 100%;
  padding: 13px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: var(--bg-3); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.toast.ok   { border-color: rgba(76,175,80,.5);  color: var(--success); }
.toast.err  { border-color: rgba(255,107,107,.5); color: var(--danger); }

.offline-bar {
  position: fixed; top: calc(var(--topbar-h) + var(--safe-t)); left: 0; right: 0; z-index: 19;
  background: var(--warning); color: #2b1a00;
  text-align: center; font-size: 13px; font-weight: 600; padding: 6px;
}

/* ---------- Ab Tablet ---------- */
@media (min-width: 900px) {
  .sidebar { transform: translateX(0); }
  .scrim { display: none !important; }
  #nav-toggle { display: none; }
  .topbar { left: var(--sidebar-w); }
  .topbar h1 { text-align: left; padding-left: 8px; }
  .view { padding-left: calc(var(--sidebar-w) + 24px); padding-right: 24px; max-width: 1340px; }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; padding-bottom: 20px; }
  .offline-bar { left: var(--sidebar-w); }
}
