/* pentest-ai dashboard
 * Mirrors the live pentestai.xyz design system (v0.10.1):
 *   --bg dirty white, --fg dark green, --accent lime, --warn orange
 * Neue Montreal display, Geist Mono mono.
 *
 * Premium minimal, terminal-industries aesthetic.
 */

:root {
  /* Color tokens copied from pentestai.xyz live CSS */
  --c-black: #000;
  --c-dark-gray: #7f7f7f;
  --c-dark-green: #052424;
  --c-dirty-white: #f0f0f0;
  --c-gray: #454742;
  --c-light-gray: #c2c2c2;
  --c-light-light-gray: #ddd;
  --c-lime: #abff02;
  --c-orange: #fb6b3c;
  --c-white: #fff;

  --bg: var(--c-dirty-white);
  --fg: var(--c-dark-green);
  --fg-2: var(--c-gray);
  --line: rgba(5, 36, 36, 0.08);
  --line-strong: rgba(5, 36, 36, 0.18);
  --accent: var(--c-lime);
  --warn: var(--c-orange);

  --display: 'Neue Montreal', 'SuisseIntl', -apple-system, system-ui, sans-serif;
  --sans: 'Neue Montreal', 'SuisseIntl', -apple-system, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --maxw: 1320px;
  --margin: min(3.646vw, 64px);
  --radius: 4px;

  /* Severity colors (only places where we deviate from white/lime/dark-green) */
  --sev-critical: #c00;
  --sev-high: #e94560;
  --sev-medium: var(--c-orange);
  --sev-low: #aaa;
  --sev-info: var(--c-light-gray);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--fg); }

code, .mono { font-family: var(--mono); }

/* ─── Topbar ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--margin);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: -0.02em;
  font-weight: 500;
}
.logo .dash { color: var(--fg-2); }

.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--fg-2);
}

.topnav {
  display: flex;
  gap: 24px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.topnav a {
  color: var(--fg-2);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}
.topnav a:hover { color: var(--fg); }
.topnav a.nav-active { color: var(--fg); border-bottom-color: var(--fg); }

.topright { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--fg-2); }
.health-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-light-gray);
  transition: background 200ms;
}
.health-dot.ok { background: var(--accent); box-shadow: 0 0 0 4px rgba(171, 255, 2, 0.2); }
.health-dot.bad { background: var(--warn); }

/* ─── Layout ─────────────────────────────────────────────────────────── */

.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px var(--margin);
}

.panel { display: block; }
.panel.hidden { display: none; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.panel-head h2 {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}
.panel-actions { display: flex; gap: 12px; align-items: center; }
.hint { font-family: var(--mono); font-size: 11px; color: var(--fg-2); }

/* ─── Buttons ────────────────────────────────────────────────────────── */

.btn {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 120ms, border-color 120ms;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { background: var(--line); color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--fg); }
.btn.primary:hover { background: var(--fg); color: var(--accent); }

/* ─── Engagement list / detail ───────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.engagement-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--c-white);
  min-height: 300px;
  overflow: hidden;
}
.engagement-row {
  display: block;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms;
}
.engagement-row:last-child { border-bottom: none; }
.engagement-row:hover { background: var(--bg); }
.engagement-row.active {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
.engagement-row .er-target {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  word-break: break-all;
}
.engagement-row .er-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
}

.engagement-detail {
  min-height: 400px;
}

.engagement-detail .ed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.engagement-detail .ed-target {
  font-family: var(--mono);
  font-size: 16px;
}
.engagement-detail .ed-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  display: flex;
  gap: 16px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 16px 0;
}
.summary-cell {
  border: 1px solid var(--line);
  background: var(--c-white);
  padding: 12px;
  border-radius: var(--radius);
}
.summary-cell .sc-num {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.summary-cell .sc-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Findings table ─────────────────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 24px 0 12px;
}
.section-head h3 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.filter-bar {
  display: flex;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.filter-bar a {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-2);
}
.filter-bar a:hover { color: var(--fg); }
.filter-bar a.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.findings-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.findings-table th, .findings-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.findings-table th {
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-2);
}
.findings-table tr.f-row { cursor: pointer; transition: background 120ms; }
.findings-table tr.f-row:hover { background: var(--c-white); }
.f-sev {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--sev-info);
  color: var(--c-white);
}
.f-sev.critical { background: var(--sev-critical); }
.f-sev.high { background: var(--sev-high); }
.f-sev.medium { background: var(--sev-medium); }
.f-sev.low { background: var(--sev-low); }
.f-confirmed {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
}

/* ─── Chain viz ──────────────────────────────────────────────────────── */

.chain-viz {
  margin: 24px 0;
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--c-white);
  border-radius: var(--radius);
}
.chain-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0;
  position: relative;
}
.chain-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 36px;
  bottom: -8px;
  width: 1px;
  background: var(--line-strong);
}
.chain-step .cs-marker {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--fg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
}
.chain-step .cs-body { flex: 1; }
.chain-step .cs-title { font-family: var(--mono); font-size: 13px; }
.chain-step .cs-desc { color: var(--fg-2); font-size: 12px; margin-top: 4px; }

/* ─── Agent timeline ─────────────────────────────────────────────────── */

.timeline {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--c-white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
}
.timeline-row {
  display: grid;
  grid-template-columns: 80px 100px 1fr;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.timeline-row:last-child { border-bottom: none; }
.timeline-row .tl-time { color: var(--fg-2); }
.timeline-row .tl-agent { color: var(--fg); }
.timeline-row .tl-msg { color: var(--fg); word-break: break-word; }

/* ─── Grid (agents/tools tab) ─────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  border: 1px solid var(--line);
  background: var(--c-white);
  padding: 16px;
  border-radius: var(--radius);
}
.card .c-name {
  font-family: var(--mono);
  font-size: 14px;
  margin-bottom: 4px;
}
.card .c-desc { color: var(--fg-2); font-size: 13px; }
.card .c-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  margin-top: 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-2);
}

/* ─── Modal ──────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 36, 36, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: min(720px, 100%);
  max-height: 80vh;
  overflow: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 500; }
.modal-body { padding: 20px; font-family: var(--mono); font-size: 12px; }
.modal-body dt { color: var(--fg-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 12px; }
.modal-body dt:first-child { margin-top: 0; }
.modal-body dd { margin: 4px 0 0; word-break: break-word; }
.modal-body pre {
  background: var(--c-white);
  border: 1px solid var(--line);
  padding: 12px;
  margin: 8px 0 0;
  font-size: 11px;
  overflow-x: auto;
  border-radius: var(--radius);
}

/* ─── Empty / footer ─────────────────────────────────────────────────── */

.empty-state {
  padding: 32px;
  color: var(--fg-2);
  text-align: left;
}
.empty-state.center { text-align: center; padding: 64px 32px; }
.empty-state code { background: var(--c-white); padding: 1px 6px; border-radius: 3px; }

.footer {
  max-width: var(--maxw);
  margin: 32px auto 16px;
  padding: 16px var(--margin);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  border-top: 1px solid var(--line);
}
.footer a:hover { color: var(--fg); }

/* ─── Live indicator pulse ───────────────────────────────────────────── */

.live-pulse {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
  animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
