/* ============================================================
   QR Code Portal - Stylesheet
   Modernes Blau/Weiß-Design mit Dark-Mode-Unterstützung
   ============================================================ */

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-accent: #0ea5e9;

  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;

  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.14);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --topbar-height: 68px;
  --sidebar-width: 240px;
}

[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-dark: #60a5fa;
  --color-primary-light: #1e3a5f;
  --color-accent: #38bdf8;

  --color-bg: #0b1220;
  --color-surface: #121b2e;
  --color-surface-alt: #182339;
  --color-border: #253355;
  --color-text: #e6ebf5;
  --color-text-muted: #97a4c0;
  --color-text-faint: #6d7ba0;

  --color-success: #22c55e;
  --color-success-bg: #113321;
  --color-danger: #f87171;
  --color-danger-bg: #3a1414;
  --color-warning: #fbbf24;
  --color-warning-bg: #3a2c0c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

body { font-size: 15px; line-height: 1.5; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; color: var(--color-text-muted); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--color-primary-light); }

/* ---------- Layout: App-Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transition: transform .25s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 22px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--color-text);
}
.sidebar-brand .logo-dot {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem; flex-shrink: 0;
}

.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-text-faint); padding: 0 10px; margin-bottom: 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--color-text-muted); font-weight: 600; font-size: .92rem;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--color-surface-alt); text-decoration: none; color: var(--color-text); }
.nav-link.active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.nav-link .icon { width: 20px; text-align: center; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--color-border); }

.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Element+Klasse (statt nur .menu-toggle) ist bewusst etwas spezifischer
   als die allgemeine .btn-Regel weiter unten (display: inline-flex) -
   sonst gewinnt .btn im Zweifel rein durch Reihenfolge im Stylesheet und
   der Menü-Button bliebe (als inline-flex) auch auf dem Desktop sichtbar,
   obwohl er nur für schmale/mobile Ansichten gedacht ist. */
button.menu-toggle { display: none; }

