/* ─── CSS-Variablen: Light-Mode (Standard) ────────────────────────────── */
:root {
  --bg:          #ffffff;
  --bg-2:        #f4f4f5;
  --bg-3:        #e4e4e7;
  --text:        #18181b;
  --text-2:      #52525b;
  --text-3:      #a1a1aa;
  --accent:      #2563eb;
  --accent-h:    #1d4ed8;
  --accent-fg:   #ffffff;
  --border:      #d4d4d8;
  --danger:      #dc2626;
  --danger-h:    #b91c1c;
  --success:     #16a34a;
  --warning:     #d97706;
  --info:        #0284c7;
  --tag-bg:      #dbeafe;
  --tag-text:    #1e40af;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius:      6px;
  --radius-lg:   10px;
  --font:        system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:   "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

/* Auto-Darkmode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #09090b;
    --bg-2:     #18181b;
    --bg-3:     #27272a;
    --text:     #fafafa;
    --text-2:   #a1a1aa;
    --text-3:   #52525b;
    --accent:   #3b82f6;
    --accent-h: #60a5fa;
    --border:   #3f3f46;
    --tag-bg:   #1e3a5f;
    --tag-text: #93c5fd;
    --shadow:      0 1px 3px rgba(0,0,0,.3);
    --shadow-md:   0 4px 6px rgba(0,0,0,.3);
  }
}

/* Manuelles Dark-Theme */
[data-theme="dark"] {
  --bg:       #09090b;
  --bg-2:     #18181b;
  --bg-3:     #27272a;
  --text:     #fafafa;
  --text-2:   #a1a1aa;
  --text-3:   #52525b;
  --accent:   #3b82f6;
  --accent-h: #60a5fa;
  --border:   #3f3f46;
  --tag-bg:   #1e3a5f;
  --tag-text: #93c5fd;
  --shadow:      0 1px 3px rgba(0,0,0,.3);
  --shadow-md:   0 4px 6px rgba(0,0,0,.3);
}
[data-theme="light"] {
  --bg:       #ffffff;
  --bg-2:     #f4f4f5;
  --bg-3:     #e4e4e7;
  --text:     #18181b;
  --text-2:   #52525b;
  --text-3:   #a1a1aa;
  --accent:   #2563eb;
  --accent-h: #1d4ed8;
  --border:   #d4d4d8;
  --tag-bg:   #dbeafe;
  --tag-text: #1e40af;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: .875em;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.site-logo:hover { text-decoration: none; color: var(--accent); }
.site-logo svg { color: var(--accent); flex-shrink: 0; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex: 1;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-2);
  padding: .375rem .625rem;
  border-radius: var(--radius);
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav-links a.active { background: var(--accent); color: var(--accent-fg); }

.nav-spacer { flex: 1; }

.nav-actions { display: flex; align-items: center; gap: .5rem; }

.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem .875rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
  min-height: 40px;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

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

.btn-secondary { background: var(--bg-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-3); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-h); border-color: var(--danger-h); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }

.btn-sm { padding: .3rem .6rem; font-size: .8125rem; min-height: 32px; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
  padding: .4rem;
  min-width: 36px;
  justify-content: center;
}

/* ─── Formulare ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: .375rem;
}
.form-group small {
  display: block;
  font-size: .8125rem;
  color: var(--text-3);
  margin-top: .25rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: .5rem .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .9375rem;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  min-height: 40px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

textarea { resize: vertical; min-height: 200px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23888' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input[type="checkbox"] { width: auto; min-height: auto; cursor: pointer; }

/* ─── Alerts / Flash ─────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9375rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #86efac; color: #14532d; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

[data-theme="dark"] .alert-error   { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .alert-success { background: #052e16; border-color: #166534; color: #86efac; }
[data-theme="dark"] .alert-info    { background: #0c1a3a; border-color: #1e3a8a; color: #93c5fd; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .alert-error   { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
  :root:not([data-theme="light"]) .alert-success { background: #052e16; border-color: #166534; color: #86efac; }
  :root:not([data-theme="light"]) .alert-info    { background: #0c1a3a; border-color: #1e3a8a; color: #93c5fd; }
}

/* ─── Karten & Listen ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.artifact-list { display: flex; flex-direction: column; gap: .5rem; }

.artifact-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .875rem 1rem;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: .5rem .75rem;
  align-items: start;
  transition: border-color .15s, box-shadow .15s;
}
.artifact-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.artifact-item input[type="checkbox"] { margin-top: .2rem; cursor: pointer; }

.artifact-info {}
.artifact-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.artifact-title:hover { color: var(--accent); text-decoration: underline; }

.artifact-meta {
  font-size: .8125rem;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  margin-top: .25rem;
}

.artifact-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* ─── Tags ───────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s;
}
.tag:hover { opacity: .8; text-decoration: none; }
.tag.active-tag { outline: 2px solid var(--accent); }

.tag-list { display: flex; flex-wrap: wrap; gap: .375rem; margin: .5rem 0; }

/* Tagcloud */
.tagcloud {
  padding: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}
.tagcloud-inner { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .625rem; }
.tagcloud-toggle { cursor: pointer; user-select: none; display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9375rem; background: none; border: none; color: var(--text); padding: 0; }
.tagcloud-toggle .chevron { transition: transform .2s; }
.tagcloud-toggle.open .chevron { transform: rotate(180deg); }
.tagcloud[data-hidden="true"] .tagcloud-inner { display: none; }

/* ─── Suche & Filter ─────────────────────────────────────────────────────── */
.search-bar {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}
.search-bar form { display: flex; flex-direction: column; gap: .625rem; }
.search-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.search-row input[type="search"], .search-row select { flex: 1; min-width: 140px; }
.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-row input[type="date"] { flex: 1; min-width: 130px; }

/* ─── Artefakt-Einzelansicht ─────────────────────────────────────────────── */
.artifact-view {}
.artifact-view-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.artifact-view-title { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.artifact-view-meta { font-size: .875rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: .375rem 1rem; margin-top: .5rem; }
.artifact-view-body { line-height: 1.75; }

.artifact-view-body h1, .artifact-view-body h2, .artifact-view-body h3,
.artifact-view-body h4, .artifact-view-body h5, .artifact-view-body h6 {
  margin: 1.5rem 0 .5rem; font-weight: 600;
}
.artifact-view-body p   { margin-bottom: 1rem; }
.artifact-view-body ul, .artifact-view-body ol { margin: .5rem 0 1rem 1.5rem; }
.artifact-view-body li  { margin-bottom: .25rem; }
.artifact-view-body pre { background: var(--bg-3); padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 1rem; }
.artifact-view-body code { background: var(--bg-3); padding: .125rem .375rem; border-radius: 3px; }
.artifact-view-body pre code { background: none; padding: 0; }
.artifact-view-body blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--text-2); }
.artifact-view-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.artifact-view-body a  { color: var(--accent); }
.artifact-view-body strong { font-weight: 600; }

