/* Wilke IT Datenraum — design system.
   Served locally (CSP-safe, no build step). Styles the shared class vocabulary
   used across the auth card pages (base.html) and the app shell (app_base.html). */

:root {
  /* Brand */
  --brand: #122945;        /* Nachtblau  */
  --brand-600: #1c3a5e;
  --accent: #c8361d;       /* Rot-Orange (Homepage-CTA) */
  --accent-700: #a63019;
  --sky: #56a8dd;          /* Azurblau   */
  --link: #1667a0;         /* darker sky — AA contrast on white */

  /* Neutrals */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #122945;
  --muted: #57697b;
  --border: #e0e5eb;

  /* Scale */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem;
  --sp-4: 1rem;    --sp-5: 1.5rem; --sp-6: 2rem;
  --radius: 10px;  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(18, 41, 69, 0.08), 0 8px 28px rgba(18, 41, 69, 0.06);
  --focus: 0 0 0 3px rgba(86, 168, 221, 0.55);
  --font: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.55;
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 var(--sp-4); }
h2 { font-size: 1.15rem; margin: var(--sp-5) 0 var(--sp-3); }
p  { margin: 0 0 var(--sp-3); }

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

.muted, .badge { color: var(--muted); font-size: 0.9rem; }

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: #eef2f6; padding: 0.15rem 0.4rem; border-radius: 4px;
  word-break: break-all;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Keyboard focus — visible on every interactive element */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm);
}

