/*
 * Gemeinsames Design für Büro und Montage-App.
 * Farben und Abstände als Variablen, damit das Erscheinungsbild an einer Stelle
 * angepasst werden kann (z. B. Firmenfarbe in --brand).
 */
:root {
  --brand: #fbb900;          /* Gelb aus dem Kundenlogo */
  --brand-strong: #b45309;
  --accent: #032950;         /* Navy aus dem Kundenlogo, Kopfzeile */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --success: #15803d;
  --success-bg: #dcfce7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--info); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
.muted { color: var(--text-muted); }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }

/* --- Layout ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow);
}
.topbar a, .topbar button.link { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; min-width: 0; flex-shrink: 0; }
/* Weißes Feld, damit auch dunkle Kundenlogos auf der Kopfzeile lesbar bleiben */
.brand-logo { height: 34px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-section { font-size: 0.75rem; font-weight: 400; opacity: 0.8; }
/* Unter 1000px kommt die Navigation in eine eigene Zeile, damit der Firmenname Platz hat */
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar .brand { flex: 1 1 0; }
  .topbar .spacer { display: none; }
  .topbar nav { order: 1; width: 100%; }
}
@media (max-width: 480px) {
  .topbar .brand-name { white-space: normal; font-size: 0.85rem; }
  .topbar .brand-section { display: none; }
  .hide-narrow { display: none; }
}
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255, 255, 255, 0.15); }
.spacer { flex: 1; }
.user-info { font-size: 0.85rem; opacity: 0.85; white-space: nowrap; }
@media (max-width: 640px), (min-width: 1001px) and (max-width: 1240px) { .user-info { display: none; } }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.container-narrow { max-width: 720px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.stack > * + * { margin-top: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-header h2 { margin: 0; }

/* --- Formulare ------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.field small { color: var(--text-muted); }
input[type='text'], input[type='password'], input[type='search'], input[type='tel'],
input[type='datetime-local'], select, textarea {
  font: inherit; color: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.checkbox { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checkbox input { width: 18px; height: 18px; }

/* --- Buttons --------------------------------------------------------- */
.btn {
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; min-height: 44px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #1f1300; }
.btn-primary:hover { background: #fbbf24; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-small { padding: 4px 10px; min-height: 32px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-light { background: rgba(255, 255, 255, 0.15); border-color: transparent; color: #fff; }
.btn-light:hover { background: rgba(255, 255, 255, 0.25); }

/* --- Tabellen & Listen ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }

/* --- Plaketten ------------------------------------------------------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.notice { padding: 12px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info); }
.notice-warning { background: var(--warning-bg); color: var(--warning); }
.notice-success { background: var(--success-bg); color: var(--success); }
.notice-danger { background: var(--danger-bg); color: var(--danger); }

/* --- Fotos ----------------------------------------------------------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb {
  position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: var(--text-muted); text-align: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb .thumb-remove {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 16px; cursor: pointer;
}
.thumb .thumb-state { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.65rem; padding: 1px 2px; }

/* --- Meldungen ------------------------------------------------------- */
.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: 8px; background: #1f2937; color: #fff; box-shadow: var(--shadow); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* --- Anmeldung ------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.login-card { width: min(100%, 380px); }
.login-card .brand { color: var(--accent); flex-direction: column; text-align: center; margin-bottom: 16px; font-size: 1.3rem; }
.login-card .brand-wordmark { width: min(100%, 280px); height: auto; margin-bottom: 8px; }
.login-card .brand-text { align-items: center; }
.login-card .brand-name { white-space: normal; }
.login-card .brand-section { font-size: 0.9rem; color: var(--text-muted); opacity: 1; }

/* --- Hersteller-Hinweis ---------------------------------------------- */
.powered-by { text-align: center; font-size: 0.75rem; color: var(--text-muted); padding: 16px; }
.powered-by strong { font-weight: 600; }

/* --- Dialog -------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 150; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); padding: 20px; width: min(100%, 480px); }
.modal-danger { border-top: 4px solid var(--danger); }
.modal-danger h2 { color: var(--danger); }
.modal-body { margin-bottom: 16px; }
.modal-body p:last-child { margin-bottom: 0; }
.btn-danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }

/* --- Bild-Vollansicht ------------------------------------------------ */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); display: flex; align-items: center; justify-content: center; z-index: 200; }
.lightbox img { max-width: 96vw; max-height: 92vh; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f172a; --surface: #1e293b; --surface-2: #273449; --text: #e5e7eb; --text-muted: #94a3b8;
    --border: #334155; --accent: #0b1a2e;
    --success-bg: #14532d; --success: #86efac; --info-bg: #1e3a8a; --info: #bfdbfe;
    --warning-bg: #78350f; --warning: #fde68a; --danger-bg: #7f1d1d; --danger: #fecaca;
    color-scheme: dark;
  }
  :root:not([data-theme='light']) .btn-success { color: #052e16; }
  :root:not([data-theme='light']) .login-card .brand { color: var(--text); }
}