/* Plaintext-Anzeige */
.content-plaintext {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: .875rem;
  background: var(--bg-2);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
}

/* ─── Export-Leiste ──────────────────────────────────────────────────────── */
.export-bar {
  display: none;
  position: sticky;
  bottom: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: .75rem 1rem;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 -2px 8px rgba(0,0,0,.1);
  z-index: 50;
}
.export-bar.visible { display: flex; }
.export-bar-count { font-size: .9375rem; font-weight: 600; flex: 1; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: .9375rem;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background .15s;
}
.pagination a:hover    { background: var(--bg-2); text-decoration: none; }
.pagination .current   { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pagination .disabled  { color: var(--text-3); pointer-events: none; }

/* ─── Setup-Seite ────────────────────────────────────────────────────────── */
.setup-body { justify-content: center; align-items: center; background: var(--bg-3); }
.setup-wrap { width: 100%; max-width: 500px; padding: 1rem; }
.setup-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.setup-logo { display: flex; align-items: center; gap: .75rem; margin-bottom: .25rem; }
.setup-logo h1 { font-size: 1.5rem; font-weight: 700; }
.setup-logo svg { color: var(--accent); }
.setup-subtitle { color: var(--text-2); font-size: .875rem; margin-bottom: 1.5rem; }
.setup-card h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }

.secret-display {
  display: block;
  word-break: break-all;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: .75rem;
  border-radius: var(--radius);
  font-size: .9375rem;
  letter-spacing: .05em;
  user-select: all;
}
.totp-uri-link {
  display: block;
  word-break: break-all;
  font-size: .8125rem;
  font-family: var(--font-mono);
  padding: .5rem;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ─── Login-Seite ────────────────────────────────────────────────────────── */
.login-wrap { display: flex; justify-content: center; align-items: flex-start; padding: 4rem 1rem; }
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.login-logo h2 { font-size: 1.25rem; font-weight: 700; }
.login-logo svg { color: var(--accent); }

/* ─── Admin-Panel ────────────────────────────────────────────────────────── */
.users-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.users-table th, .users-table td {
  padding: .625rem .875rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.users-table th { font-weight: 600; color: var(--text-2); background: var(--bg-2); }
.users-table tr:hover td { background: var(--bg-2); }

/* ─── Abschnitt-Header ───────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.section-header h1, .section-header h2 { font-size: 1.25rem; font-weight: 700; }

/* ─── Import-Ergebnis ────────────────────────────────────────────────────── */
.import-results { display: flex; flex-direction: column; gap: .375rem; margin-top: 1rem; }
.import-result-ok  { color: var(--success); font-size: .875rem; }
.import-result-err { color: var(--danger);  font-size: .875rem; }

/* ─── TOTP-Seite ─────────────────────────────────────────────────────────── */
.totp-setup { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-top: 1rem; }
.totp-setup h3 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }

/* ─── Page-Limit Selector ────────────────────────────────────────────────── */
.limit-select { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--text-2); }
.limit-select select { width: auto; min-height: 32px; padding: .25rem .5rem; font-size: .875rem; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header { gap: .5rem; }
  .nav-links a { padding: .375rem .5rem; font-size: .8125rem; }
  .main-content { padding: 1rem .75rem; }
  .artifact-item { grid-template-columns: 24px 1fr; }
  .artifact-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .form-row { grid-template-columns: 1fr; }
  .search-row, .filter-row { flex-direction: column; }
}
@media (min-width: 641px) {
  .artifact-meta { flex-wrap: nowrap; }
}
