/* ZeroBay dark theme — black / white / red / grey only. Built on Bootstrap 5.3 CSS variables. */

:root,
[data-bs-theme="dark"] {
  --zd-bg: #09090a;
  --zd-surface: #131315;
  --zd-surface-alt: #1c1c1f;
  --zd-border: #2a2a2e;
  --zd-border-strong: #3a3a3f;
  --zd-text: #e9e9ea;
  --zd-text-muted: #9a9aa0;
  --zd-red: #dc2626;
  --zd-red-strong: #ef4444;
  --zd-red-dim: #5c1414;
  --zd-red-bg: #2a1010;

  /* Severity chart ramp — a status palette (not a pure single-hue sequential ramp), since Critical/High
     read as "red family" and Medium/Low as "grey family". Each step's sRGB relative luminance was checked
     by hand (Critical .223, High .076, Medium .342, Low/Info .047 — all pairs differ by >=0.05, well
     above the ~0.01-0.02 JND) since this environment's Node (v14) predates the dataviz skill validator's
     ??= syntax requirement (Node 15+) and the script couldn't be run directly. */
  --zd-chart-critical: #ef4444;
  --zd-chart-high: #991b1b;
  --zd-chart-medium: #a8a29e;
  --zd-chart-lowinfo: #3f3f46;

  color-scheme: dark;

  --bs-body-bg: var(--zd-bg);
  --bs-body-color: var(--zd-text);
  --bs-border-color: var(--zd-border);
  --bs-emphasis-color: #ffffff;
  --bs-secondary-color: var(--zd-text-muted);
  --bs-tertiary-bg: var(--zd-surface-alt);
  --bs-link-color: var(--zd-red-strong);
  --bs-link-hover-color: #ff6b6b;
  --bs-primary: var(--zd-red);
  --bs-primary-rgb: 220, 38, 38;
  --bs-danger: var(--zd-red-strong);
}

