/* Bagheera Labs / DRIFT Color Scheme */
:root {
  --bg-darkest: #0B1426;
  --bg-dark: #162033;
  --bg-card: #1E3A5F;
  --accent: #00D4AA;
  --accent-dark: #00a88a;
  --text-primary: #E2E8F0;
  --text-muted: #94A3B8;
  --error: #ef4444;
  --error-dark: #450a0a;
  --warning: #f59e0b;
  --info: #3b82f6;
  --vpc-border: #8B5CF6;
  --subnet-public: rgba(0, 212, 170, 0.15);
  --subnet-private: rgba(30, 58, 95, 0.6);

  /* drift-pentest severity palette */
  --sev-critical: #ff4444;
  --sev-high:     #ff7b00;
  --sev-medium:   #d29922;
  --sev-low:      #3fb950;
  --sev-info:     #8b949e;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  background: var(--bg-darkest);
  color: var(--text-primary);
  overflow: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-darkest); }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 4px; }

/* ─── App shell ─── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── Header ─── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--bg-card);
  flex-shrink: 0;
  gap: 16px;
  height: 62px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.header-left { justify-content: flex-start; }

.header-center {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.header-center img { height: 36px; }

.header-right { justify-content: flex-end; }

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

.logo img.bagheera { height: 32px; }

/* Nav links */
nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a:hover { color: var(--text-primary); }
nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── Summary Stats (header right) ─── */
.summary {
  display: flex;
  gap: 14px;
  font-size: 13px;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.pass   { background: var(--accent); }
.dot.fail   { background: var(--error); }
.dot.error  { background: var(--warning); }
.dot.manual { background: var(--info); }
.dot.critical { background: #9B1D20; }
.dot.high     { background: var(--error); }
.dot.medium   { background: var(--warning); }
.dot.low      { background: var(--info); }
.dot.info     { background: #6b7280; }

/* ─── Region Select ─── */
select {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid #2d4a6f;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: Arial, sans-serif;
  font-size: 13px;
  cursor: pointer;
}

select:hover { border-color: var(--accent); }
select:focus { outline: none; border-color: var(--accent); }

/* ─── Tenant Badge ─── */
#tenant-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.tenant-label { color: var(--text-muted); }
.tenant-value { color: var(--accent); font-weight: 600; }

#tenant-badge button {
  background: transparent;
  border: 1px solid var(--bg-card);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: background 0.15s, color 0.15s;
}

#tenant-badge button:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--bg-card);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #000; }

/* ─── Page container ─── */
#page {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.page-view {
  display: none;
  width: 100%;
  height: 100%;
}

.page-view.active { display: flex; flex-direction: column; }

/* ─── Dashboard ─── */
#view-dashboard {
  padding: 32px;
  overflow-y: auto;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.dash-header h1 { font-size: 22px; font-weight: 700; }
.last-scan { font-size: 13px; color: var(--text-muted); }

.dash-posture {
  background: var(--bg-dark);
  border: 1px solid var(--bg-card);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.dash-posture h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

.posture-bar {
  height: 12px;
  border-radius: 6px;
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  margin-bottom: 10px;
}

.bar-pass { background: var(--accent); transition: width 0.5s; }
.bar-fail { background: var(--error); transition: width 0.5s; }

.posture-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-dark);
  border: 1px solid var(--bg-card);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .value.critical { color: #9B1D20; }
.stat-card .value.high     { color: var(--error); }
.stat-card .value.medium   { color: var(--warning); }
.stat-card .value.low      { color: var(--info); }
.stat-card .value.info     { color: var(--text-muted); }

.dash-quicklinks { display: flex; gap: 12px; flex-wrap: wrap; }

/* ─── Tenant Selector ─── */
.tenant-selector {
  max-width: 480px;
  margin: 60px auto;
}

.tenant-selector h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.tenant-selector p  { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.tenant-cards { display: flex; flex-direction: column; gap: 10px; }

.tenant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-dark);
  border: 1px solid var(--bg-card);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: Arial, sans-serif;
  transition: border-color 0.15s, background 0.15s;
}

.tenant-card:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.05);
}

.tenant-name  { font-weight: 600; }
.tenant-arrow { color: var(--accent); font-size: 18px; }

/* ─── Topology view ─── */
#view-topology { flex-direction: row; }

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.diagram {
  flex: 1;
  position: relative;
  background: var(--bg-darkest);
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

#svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Zoom controls */
.controls {
  position: absolute;
  top: 16px;
  right: 376px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.controls button {
  width: 40px;
  height: 40px;
  background: var(--bg-dark);
  border: 1px solid var(--bg-card);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: all 0.2s;
}

.controls button:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

/* Legend */
.legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--bg-dark);
  border: 1px solid var(--bg-card);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 12px;
  z-index: 10;
}

.legend-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.legend-box {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid;
}

