/* ==========================================================================
   Faplo · Portal — shared stylesheet
   Project Zora tokens. Dark, quiet, precise. WCAG 2.2 AA.
   ========================================================================== */

:root {
  /* Backgrounds */
  --bg-primary:   #06060F;
  --bg-surface:   #0E0E1B;
  --bg-elevated:  #15152A;

  /* Borders & text */
  --border-subtle: #1E1E38;
  --border-strong: #2A2A4A;
  --text-primary:  #E8E8F2;
  --text-muted:    #8F8FAD;
  --text-dim:      #5C5C7A;

  /* Accents */
  --accent-primary:   #FF9966;
  --accent-secondary: #FFCC66;

  /* Semantic */
  --ok:    #66D98F;
  --error: #FF6B8A;
  --info:  #66B3FF;

  /* Type */
  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Geometry */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* Starfield canvas sits behind everything, non-interactive. */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

main, header, footer { position: relative; z-index: 1; }

/* ---------- Focus ring (Pflicht) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Links ---------- */
a {
  color: var(--accent-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}
a:hover { border-bottom-color: var(--accent-secondary); }

/* ---------- App shell ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(6, 6, 15, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  border-bottom: none;
}
.brand:hover { border-bottom-color: transparent; }

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: inline-grid;
  place-items: center;
  position: relative;
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 1px;
}
.brand-mark::before {
  width: 10px; height: 2px;
  background: var(--accent-primary);
  transform: translateY(-2px);
}
.brand-mark::after {
  width: 6px; height: 2px;
  background: var(--accent-secondary);
  transform: translateY(2px);
}

.brand-text { display: inline-flex; align-items: baseline; gap: 6px; }
.brand-text .dot { color: var(--text-dim); font-weight: 400; }
.brand-text .sub { color: var(--text-muted); font-weight: 500; }

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-primary);
}
.user-chip .role {
  color: var(--accent-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-link {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-bottom: none;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-surface); border-bottom-color: transparent; }
.nav-link.active { color: var(--accent-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: #1c1c36; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent-primary);
  color: #1a0d06;
  font-weight: 600;
}
.btn-primary:hover { background: #ffad85; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-dim); }

.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.label-num {
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-right: 8px;
  font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  transition: border-color .12s ease, background .12s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

.field-error {
  margin-top: 6px;
  font-size: 12px;
  color: var(--error);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-error::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--error);
  flex-shrink: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--shadow-inset);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}
.card-header .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0,0,0,0.15);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card .card-body { padding: 26px; }
.login-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}
.login-card .field + .field { margin-top: 14px; }
.login-card .btn-primary { width: 100%; margin-top: 18px; padding: 11px; }

.login-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.login-footer a { color: var(--text-muted); }
.login-footer a:hover { color: var(--accent-secondary); }

/* TLP banner (small, unobtrusive — this is an internal tool) */
.tlp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-secondary);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 204, 102, 0.25);
  background: rgba(255, 204, 102, 0.04);
}
.tlp .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-secondary);
}

/* ---------- Dashboard ---------- */
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}
.page-wide { max-width: 1100px; }

.page-intro {
  margin-bottom: 28px;
}
.page-intro h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.page-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.card + .card { margin-top: 20px; }

.field { margin: 0; }
.field + .field { margin-top: 18px; }

.q-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.q-header label {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}
.q-help {
  color: var(--text-muted);
  font-size: 12px;
  margin: 6px 0 0;
}

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  background: var(--bg-primary);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  cursor: pointer;
}
.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--accent-primary);
  background: rgba(255, 153, 102, 0.04);
}
.dropzone.drag-active {
  border-color: var(--accent-primary);
  background: rgba(255, 153, 102, 0.08);
  border-style: solid;
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone-title {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 4px;
}
.dropzone-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}
.dropzone-hint kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.upload-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-list:empty { display: none; }
.upload-item {
  display: grid;
  grid-template-columns: 18px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.upload-item .status {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #06060F;
}
.upload-item .status.ok    { background: var(--ok); }
.upload-item .status.err   { background: var(--error); }
.upload-item .status.pending { background: var(--text-dim); }
.upload-item .fname { color: var(--text-primary); }
.upload-item .fmeta { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.upload-item .faction {
  color: var(--text-muted);
  font-size: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.upload-item .faction:hover { color: var(--error); }

/* ---------- Tabs (Admin) ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}
.tab .count {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.tab[aria-selected="true"] .count { color: var(--accent-secondary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-surface);
  box-shadow: var(--shadow-inset);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 720px;
}
thead th {
  text-align: left;
  padding: 11px 14px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 153, 102, 0.03); }
td.mono, .mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-ok    { color: var(--ok);    background: rgba(102, 217, 143, 0.08); border-color: rgba(102, 217, 143, 0.25); }
.pill-err   { color: var(--error); background: rgba(255, 107, 138, 0.08); border-color: rgba(255, 107, 138, 0.25); }
.pill-info  { color: var(--info);  background: rgba(102, 179, 255, 0.08); border-color: rgba(102, 179, 255, 0.25); }
.pill-muted { color: var(--text-muted); background: var(--bg-elevated); border-color: var(--border-subtle); }
.pill-admin { color: var(--accent-secondary); background: rgba(255, 204, 102, 0.06); border-color: rgba(255, 204, 102, 0.25); }

/* Toolbar above tables */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar .search {
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.toolbar .search input { padding: 7px 10px; font-size: 13px; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in .2s ease-out;
}
.toast.toast-ok    { border-left-color: var(--ok); }
.toast.toast-error { border-left-color: var(--error); }
.toast.toast-info  { border-left-color: var(--info); }
.toast.closing { animation: toast-out .2s ease-in forwards; }
.toast .toast-title { font-weight: 600; margin-bottom: 2px; }
.toast .toast-msg   { color: var(--text-muted); font-size: 12px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

/* ---------- Utility ---------- */
.row        { display: flex; gap: 12px; align-items: center; }
.row-between{ display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.stack      { display: flex; flex-direction: column; gap: 12px; }
.spacer     { flex: 1; }
.muted      { color: var(--text-muted); }
.mono       { font-family: var(--font-mono); }
.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;
}

/* ---------- Submit Banner (Form-Feedback) ---------- */
.submit-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  animation: banner-in .25s ease-out;
}
.submit-banner-ok {
  background: rgba(102, 217, 143, 0.08);
  border: 1px solid rgba(102, 217, 143, 0.3);
  color: var(--text-primary);
}
.submit-banner-err {
  background: rgba(255, 107, 138, 0.08);
  border: 1px solid rgba(255, 107, 138, 0.3);
  color: var(--text-primary);
}
.submit-banner-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: #06060F;
}
.submit-banner-ok  .submit-banner-icon { background: var(--ok); }
.submit-banner-err .submit-banner-icon { background: var(--error); }
.submit-banner-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.submit-banner-msg {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Success-State für Submit-Button */
.btn-success-state {
  background: var(--ok) !important;
  color: #06060F !important;
  pointer-events: none;
  animation: btn-pulse .5s ease-out;
}
@keyframes btn-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-header { padding: 12px 16px; }
  .page { padding: 24px 16px 60px; }
  .card-body { padding: 18px; }
  .card-header { padding: 14px 18px 12px; }
  .header-right .user-chip .uname { display: none; }
  .page-intro h1 { font-size: 20px; }
}
