/* secrag — shared design system ("Vault" direction: deep navy, glass
   panels, a vault-bolt logomark). One stylesheet for every page, so a
   redesign only ever happens in one place. Every page keeps its own
   functional element IDs (app.js/query.js/etc. select by ID) — this
   file only ever adds classes/structure around them, never renames
   anything a script depends on.

   Deliberately single-theme (no light/dark toggle) — a committed dark-
   glass visual identity, not an unfinished light mode. Every color is
   painted explicitly here, not left to inherit from the host page. */

:root {
  --color-bg: #030b1f;
  --color-surface: #0e2247;
  --color-surface-alt: #132a56;
  --color-border: rgba(96, 165, 250, 0.18);
  --color-text: #eaf2ff;
  --color-text-muted: #9db0d4;
  --color-text-faint: #5c7099;

  --color-primary: #3b82f6;
  --color-primary-hover: #5b95f7;
  --color-primary-soft: rgba(59, 130, 246, 0.16);

  --color-success: #34d399;
  --color-success-bg: rgba(52, 211, 153, 0.12);
  --color-success-border: rgba(52, 211, 153, 0.35);
  --color-error: #fb7185;
  --color-error-bg: rgba(251, 113, 133, 0.12);
  --color-error-border: rgba(251, 113, 133, 0.35);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251, 191, 36, 0.12);
  --color-warning-border: rgba(251, 191, 36, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  --glow-sm: 0 0 0 3px rgba(59, 130, 246, 0.22);

  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background:
    radial-gradient(900px 560px at 10% 0%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(1000px 700px at 92% 22%, rgba(21, 84, 201, 0.22), transparent 55%),
    var(--color-bg);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page { max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page--narrow { max-width: 460px; }
.page--wide { max-width: 920px; }

/* Top navigation, shared across every authenticated page */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: rgba(14, 34, 71, 0.6);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

/* The vault-bolt mark: a hex "bolt head" with a recessed lock-wheel
   center — every page inlines the same small SVG here, sized by this
   class. See favicon.svg for the source shape at full detail. */
.topbar__mark { width: 1.7rem; height: 1.7rem; filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5)); }

.topbar__title { color: var(--color-text-faint); font-weight: 500; font-family: var(--font-sans); }

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.86rem;
}

.topbar__nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.topbar__nav a:hover { color: var(--color-text); }
.topbar__nav a.is-active { color: var(--color-primary-hover); font-weight: 600; }

/* EN/DE toggle — injected by i18n.js into any [data-lang-switcher] mount */
.lang-switch { display: inline-flex; border: 1px solid var(--color-border); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  margin: 0; padding: 0.25rem 0.6rem; border: none; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--color-text-faint); font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em; cursor: pointer;
}
.lang-switch button:hover { background: rgba(255, 255, 255, 0.06); color: var(--color-text); box-shadow: none; }
.lang-switch button.is-active { background: var(--color-primary); color: white; }

h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.65rem; letter-spacing: -0.01em; margin: 0 0 0.35rem; text-wrap: balance; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin: 2.25rem 0 0.6rem; letter-spacing: -0.005em; }
p { color: var(--color-text-muted); }

.note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

a { color: var(--color-primary-hover); }

/* Cards — glass panels every section of content sits on */
.card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

/* overflow-x: auto (not hidden) — a wide table (long filenames, a full
   date/time column, an actions column) can legitimately need to scroll
   rather than get clipped; overflow-y stays hidden so the table's sharp
   corners still don't poke past the card's rounded border-radius. */
.card--flush { padding: 0; overflow-x: auto; overflow-y: hidden; }

/* Forms */
label {
  display: block;
  margin-top: 1rem;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea {
  display: block;
  margin-top: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { resize: vertical; min-height: 4rem; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--glow-sm);
}

/* Buttons */
button {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.62rem 1.15rem;
  margin-top: 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  background: linear-gradient(135deg, var(--color-primary), #1554c9);
  color: white;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.32);
}
button:hover { background: linear-gradient(135deg, var(--color-primary-hover), #1e5fdb); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.42); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

button.secondary {
  background: transparent;
  color: var(--color-text);
  border-color: rgba(96, 165, 250, 0.38);
  box-shadow: none;
}
button.secondary:hover { background: rgba(255, 255, 255, 0.05); box-shadow: none; }

button.danger { background: linear-gradient(135deg, var(--color-error), #e11d48); box-shadow: 0 4px 16px rgba(251, 113, 133, 0.3); }
button.danger:hover { background: linear-gradient(135deg, #fc8fa0, #e11d48); box-shadow: 0 6px 20px rgba(251, 113, 133, 0.4); }

button.ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  box-shadow: none;
  padding: 0.4rem 0.7rem;
  font-weight: 500;
}
button.ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--color-text); }

button.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; margin-top: 0; }

/* Result / alert boxes */
#result, .alert {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  display: none;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  border: 1px solid transparent;
}
#result.success, .alert--success { display: block; background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
#result.error, .alert--error { display: block; background: var(--color-error-bg); border-color: var(--color-error-border); color: var(--color-error); }

/* Document list (index.html) — deliberately not a <table>. A table's
   columns need a fixed row width, and with translated strings of very
   different lengths (EN vs DE) that either forced horizontal scrolling
   to reach the date/delete column or squeezed a column away entirely.
   This wraps instead: a top line with the filename (ellipsis-truncated
   if long, full name in a title tooltip) and the delete button pinned
   right, then a second line of meta info that flows onto its own line
   whenever it doesn't fit — no side-scrolling, in either language. */
.doc-list { display: flex; flex-direction: column; }
.doc-row { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--color-border); transition: background 0.12s ease; }
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: rgba(255, 255, 255, 0.03); }