.legend-box.pass { background: #0a3d35; border-color: var(--accent); }
.legend-box.fail { background: var(--error-dark); border-color: var(--error); box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ─── Right Panel (topology) ─── */
.panel {
  width: 360px;
  background: var(--bg-dark);
  border-left: 1px solid var(--bg-card);
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel h2 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  border-bottom: 1px solid var(--bg-card);
  padding-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Resource Info */
.resource-info {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #2d4a6f;
}

.resource-info h3 { font-size: 15px; margin-bottom: 6px; }

.resource-info .meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
}

/* Compliance findings (panel) */
.finding {
  background: var(--bg-darkest);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  border-left: 4px solid var(--bg-card);
}

.finding.pass   { border-left-color: var(--accent); }
.finding.fail   { border-left-color: var(--error); background: #1a0f0f; }
.finding.error  { border-left-color: var(--warning); }
.finding.manual { border-left-color: var(--info); }

.finding-id     { font-weight: 700; color: var(--text-primary); }
.finding-name   { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.finding-reason { font-size: 13px; line-height: 1.4; }

/* Pentest findings (panel overlay) */
.finding.pentest-finding { border-left-width: 4px; }
.finding.pentest-finding.critical { border-left-color: #9B1D20; background: rgba(155,29,32,0.1); }
.finding.pentest-finding.high     { border-left-color: var(--error); background: rgba(239,68,68,0.1); }
.finding.pentest-finding.medium   { border-left-color: var(--warning); background: rgba(245,158,11,0.1); }
.finding.pentest-finding.low      { border-left-color: var(--info); background: rgba(59,130,246,0.1); }
.finding.pentest-finding.info     { border-left-color: #6b7280; background: rgba(107,114,128,0.1); }

/* Badges */
.badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  margin-left: 8px;
  font-weight: 700;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.pass     { background: var(--accent); color: #000; }
.badge.fail     { background: var(--error); color: #fff; }
.badge.error    { background: var(--warning); color: #000; }
.badge.manual   { background: var(--info); color: #fff; }
.badge.critical { background: #9B1D20; color: white; }
.badge.high     { background: var(--error); color: white; }
.badge.medium   { background: var(--warning); color: #1a1a1a; }
.badge.low      { background: var(--info); color: white; }
.badge.info     { background: #6b7280; color: white; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin: 12px 0;
  border-bottom: 1px solid var(--bg-card);
}

.tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: Arial, sans-serif;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  display: inline-block;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
}

.tab.active .tab-count {
  background: var(--accent);
  color: var(--bg-darkest);
}

/* ─── Empty & Loading ─── */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 52px; margin-bottom: 16px; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Reports view ─── */
#view-reports { flex-direction: row !important; overflow: hidden; }

.view-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-dark);
  border-right: 1px solid var(--bg-card);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bg-card);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.client-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.year-label {
  padding: 8px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.report-item {
  display: block;
  width: 100%;
  padding: 7px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  font-family: Arial, sans-serif;
  transition: background 0.12s, color 0.12s;
}

.report-item:hover  { background: var(--bg-card); color: var(--text-primary); }
.report-item.active { color: var(--accent); background: rgba(0,212,170,0.08); }

.view-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.report-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Report rendering (rpt-*) ─── */
.rpt-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--bg-card);
}

.rpt-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.rpt-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.rpt-severity-bar { display: flex; gap: 8px; flex-wrap: wrap; }

.sev-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
}

.sev-chip.sev-critical { background: var(--sev-critical); color: #000; }
.sev-chip.sev-high     { background: var(--sev-high);     color: #000; }
.sev-chip.sev-medium   { background: var(--sev-medium);   color: #000; }
.sev-chip.sev-low      { background: var(--sev-low);      color: #000; }
.sev-chip.sev-info     { background: var(--bg-card); color: var(--sev-info); border: 1px solid #2d4a6f; }

.rpt-section { margin-bottom: 28px; }

.rpt-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-card);
}

.rpt-body-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
}

.rpt-findings { display: flex; flex-direction: column; gap: 10px; }

.rpt-finding {
  border: 1px solid var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-dark);
}

.rpt-finding-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #1a2a40;
  cursor: pointer;
  user-select: none;
}

.rpt-finding-header:hover { background: #1f3450; }

.rpt-finding-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpt-cvss        { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.rpt-toggle-caret { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }

.rpt-finding-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--bg-card);
}

.rpt-finding-body.hidden { display: none; }

.rpt-field { display: flex; flex-direction: column; gap: 6px; }

.rpt-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.rpt-assets { display: flex; gap: 6px; flex-wrap: wrap; }

.asset-chip {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid #2d4a6f;
  border-radius: 4px;
  color: var(--text-primary);
  font-family: monospace;
}

.rpt-evidence-grid { display: flex; flex-wrap: wrap; gap: 12px; }

.rpt-evidence-figure {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
}

.rpt-evidence-figure img {
  max-width: 320px;
  max-height: 240px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--bg-card);
  cursor: zoom-in;
  background: #000;
}

.rpt-evidence-figure figcaption {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.rpt-code-block { border: 1px solid var(--bg-card); border-radius: 6px; overflow: hidden; }

.rpt-code-header {
  padding: 5px 12px;
  background: #1a2a40;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg-card);
}

.rpt-code {
  margin: 0;
  padding: 14px 16px;
  background: #080c12;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #cdd6f4;
  white-space: pre;
}

.rpt-refs { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.rpt-refs li::before { content: '↗ '; color: var(--text-muted); font-size: 11px; }
.rpt-refs a { color: var(--accent); font-size: 13px; text-decoration: none; word-break: break-all; }
.rpt-refs a:hover { text-decoration: underline; }

/* Severity badges */
.severity-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 3px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.severity-badge.critical, .sev-critical { background: var(--sev-critical); color: #000; }
.severity-badge.high,     .sev-high     { background: var(--sev-high);     color: #000; }
.severity-badge.medium,   .sev-medium   { background: var(--sev-medium);   color: #000; }
.severity-badge.low,      .sev-low      { background: var(--sev-low);      color: #000; }
.severity-badge.info,     .sev-info     { background: var(--bg-card); color: var(--sev-info); border: 1px solid #2d4a6f; }

/* ─── Lightbox ─── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* ─── Spinner (callback.html) ─── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.status-text { color: var(--text-muted); font-size: 14px; }
.error-text  { color: var(--error); font-size: 14px; max-width: 400px; text-align: center; }