html {
  font-size: 15px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html, body {
  min-height: 100%;
  background-color: var(--zd-bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

/* ---- Navbar ---- */
.zd-navbar {
  background-color: #000000;
  border-bottom: 1px solid var(--zd-border);
}

.zd-brand,
.zd-brand:hover,
.zd-brand:focus,
.zd-brand:active {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff !important;
  text-decoration: none !important;
}

.zd-brand-logo {
  height: 50px;
  width: auto;
  display: block;
}

.zd-navbar .nav-link {
  color: var(--zd-text-muted);
}

.zd-navbar .nav-link.active,
.zd-navbar .nav-link:hover,
.zd-navbar .nav-link:focus {
  color: #ffffff;
}

.zd-navbar .navbar-toggler {
  border-color: var(--zd-border-strong);
}

/* ---- Cards / surfaces ---- */
.card {
  background-color: var(--zd-surface);
  border: 1px solid var(--zd-border);
}

.card-header {
  background-color: var(--zd-surface-alt);
  border-bottom: 1px solid var(--zd-border);
}

.zd-breadcrumb {
  margin-bottom: 1rem;
}

.zd-breadcrumb .breadcrumb {
  --bs-breadcrumb-divider-color: var(--zd-text-muted);
  font-size: 0.8125rem;
}

.zd-breadcrumb .breadcrumb-item a {
  color: var(--zd-text-muted);
  text-decoration: none;
}

.zd-breadcrumb .breadcrumb-item a:hover {
  color: var(--zd-text);
  text-decoration: underline;
}

.zd-breadcrumb .breadcrumb-item.active {
  color: var(--zd-text);
}

.zd-sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.zd-sortable-th:hover {
  color: var(--zd-text);
}

.zd-sortable-th::after {
  content: '\2195';
  display: inline-block;
  margin-left: 0.35em;
  color: var(--zd-text-muted);
  opacity: 0.5;
  font-size: 0.85em;
}

.zd-sortable-th.zd-sorted-asc::after {
  content: '\2191';
  color: var(--zd-red-strong);
  opacity: 1;
}

.zd-sortable-th.zd-sorted-desc::after {
  content: '\2193';
  color: var(--zd-red-strong);
  opacity: 1;
}

.zd-stat-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  height: 100%;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.zd-stat-card-link:hover {
  color: inherit;
  transform: translateY(-2px);
}

.zd-stat-card-link:hover,
.zd-stat-card-link:hover * {
  text-decoration: none !important;
}

.zd-stat-card-link:hover .card {
  border-color: var(--zd-border-strong);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--zd-text);
  --bs-table-border-color: var(--zd-border);
  --bs-table-striped-bg: var(--zd-surface-alt);
  --bs-table-hover-bg: var(--zd-surface-alt);
}

/* Wide tables (findings grids, evidence) scroll within their own container on small screens
   instead of forcing the page to scroll horizontally. */
.table-responsive {
  border: 1px solid var(--zd-border);
  border-radius: 0.375rem;
}

/* ---- Forms ---- */
.form-control,
.form-select {
  background-color: var(--zd-surface);
  border-color: var(--zd-border-strong);
  color: var(--zd-text);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--zd-surface);
  color: var(--zd-text);
  border-color: var(--zd-red);
  box-shadow: 0 0 0 0.25rem var(--zd-red-dim);
}

.form-control::placeholder {
  color: var(--zd-text-muted);
}

/* ---- Buttons ---- */
.btn-primary {
  --bs-btn-bg: var(--zd-red);
  --bs-btn-border-color: var(--zd-red);
  --bs-btn-hover-bg: var(--zd-red-strong);
  --bs-btn-hover-border-color: var(--zd-red-strong);
  --bs-btn-active-bg: #b91c1c;
  --bs-btn-active-border-color: #b91c1c;
  --bs-btn-disabled-bg: var(--zd-red-dim);
  --bs-btn-disabled-border-color: var(--zd-red-dim);
}

.btn-outline-light {
  --bs-btn-color: var(--zd-text);
  --bs-btn-border-color: var(--zd-border-strong);
  --bs-btn-hover-bg: var(--zd-surface-alt);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: var(--zd-border-strong);
}

.btn-link {
  color: var(--zd-text-muted);
}

/* ---- Auth pages ---- */
.zd-auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.zd-auth-logo {
  width: 100%;
  max-width: 160px;
  height: auto;
  margin-bottom: 1.5rem;
}

.zd-auth-card {
  width: 100%;
  max-width: 380px;
}

/* ---- Severity badges (kept within the black/white/red/grey palette;
   severity is differentiated by weight/tone rather than a rainbow of hues) ---- */
.zd-badge-severity {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.zd-badge-critical {
  background-color: var(--zd-red);
  color: #fff;
}

.zd-badge-high {
  background-color: var(--zd-red-bg);
  color: var(--zd-red-strong);
  border-color: var(--zd-red-dim);
}

.zd-badge-medium {
  background-color: var(--zd-surface-alt);
  color: var(--zd-text);
  border-color: var(--zd-border-strong);
}

.zd-badge-low,
.zd-badge-info {
  background-color: transparent;
  color: var(--zd-text-muted);
  border-color: var(--zd-border);
}

/* ---- Footer ---- */
.zd-footer {
  border-top: 1px solid var(--zd-border);
  color: var(--zd-text-muted);
  font-size: 0.875rem;
}

/* ---- Utility: keep any wide content (code blocks, evidence dumps) from
   blowing out the viewport on mobile ---- */
pre, .zd-scroll-x {
  overflow-x: auto;
  max-width: 100%;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Chat bubbles (ProjectChat) ---- */
.zd-chat-bubble {
  max-width: 80%;
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.zd-chat-user {
  align-self: flex-end;
  background-color: var(--zd-red-dim);
  color: var(--zd-text);
  border: 1px solid var(--zd-red);
}

.zd-chat-assistant {
  align-self: flex-start;
  background-color: var(--zd-surface-alt);
  color: var(--zd-text);
  border: 1px solid var(--zd-border-strong);
}

/* A live-fired AI tool call (see ProjectChatHub.SendFindingMessage) — visually distinct from a normal
   assistant reply so it reads as "the AI did something" rather than "the AI said something". */
.zd-chat-tool {
  align-self: flex-start;
  background-color: transparent;
  color: var(--zd-text-muted);
  border: 1px dashed var(--zd-border-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.zd-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0;
}

.zd-chat-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background-color: var(--zd-text-muted, #9a9a9a);
  animation: zd-chat-bounce 1.1s infinite ease-in-out both;
}

.zd-chat-typing span:nth-child(1) { animation-delay: -0.24s; }
.zd-chat-typing span:nth-child(2) { animation-delay: -0.12s; }
.zd-chat-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes zd-chat-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.zd-chat-thinking {
  font-size: 0.8rem;
  color: var(--zd-text-muted);
  border-left: 2px solid var(--zd-border);
  padding-left: 0.5rem;
  margin-bottom: 0.4rem;
}

.zd-chat-thinking summary {
  cursor: pointer;
  font-style: italic;
}

.zd-chat-thinking-text {
  white-space: pre-wrap;
  font-style: italic;
  margin-top: 0.25rem;
}

.zd-chat-content.zd-chat-streaming-cursor::after {
  content: '\258c';
  display: inline-block;
  margin-left: 1px;
  color: var(--zd-text-muted);
  animation: zd-cursor-blink 1s step-start infinite;
}

@keyframes zd-cursor-blink {
  50% { opacity: 0; }
}

/* Markdown rendered inside a chat bubble (see ChatMarkdownRenderer) — highlight.js supplies code-token
   colors itself (github-dark theme), this just fits the surrounding block/table/link chrome to the app's
   dark palette. */
.zd-chat-bubble :is(p, ul, ol, blockquote, table, pre):last-child {
  margin-bottom: 0;
}

.zd-chat-bubble pre {
  background-color: var(--zd-bg);
  border: 1px solid var(--zd-border);
  border-radius: 0.4rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.zd-chat-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.zd-chat-bubble :not(pre) > code {
  background-color: var(--zd-bg);
  border: 1px solid var(--zd-border);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.zd-chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.85em;
}

.zd-chat-bubble th,
.zd-chat-bubble td {
  border: 1px solid var(--zd-border);
  padding: 0.3rem 0.5rem;
  text-align: left;
}

.zd-chat-bubble blockquote {
  border-left: 2px solid var(--zd-border-strong);
  padding-left: 0.6rem;
  color: var(--zd-text-muted);
  margin: 0.5rem 0;
}

.zd-chat-bubble a {
  color: var(--zd-red-strong);
}

/* ---- Scan progress bar (Scans/Details) ---- */
.zd-progress-track {
  height: 0.5rem;
  border-radius: 999px;
  background-color: var(--zd-surface-alt);
  border: 1px solid var(--zd-border);
  overflow: hidden;
}

.zd-progress-fill {
  height: 100%;
  background-color: var(--zd-red);
  transition: width 0.6s ease;
}

.zd-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.8rem;
  color: var(--zd-text-muted);
  margin-top: 0.4rem;
}

/* ---- Scan origin indicator (navbar) ---- */
.zd-scan-origin {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--zd-text-muted);
}

.zd-scan-origin-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--zd-border-strong);
  flex-shrink: 0;
}

.zd-scan-origin-dot-proxied {
  background-color: var(--zd-red-strong);
  box-shadow: 0 0 4px var(--zd-red-strong);
}

.zd-scan-origin-dot-direct {
  background-color: #ffffff;
}

.zd-scan-origin-dot-unknown {
  background-color: var(--zd-text-muted);
}

/* ---- Severity distribution bar (Dashboard) ---- */
.zd-sev-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--zd-surface-alt);
  gap: 2px;
}

.zd-sev-segment {
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-width: 3px;
}

.zd-sev-segment:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.zd-sev-segment:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.zd-sev-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--zd-text-muted);
}

.zd-sev-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.zd-sev-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