/* --- Buttons ------------------------------------------------------------- */
button, .btn, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  font: inherit; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--brand); color: #fff;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.02s ease;
}
button:active, .btn:active, .btn-secondary:active, .btn-danger:active { transform: translateY(1px); }
button:hover, .btn:hover { background: var(--brand-600); }
.btn-secondary { background: #fff; color: var(--brand); border-color: var(--border); }
.btn-secondary:hover { background: #eef2f6; }
.btn-danger { background: var(--accent); color: #fff; }
.btn-danger:hover { background: var(--accent-700); }

/* --- Forms --------------------------------------------------------------- */
label { display: block; font-weight: 600; margin: var(--sp-3) 0 var(--sp-1); }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="file"],
select, textarea {
  width: 100%; padding: 0.6rem 0.7rem; font: inherit;
  color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { border-color: var(--sky); outline: none; }

.check { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.check input { width: auto; }

/* A row of small controls (create/rename/move actions, resend button) */
.inline-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin: var(--sp-3) 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 12rem; }
.stack-gap > * + * { margin-top: var(--sp-3); }

/* --- Alerts / messages --------------------------------------------------- */
.errors {
  color: var(--accent-700); background: #fdeee9; border: 1px solid #f6ccbc;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); margin: 0.5rem 0;
}
.notice {
  color: #0f5132; background: #e6f4ea; border: 1px solid #bfe3cb;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); margin: 0.5rem 0;
}
.notice-warn {
  color: #8a5a12; background: #fdf1e5; border: 1px solid #f2d9bd;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); margin: 0.5rem 0;
}

/* --- Auth card (base.html) ---------------------------------------------- */
body.auth {
  display: flex; flex-direction: column; min-height: 100vh; align-items: center;
  justify-content: center; padding: var(--sp-5);
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--sp-6); width: 100%; max-width: 26rem;
}
.card h1 { font-size: 1.3rem; }
/* Auth forms use full-width submit buttons. */
body.auth button { width: 100%; margin-top: var(--sp-4); }

/* --- App shell: left sidebar on wide screens, top bar when narrow -------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.sidebar {
  background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4); flex-wrap: wrap;
}
.side-brand {
  color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.side-brand .brand-logo { height: 40px; width: auto; max-width: 100%; display: block; }
.side-nav { display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.side-nav a {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: rgba(255, 255, 255, 0.82); text-decoration: none; font-weight: 600;
  font-size: 0.92rem; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.side-nav a.active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.side-nav .icon { width: 1.05rem; height: 1.05rem; }
.side-badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; padding: 0.02rem 0.4rem; margin-left: 0.15rem;
}
.side-foot { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.side-user {
  font-size: 0.82rem; color: rgba(255, 255, 255, 0.72);
  max-width: 15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-logout {
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.4); color: #fff;
  padding: 0.4rem 0.8rem; gap: 0.4rem;
}
.side-logout:hover { background: rgba(255, 255, 255, 0.14); }
.app-main { max-width: 72rem; margin: var(--sp-5) auto; padding: 0 var(--sp-5); width: 100%; }

@media (min-width: 960px) {
  .app-shell { display: grid; grid-template-columns: 15rem 1fr; align-items: stretch; }
  .sidebar {
    flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    gap: var(--sp-4); height: 100vh; position: sticky; top: 0;
    padding: var(--sp-5) var(--sp-4);
  }
  .side-brand { margin-bottom: var(--sp-3); font-size: 1.15rem; }
  .side-brand .brand-logo { height: 48px; }
  .side-nav { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0.15rem; }
  .side-foot {
    margin-left: 0; margin-top: auto; flex-direction: column; align-items: stretch;
    gap: var(--sp-3); border-top: 1px solid rgba(255, 255, 255, 0.14); padding-top: var(--sp-4);
  }
  .side-user { max-width: 100%; }
  .side-logout { width: 100%; justify-content: center; }
  .app-main { margin: var(--sp-6) auto; padding: 0 var(--sp-6); }
}

/* --- Dashboard ---------------------------------------------------------- */
.dash-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: 0.15rem;
  text-decoration: none; color: inherit;
}
a.stat:hover { border-color: var(--sky); }
.stat-val { font-size: 1.75rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); align-items: start; }
@media (max-width: 820px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); }
.dash-panel > h2 { margin: 0 0 var(--sp-3); font-size: 1.05rem; }
.dash-item {
  display: flex; gap: var(--sp-3); align-items: center;
  padding: 0.6rem 0; border-top: 1px solid var(--border);
}
.dash-item:first-of-type { border-top: 0; }
.di-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; background: #eef4fa; color: var(--link); }
.di-ic.di-warn { background: #fdeee9; color: var(--accent-700); }
.di-main { min-width: 0; flex: 1; }
.di-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.di-title a { color: var(--text); text-decoration: none; }
.di-title a:hover { color: var(--link); text-decoration: underline; }
.di-sub { font-size: 0.82rem; color: var(--muted); }
.di-meta { font-size: 0.8rem; color: var(--muted); white-space: nowrap; text-align: right; }
.di-meta.di-warn { color: var(--accent-700); font-weight: 600; }
.dash-empty { color: var(--muted); font-size: 0.9rem; padding: var(--sp-3) 0; }

/* --- Tables -------------------------------------------------------------- */
table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--border); }
thead th {
  background: #eef2f6; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f7f9fb; }

/* --- Misc ---------------------------------------------------------------- */
.crumbs { margin: 0 0 var(--sp-4); font-size: 0.95rem; color: var(--muted); }
.empty { color: var(--muted); padding: var(--sp-5) 0; text-align: center; }
.mt { margin-top: var(--sp-4); }
.divide-top { border-top: 1px solid var(--border); padding: var(--sp-3) 0; }

/* Backup-code list and single-secret display (auth setup pages) */
.codes {
  list-style: none; margin: var(--sp-3) 0; padding: var(--sp-4) var(--sp-5);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: ui-monospace, Menlo, monospace; line-height: 1.9;
}
.code-block {
  display: inline-block; padding: 0.4rem 0.6rem; font-size: 1rem; background: var(--bg);
}

details summary {
  cursor: pointer; font-weight: 600; color: var(--link); list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: ""; display: inline-block; width: 0.45em; height: 0.45em;
  margin-right: 0.55em; vertical-align: middle;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s ease;
}
details[open] summary::before { transform: rotate(45deg); }

/* Branding: app name on the auth card, tenant footer */
.auth-brand {
  margin: 0 0 var(--sp-4);
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.01em;
}
.auth-logo { display: block; max-height: 48px; width: auto; margin: 0 0 var(--sp-4); }
.brand-logo { height: 28px; width: auto; display: block; }
.upload-progress { width: 100%; max-width: 24rem; height: 0.75rem; margin: var(--sp-3) 0; }

/* --- Icons (inline SVG sprite) --- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon, .file-icon {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon { width: 1.05em; height: 1.05em; flex: none; }

/* --- Action toolbar (folder browser) --- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin: var(--sp-4) 0; }
.toolbar .btn, .toolbar .btn-secondary { padding: 0.45rem 0.9rem; }

/* --- Create-folder bar --- */
/* New-folder disclosure + form panel */
.new-folder { margin: var(--sp-4) 0; }
.new-folder > summary {
  display: inline-flex; align-items: center; gap: 0.5rem; width: fit-content;
  cursor: pointer; list-style: none; font-weight: 600; font-size: 0.95rem; color: var(--brand);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.6rem 1.15rem; background: var(--surface);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.new-folder > summary::-webkit-details-marker { display: none; }
.new-folder > summary::before { content: none; }  /* not the generic details chevron */
.new-folder > summary:hover { background: #eef2f6; border-color: var(--sky); }
.new-folder[open] > summary { background: var(--brand); border-color: var(--brand); color: #fff; }
.new-folder-form {
  display: flex; flex-direction: column; gap: var(--sp-5); max-width: 34rem;
  margin-top: var(--sp-3); padding: var(--sp-6);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { margin: 0; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.new-folder-form input[name="name"], .new-folder-form select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 0.72rem 0.9rem; font: inherit; color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.new-folder-form input[name="name"]:focus, .new-folder-form select:focus {
  border-color: var(--sky); background: #fff; box-shadow: 0 0 0 3px rgba(86, 168, 221, 0.18); outline: none;
}
.select-wrap { position: relative; display: block; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer; }
.select-wrap::after {
  content: ""; position: absolute; right: 1.05rem; top: 50%; margin-top: -0.35rem;
  width: 0.5rem; height: 0.5rem; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
.new-folder-opts { display: flex; flex-wrap: wrap; gap: var(--sp-5); }
.toggle {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-size: 0.92rem; font-weight: 600; color: var(--text); cursor: pointer; user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .toggle-box {
  width: 1.3rem; height: 1.3rem; flex: 0 0 auto; background: #fff;
  border: 2px solid #cdd6e0; border-radius: 6px;
  display: grid; place-items: center; color: #fff; transition: background 0.15s ease, border-color 0.15s ease;
}
.toggle .toggle-box .icon { width: 0.85rem; height: 0.85rem; opacity: 0; transition: opacity 0.12s ease; }
.toggle input:checked ~ .toggle-box { background: var(--brand); border-color: var(--brand); }
.toggle input:checked ~ .toggle-box .icon { opacity: 1; }
.toggle input:focus-visible ~ .toggle-box { box-shadow: var(--focus); }
.new-folder-actions { display: flex; }
.check { display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.check input { width: 1rem; height: 1rem; accent-color: var(--sky); }

/* --- Card list of folders / files --- */
.file-list {
  list-style: none; margin: var(--sp-4) 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.file-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.8rem var(--sp-4); border-top: 1px solid var(--border);
}
.file-row:first-child { border-top: none; }
.file-row:hover { background: #f7f9fc; }
.file-check { flex: none; width: 1.1rem; display: inline-flex; align-items: center; }
.file-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--sky); }
.file-icon { width: 22px; height: 22px; flex: none; }
.file-icon.is-folder { stroke: var(--sky); }
.file-icon.is-file { stroke: var(--muted); }
.file-name {
  flex: 1 1 auto; min-width: 0; font-weight: 600; text-decoration: none; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-name:hover { color: var(--link); }
.file-meta { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.file-meta a { font-size: 0.85rem; }

/* --- Status pills --- */
.pill {
  display: inline-flex; align-items: center; gap: 0.3em;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.pill .icon { width: 0.9em; height: 0.9em; }
.pill-ok { background: #e7f4ee; color: #1c7a4f; }
.pill-info { background: #eaf3fb; color: var(--link); }
.pill-muted { background: #eef2f6; color: var(--muted); }
.pill-warn { background: #fdf1e5; color: #b5651d; }
.pill-accent { background: var(--accent); color: #fff; }
/* Table cells that carry pills / an icon + link */
td .pill { margin-right: 0.3rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.cell-with-icon { display: inline-flex; align-items: center; gap: var(--sp-2); }
.cell-with-icon .file-icon { width: 20px; height: 20px; }

/* Multi-line middle column in a card row (e.g. a download token) */
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.row-title { font-weight: 600; word-break: break-all; }

/* Framed container for standalone forms in the app shell */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--sp-5) var(--sp-6); max-width: 42rem;
}
.form-card > :first-child { margin-top: 0; }

/* --- Collapsible panel (folder settings) --- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4);
}
.panel-body { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
.auth-footer {
  max-width: 26rem;
  margin: var(--sp-4) auto 0;
  padding: 0 var(--sp-4);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.app-footer {
  max-width: 64rem;
  margin: var(--sp-6) auto var(--sp-5);
  padding: var(--sp-4) var(--sp-4) 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .app-header { padding: var(--sp-3) var(--sp-4); }
  .app-main { padding: 0 var(--sp-4); }
  .card { padding: var(--sp-5); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