.doc-row__main { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.doc-row__name {
  min-width: 0; /* lets a flex child shrink below its content width so the ellipsis can kick in */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.doc-row__main button.delete { flex-shrink: 0; }

.doc-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-faint);
}

/* Tables (employees, past conversations — still tabular data that reads
   fine as columns in both languages) */
table { width: 100%; min-width: max-content; border-collapse: collapse; margin-top: 0.9rem; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.65rem; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th { color: var(--color-text-faint); font-weight: 600; font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

/* Past-conversations accordion (query.js) — clicking a row expands its
   transcript into a detail row directly beneath it. */
.conversation-row { cursor: pointer; }
.conversation-row__chevron {
  display: inline-block;
  width: 0.9rem;
  margin-right: 0.4rem;
  color: var(--color-text-faint);
  transition: transform 0.15s ease;
}
.conversation-row--open .conversation-row__chevron { transform: rotate(90deg); }
.conversation-detail-row td { padding: 0; border-bottom: 1px solid var(--color-border); }
.conversation-detail {
  padding: 0.9rem 1rem 1rem 2.3rem;
  background: rgba(255, 255, 255, 0.02);
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.conversation-detail .turn { padding: 0.85rem 1rem; }
/* Any button rendered inside a table cell (documents/employees/
   conversations lists all build these dynamically in JS) defaults to
   the compact sizing — a full-size button looks oversized in a row. */
td button { margin-top: 0; padding: 0.35rem 0.7rem; font-size: 0.78rem; }

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.pill--active, .pill--success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.pill--muted { background: rgba(255, 255, 255, 0.05); color: var(--color-text-faint); border: 1px solid var(--color-border); }
.pill--warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }

/* Step-up / confirmation panels */
.confirm-panel {
  display: none;
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-md);
}
.confirm-panel input { max-width: 12rem; }
.confirm-panel .actions { display: flex; gap: 0.6rem; align-items: center; }
.confirm-panel .actions button { margin-top: 0; }

.secret-box {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.empty-state {
  margin-top: 0.85rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-faint);
  font-size: 0.9rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.actions-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.actions-row button { margin-top: 0; }

/* query.js toggles this purely via inline style.display (always an
   error — no success variant needed on this page), not a class. */
#error {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  display: none;
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
  white-space: pre-wrap;
  font-size: 0.85rem;
}

/* Q&A turns (query.html/query.js builds these dynamically) */
#turns { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.turn {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  padding: 1.1rem 1.25rem;
}

.turn .question {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}
.turn .question::before {
  content: "Q";
  flex: none;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #1554c9);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.turn .answer {
  margin-top: 0.65rem;
  padding-left: 2.2rem;
  white-space: pre-wrap;
  color: var(--color-text);
  line-height: 1.6;
}
.turn .answer--pending { font-style: italic; color: var(--color-text-faint); animation: chat-pulse 1.6s ease-in-out infinite; }

.turn .sources {
  margin-top: 0.6rem;
  padding-left: 2.2rem;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--color-text-faint);
}

/* ============ Floating "ask" widget (chat-widget.js) ============
   Injected into the DOM by script, not present in any page's markup —
   this is its complete visual definition. */

.chat-fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.1rem 0.6rem 0.6rem;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: rgba(14, 34, 71, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chat-fab:hover { transform: translateY(-2px); background: rgba(19, 42, 86, 0.9); }
.chat-fab svg { width: 2.1rem; height: 2.1rem; flex: none; filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.55)); }
.chat-fab.is-open .chat-fab__label { display: none; }
.chat-fab.is-open { padding: 0.6rem; }

.chat-panel {
  position: fixed;
  right: 1.5rem;
  bottom: 6rem;
  z-index: 50;
  width: min(380px, calc(100vw - 3rem));
  height: min(540px, calc(100vh - 9rem));
  display: none;
  flex-direction: column;
  background: rgba(11, 27, 58, 0.94);
  backdrop-filter: blur(22px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.chat-panel.is-open { display: flex; }

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  flex: none;
}
.chat-panel__close {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.chat-panel__close:hover { color: var(--color-text); background: none; box-shadow: none; }

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-panel__intro { color: var(--color-text-faint); font-size: 0.82rem; text-align: center; margin-top: 2rem; }

.chat-turn__q { font-weight: 700; font-size: 0.85rem; color: var(--color-text); }
.chat-turn__a { margin-top: 0.35rem; font-size: 0.85rem; color: var(--color-text-muted); white-space: pre-wrap; line-height: 1.55; }
.chat-turn__a--pending { font-style: italic; color: var(--color-text-faint); animation: chat-pulse 1.6s ease-in-out infinite; }
.chat-turn__sources {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--color-text-faint);
}
@keyframes chat-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.chat-panel__footer {
  flex: none;
  border-top: 1px solid var(--color-border);
}

.chat-panel__form { display: flex; gap: 0.5rem; padding: 0.9rem 1.1rem; align-items: flex-end; }
.chat-panel__form textarea { margin-top: 0; min-height: 2.5rem; max-height: 5rem; flex: 1; font-size: 0.85rem; }
.chat-panel__form button { margin-top: 0; padding: 0.55rem 0.9rem; flex: none; }

.chat-panel__error {
  margin: 0 1.1rem 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  display: none;
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  color: var(--color-error);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.chat-panel__link {
  display: block;
  text-align: center;
  padding: 0 1.1rem 0.9rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}
