/* Lager-App: eigenstaendiges CSS, kein Build-Schritt, kein Framework noetig. */

:root {
  --background: #f8fafc;
  --card: #ffffff;
  --foreground: #0f172a;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --primary: #0f172a;
  --primary-foreground: #f8fafc;
  --ring: #94a3b8;
  --radius: 10px;

  --slate-bg: #f1f5f9; --slate-fg: #334155; --slate-bd: #cbd5e1;
  --amber-bg: #fef3c7; --amber-fg: #92400e; --amber-bd: #fcd34d;
  --blue-bg: #dbeafe; --blue-fg: #1e40af; --blue-bd: #93c5fd;
  --indigo-bg: #e0e7ff; --indigo-fg: #3730a3; --indigo-bd: #a5b4fc;
  --emerald-bg: #d1fae5; --emerald-fg: #065f46; --emerald-bd: #6ee7b7;
  --gray-bg: #e5e7eb; --gray-fg: #374151; --gray-bd: #9ca3af;
  --red-bg: #fee2e2; --red-fg: #b91c1c; --red-bd: #fca5a5;
  --sky-bg: #e0f2fe; --sky-fg: #075985; --sky-bd: #7dd3fc;

  --red-50: #fef2f2; --red-700: #b91c1c;
  --amber-50: #fffbeb; --amber-700: #b45309;
  --emerald-50: #ecfdf5; --emerald-700: #047857;
}

[data-theme="dark"] {
  --background: #0a0a0c; --card: #171719; --foreground: #f1f5f9;
  --muted-foreground: #94a3b8; --border: #2b2b30; --primary: #e2e8f0;
  --primary-foreground: #0f172a; --ring: #52525b;

  --slate-bg: #27272a; --slate-fg: #cbd5e1; --slate-bd: #52525b;
  --amber-bg: #451a03; --amber-fg: #fcd34d; --amber-bd: #92400e;
  --blue-bg: #172554; --blue-fg: #93c5fd; --blue-bd: #1e40af;
  --indigo-bg: #1e1b4b; --indigo-fg: #a5b4fc; --indigo-bd: #3730a3;
  --emerald-bg: #052e1f; --emerald-fg: #6ee7b7; --emerald-bd: #065f46;
  --gray-bg: #27272a; --gray-fg: #d4d4d8; --gray-bd: #52525b;
  --red-bg: #450a0a; --red-fg: #fca5a5; --red-bd: #b91c1c;
  --sky-bg: #082f49; --sky-fg: #7dd3fc; --sky-bd: #075985;

  --red-50: #2a0e0e; --red-700: #fca5a5;
  --amber-50: #2a1c05; --amber-700: #fcd34d;
  --emerald-50: #04241a; --emerald-700: #6ee7b7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #0a0a0c; --card: #171719; --foreground: #f1f5f9;
    --muted-foreground: #94a3b8; --border: #2b2b30; --primary: #e2e8f0;
    --primary-foreground: #0f172a; --ring: #52525b;
    --slate-bg: #27272a; --slate-fg: #cbd5e1; --slate-bd: #52525b;
    --amber-bg: #451a03; --amber-fg: #fcd34d; --amber-bd: #92400e;
    --blue-bg: #172554; --blue-fg: #93c5fd; --blue-bd: #1e40af;
    --indigo-bg: #1e1b4b; --indigo-fg: #a5b4fc; --indigo-bd: #3730a3;
    --emerald-bg: #052e1f; --emerald-fg: #6ee7b7; --emerald-bd: #065f46;
    --gray-bg: #27272a; --gray-fg: #d4d4d8; --gray-bd: #52525b;
    --red-bg: #450a0a; --red-fg: #fca5a5; --red-bd: #b91c1c;
    --sky-bg: #082f49; --sky-fg: #7dd3fc; --sky-bd: #075985;
    --red-50: #2a0e0e; --red-700: #fca5a5;
    --amber-50: #2a1c05; --amber-700: #fcd34d;
    --emerald-50: #04241a; --emerald-700: #6ee7b7;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 24px; font-weight: 700; margin: 0; }
h2 { font-size: 14px; font-weight: 600; color: var(--muted-foreground); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .02em; }
p { margin: 0; }
.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 16px; font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--foreground);
}
.sidebar-link:hover { background: var(--slate-bg); }
.sidebar-link.active { background: var(--primary); color: var(--primary-foreground); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--slate-bg); color: var(--slate-fg);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.sidebar-footer { padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted-foreground); text-align: center; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--card); }
.main-content { flex: 1; padding: 24px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .topbar { padding: 10px 14px; }
}

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-header { padding: 16px 16px 0; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-body-flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; border: 1px solid transparent; font-size: 13px; font-weight: 500;
  padding: 8px 14px; cursor: pointer; background: var(--primary); color: var(--primary-foreground);
  min-height: 36px;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-destructive { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bd); }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 12px; }
.btn-lg { padding: 12px 18px; min-height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn { padding: 6px; min-height: auto; }

/* Forms */
label, .label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; background: var(--card); color: var(--foreground); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.field { margin-bottom: 12px; }
textarea { resize: vertical; min-height: 70px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid; }
.badge-slate { background: var(--slate-bg); color: var(--slate-fg); border-color: var(--slate-bd); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); border-color: var(--amber-bd); }
.badge-blue { background: var(--blue-bg); color: var(--blue-fg); border-color: var(--blue-bd); }
.badge-indigo { background: var(--indigo-bg); color: var(--indigo-fg); border-color: var(--indigo-bd); }
.badge-emerald { background: var(--emerald-bg); color: var(--emerald-fg); border-color: var(--emerald-bd); }
.badge-gray { background: var(--gray-bg); color: var(--gray-fg); border-color: var(--gray-bd); }
.badge-red { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bd); }
.badge-sky { background: var(--sky-bg); color: var(--sky-fg); border-color: var(--sky-bd); }

/* Toggle-Switch (z.B. Module an-/ausschalten) */
.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch-track::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: var(--card); border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-track { background: var(--emerald-fg); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:disabled + .switch-track { opacity: .5; cursor: not-allowed; }

/* Direktsprung von einer Kachel (z.B. "Zum Artikel" im Dashboard) auf eine Tabellenzeile */
tr:target { outline: 2px solid var(--amber-fg, #b45309); outline-offset: -2px; background: var(--amber-50) !important; }

/* Alert boxes */
.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; border: 1px solid; }
.alert-red { background: var(--red-50); color: var(--red-700); border-color: var(--red-bd); }
.alert-amber { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-bd); }
.alert-emerald { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-bd); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 16px; color: var(--muted-foreground); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.table-empty { text-align: center; padding: 40px; color: var(--muted-foreground); }

/* Modal / Dialog */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; padding: 20px; border: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.modal-close { position: absolute; }

/* Toasts */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #14532d; color: #f0fdf4; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.toast.error { background: #7f1d1d; color: #fef2f2; }

/* Utility */
.scroll-panel { max-height: 380px; overflow-y: auto; }
.border-l-4 { border-left-width: 4px; border-left-style: solid; }
.center-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px; color: var(--muted-foreground); text-align: center; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.stat-value { font-size: 28px; font-weight: 700; }