.content { padding: 28px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--color-border); background: var(--color-surface-alt);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text-muted); font-size: 1rem;
}
.theme-toggle:hover { color: var(--color-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none;
  transition: all .15s ease; line-height: 1.2;
  /* WICHTIG: <button>/<input>/<select>/<textarea> erben font-family NICHT
     automatisch vom Elternelement (langjährige Browser-Eigenheit bei
     Formularelementen) - ohne diese Zeile rendert ein <button class="btn">
     (z.B. "Löschen") in der System-Schrift statt in unserer --font-sans,
     wodurch er trotz identischer Klassen optisch größer/anders wirkt als
     ein <a class="btn"> (z.B. "Bearbeiten") daneben.
  */
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface-alt); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-danger:hover { filter: brightness(0.95); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 22px; }
.card-header {
  padding: 18px 22px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 { margin: 0; }

.grid { display: grid; gap: 18px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* ---------- Stat tiles ---------- */
.stat-tile {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-tile .stat-label { font-size: .8rem; color: var(--color-text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile .stat-sub { font-size: .78rem; color: var(--color-text-faint); margin-top: 4px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--color-text); }
.form-group { margin-bottom: 18px; }
.form-hint { font-size: .78rem; color: var(--color-text-faint); margin-top: 5px; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="number"], input[type="datetime-local"], input[type="search"],
textarea, select {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: .92rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
input[type="color"] {
  width: 46px; height: 38px; padding: 2px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface); cursor: pointer;
}
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type="text"] { max-width: 120px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }

fieldset { border: none; padding: 0; margin: 0 0 22px; }
legend { font-weight: 700; padding: 0 0 10px; font-size: .95rem; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--color-text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ---------- Alerts / Flash ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .88rem; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.alert-info { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ---------- Project cards ---------- */
.project-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm);
  display: flex; gap: 14px; transition: box-shadow .15s ease, transform .15s ease;
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.project-card .qr-thumb {
  width: 68px; height: 68px; border-radius: var(--radius-sm); background: var(--color-surface-alt);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
  border: 1px solid var(--color-border);
}
.project-card .qr-thumb img { width: 100%; height: 100%; object-fit: contain; }
.project-card .project-info { flex: 1; min-width: 0; }
.project-card .project-name { font-weight: 700; font-size: 1rem; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .project-meta { font-size: .78rem; color: var(--color-text-faint); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--color-primary-light), transparent 45%),
              radial-gradient(circle at 80% 80%, #e0f2fe, transparent 45%),
              var(--color-bg);
  padding: 20px;
}
[data-theme="dark"] .auth-wrap {
  background: radial-gradient(circle at 20% 20%, #16264a, transparent 45%),
              radial-gradient(circle at 80% 80%, #0b2438, transparent 45%),
              var(--color-bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--color-surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 38px 34px;
  border: 1px solid var(--color-border);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.auth-logo .logo-dot { width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.5rem; box-shadow: var(--shadow-md); }
.auth-logo h1 { font-size: 1.25rem; margin: 0; }
.auth-logo p { margin: 0; font-size: .85rem; }

/* ---------- Landing page (öffentliche QR-Zielseite) ---------- */
.landing-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--color-bg); padding: 24px;
}
.landing-card {
  width: 100%; max-width: 440px; background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); padding: 36px 30px; text-align: center;
}
.landing-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--color-primary-light); color: var(--color-primary-dark); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; margin: 0 auto 18px; }
.landing-card h1 { font-size: 1.3rem; }
.landing-detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--color-border); font-size: .88rem; text-align: left; }
.landing-detail-row:last-child { border-bottom: none; }
.landing-detail-row .label { color: var(--color-text-muted); }
.landing-detail-row .value { font-weight: 600; text-align: right; }
.landing-footer { margin-top: 22px; font-size: .75rem; color: var(--color-text-faint); }

/* ---------- Style-Editor / Live-Vorschau ---------- */
.style-editor { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .style-editor { grid-template-columns: 1fr; } }
.qr-preview-panel {
  position: sticky; top: 88px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 22px; text-align: center; box-shadow: var(--shadow-sm);
}
/* Karo-Muster statt festem Weiß als Bild-Hintergrund: zeigt "Transparenter
   Hintergrund" in der Live-Vorschau sofort sichtbar an (wie in gängigen
   Bild-/Design-Programmen üblich). Bei nicht-transparenten QR-Codes ist das
   Muster unsichtbar, da das PNG die Fläche komplett selbst füllt. */
.qr-preview-panel img {
  width: 100%; max-width: 260px; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 8px; }
.type-option { border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; cursor: pointer; background: var(--color-surface); transition: all .15s ease; }
.type-option:hover { border-color: var(--color-primary); }
.type-option input { display: none; }
.type-option .type-icon { font-size: 1.5rem; display: block; margin-bottom: 6px; }
.type-option .type-label { font-size: .78rem; font-weight: 600; color: var(--color-text-muted); }
.type-option.selected { border-color: var(--color-primary); background: var(--color-primary-light); box-shadow: 0 0 0 1px var(--color-primary); }
.type-option.selected .type-label { color: var(--color-primary-dark); }

.style-choice-group { display: flex; gap: 10px; flex-wrap: wrap; }
.style-choice { border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--color-text-muted); background: var(--color-surface); }
.style-choice input { display: none; }
.style-choice.selected { border-color: var(--color-primary); color: var(--color-primary-dark); background: var(--color-primary-light); }

/* ---------- Misc ---------- */
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; } .mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-faint); }
.empty-state .icon { font-size: 2.6rem; margin-bottom: 14px; }
.divider { height: 1px; background: var(--color-border); margin: 22px 0; border: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary-light); color: var(--color-primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; font-family: monospace; font-size: .82rem; }
code, .mono { font-family: 'SF Mono', 'Fira Code', Consolas, monospace; }

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  button.menu-toggle { display: flex; }
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
  /* Der abdunkelnde Klick-Hintergrund hinter dem aufgeklappten Menü darf
     NUR in dieser schmalen Ansicht aktiv werden - siehe Hinweis oben bei
     button.menu-toggle. Bliebe die "open"-Regel außerhalb dieser Media
     Query, könnte auf dem Desktop ein unsichtbares, aber klickfangendes
     Overlay über der ganzen Seite landen (z.B. falls der Menü-Zustand
     durch einen künftigen Bug doch mal auf "offen" gesetzt wird) und
     Klicks auf der eigentlichen Seite ins Leere laufen lassen. */
  .sidebar-backdrop.open { display: block; }
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 39; }
