/* Security Risk Assessment - Pure HTML, CSS, and Vanilla JS */
/* Color tokens */
:root {
  --orange: #f26522;
  --white: #ffffff;
  --bg-dark: #171717;
  --text-dark: #0c0c0c;
  --muted: #9aa0a6;
  --surface-dark: #202020;
  --surface-dark-2: #121212;
  --surface-light: #f4f6f8;
  --border: rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* --- Light theme tokens and surfaces --- */
body[data-theme="light"] {
  /* stronger contrast for borders and muted text in light */
  --border: rgba(0, 0, 0, .12);
  --muted: #5f6368;

  background: #f6f8fa;   /* page chrome */
  color: #111;
}

/* cards */
body[data-theme="light"] .card,
body[data-theme="light"] .question-card,
body[data-theme="light"] .category-tile {
  background: #fff;
  border-color: rgba(0, 0, 0, .12);
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}

/* radar area */
body[data-theme="light"] .radar-wrap {
  background: #fff;
  border-color: rgba(0,0,0,.12);
}

/* category tile headings and small labels */
body[data-theme="light"] .category-tile h4,
body[data-theme="light"] .metric-card h3 {
  color: #333;
}

/* selects in light mode */
body[data-theme="light"] select {
  background: #fff;
  color: #111;
  border-color: rgba(0,0,0,.12);
}

/* progress track for light */
body[data-theme="light"] .progress {
  background: rgba(0,0,0,.06);
}

/* question badge text color in light */
body[data-theme="light"] .category-badge {
  color: #5f6368;
  border-color: rgba(0,0,0,.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Apple Color Emoji, Segoe UI Emoji;
  background: var(--bg-dark);
  color: #eceff1;
}

body[data-theme="light"] {
  background: #ffffff;
  color: #111;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}

.site-header .title-wrap h1 {
  margin: 0 0 6px 0;
  font-size: 34px;
  letter-spacing: .2px;
}

.site-header .title-wrap p { margin: 0; color: var(--muted); }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--orange);
  color: #fff;
  border-color: transparent;
}

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

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.theme-toggle input { display: none; }
.theme-toggle .slider {
  width: 48px;
  height: 26px;
  background: #2b2b2b;
  border-radius: 999px;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08);
}
.theme-toggle .slider::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s ease;
}
.theme-toggle input:checked + .slider::after { left: 25px; }
.theme-toggle .toggle-label { font-size: 12px; color: var(--muted); }

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 10px;
}

.card {
  background: var(--surface-dark);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}

body[data-theme="light"] .card {
  background: var(--surface-light);
  border-color: rgba(0,0,0,.06);
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}

.metric-card .metric-head { margin-bottom: 8px; }
.metric-card h3 { margin: 0; font-size: 16px; color: var(--muted); font-weight: 600; }

.metric-card .metric-body { display: grid; gap: 10px; }
.metric-card .answered { font-size: 40px; font-weight: 700; letter-spacing: .5px; }
.metric-card .answered .total { font-size: 20px; color: var(--muted); }
.metric-card .big-number { font-size: 58px; font-weight: 800; letter-spacing: .5px; }
.metric-card.highlight .big-number { color: var(--orange); }

.progress {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}
body[data-theme="light"] .progress { background: rgba(0,0,0,.06); }
.progress .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #fb8c50);
  width: 0%;
}

.subtext { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .3px;
  border: 1px solid transparent;
  width: max-content;
}
.badge-danger { background: rgba(255, 85, 85, .18); color: #ff8f8f; border-color: rgba(255, 85, 85, .25); }
.badge-warn   { background: rgba(255, 186, 73, .16); color: #ffd38d; border-color: rgba(255, 186, 73, .25); }
.badge-good   { background: rgba(64, 198, 126, .18); color: #90e3b4; border-color: rgba(64, 198, 126, .25); }
.badge-great  { background: rgba(66, 165, 245, .20); color: #a1d1ff; border-color: rgba(66, 165, 245, .25); }

.analysis { margin-top: 26px; }
.analysis h2 { margin: 0 0 6px 0; }
.muted { color: var(--muted); margin-top: 0; }

.radar-wrap {
  display: grid;
  place-items: center;
  background: var(--surface-dark-2);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 16px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.category-tile {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-dark);
  border: 1px solid var(--border);
}
.category-tile h4 { margin: 0 0 8px 0; font-size: 14px; color: #cfd8dc; }
body[data-theme="light"] .category-tile h4 { color: #333; }
.category-tile .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.category-tile .percent {
  font-weight: 800;
  letter-spacing: .2px;
}
.category-tile .progress { height: 8px; margin-top: 6px; }

.questions {
  margin: 26px 0 60px;
  display: grid;
  gap: 12px;
}

.question-card {
  border-radius: 14px;
  background: var(--surface-dark);
  border: 1px solid var(--border);
  padding: 16px;
}
.question-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.q-number {
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.question-card h3 {
  margin: 0;
  font-size: 18px;
}

.question-card .category-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--border);
  padding: 4px 8px;
  border-radius: 999px;
}

.select-wrap {
  position: relative;
}

select {
  width: 100%;
  background: #0f0f0f;
  color: #e6e6e6;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  appearance: none;
  outline: none;
}
body[data-theme="light"] select {
  background: #fff;
  color: #111;
  border-color: rgba(0,0,0,.1);
}

.risk-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.footer { color: var(--muted); }

/* Responsive */
@media (max-width: 920px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .categories-grid { grid-template-columns: 1fr 1fr; }
  .site-header { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}

/* Print styles for the report window are injected from JS for fidelity */
/* For printing the main window, keep it simple */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .theme-toggle, .actions, select, .footer { display: none !important; }
  .card, .category-tile, .question-card { box-shadow: none; border-color: #ddd; }
}
