/* ===========================
   Scaffold UI - Global Styles
   =========================== */

/* CSS Variables */
:root {
  --bg: #0b0d10;
  --fg: #e7eaee;
  --muted: #9aa3ad;
  --card: #12161b;
  --border: #1f2630;
  --accent: #9ec1ff;
  --accent-bright: #b8d4ff;
  --link-hover: #7dd3fc;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.7 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  padding: 0;
}

/* Typography */
h1 {
  font-size: 48px;
  margin-bottom: 24px;
  color: var(--fg);
}

h2 {
  font-size: 32px;
  margin-top: 48px;
  margin-bottom: 16px;
  color: var(--fg);
}

h3 {
  font-size: 24px;
  margin-top: 32px;
  margin-bottom: 12px;
  color: var(--fg);
}

h4 {
  font-size: 18px;
  margin: 0 0 8px 0;
  color: var(--fg);
}

p {
  color: var(--muted);
  margin-bottom: 16px;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

p a,
li a {
  color: var(--accent-bright);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

p a:hover,
li a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
  text-decoration: none;
}

/* Lists */
ul,
ol {
  color: var(--muted);
  margin-bottom: 16px;
  padding-left: 24px;
}

li {
  margin-bottom: 8px;
}

/* Code */
code {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: var(--accent);
}

pre {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--fg);
}

/* Section Dividers */
.section {
  margin-bottom: 48px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* Navigation */
.nav {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 100;
}

.nav a:not(.btn-primary) {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
}

.nav a:not(.btn-primary):hover {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

/* Side Navigation Menu */
scaffold-nav {
  display: contents;
}

.page-layout {
  display: flex;
  min-height: 100vh;
}

.side-nav {
  width: 240px;
  background: var(--card);
  position: relative;
  border-right: 1px solid var(--border);
  padding: 24px;
  flex-shrink: 0;
}

.side-nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('/scaffold-nav-bg.png');
  background-size: 240px auto;
  background-position: center top;
  background-repeat: repeat-y;
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}

.side-nav > * {
  position: relative;
  z-index: 1;
}

.side-nav-header {
  margin-bottom: 32px;
}

.side-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.side-nav-list li {
  margin-bottom: 8px;
}

.side-nav-list a {
  display: block;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s;
  font-size: 14px;
}

.side-nav-list a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
}

.side-nav-list a.active {
  background: linear-gradient(135deg, rgba(158, 193, 255, 0.15) 0%, rgba(125, 211, 252, 0.12) 100%);
  color: var(--accent-bright);
  font-weight: 500;
  box-shadow: 0 0 12px rgba(158, 193, 255, 0.08);
}

.page-content {
  flex: 1;
  padding: 48px 40px;
  max-width: 1200px;
}

.page-content.home-page {
  padding: 32px 60px 56px 80px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 32px;
}

.back-btn:hover {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  text-decoration: none;
}

.card h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.card p {
  margin: 0;
  font-size: 14px;
}

/* Feature Grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.feature-card h4 {
  margin: 0 0 8px 0;
  color: var(--fg);
  font-size: 18px;
}

.feature-card p {
  margin: 0;
  font-size: 14px;
}

/* Callout Boxes */
.callout {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.callout-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout.info {
  border-left-color: #58a6ff;
}

.callout.info .callout-title {
  color: #58a6ff;
}

.callout.warning {
  border-left-color: #f0c346;
}

.callout.warning .callout-title {
  color: #f0c346;
}

.callout.success {
  border-left-color: #56d364;
}

.callout.success .callout-title {
  color: #56d364;
}

/* Layout Containers */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
}

.wrap-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px;
}

.wrap-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

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

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

/* Forms & Inputs */
input[type="text"],
input[type="search"],
select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

button:active {
  transform: scale(0.98);
}

/* Primary Button/Link */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #000;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #bcd3ff;
  text-decoration: none;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

thead {
  background: rgba(255, 255, 255, 0.03);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  user-select: none; /* Prevent text selection when clicking to sort */
}

/* Sortable table headers */
th[data-sort] {
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  position: relative;
}

th[data-sort]:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-bright);
}

th[data-sort].sorted {
  color: var(--accent);
}

th .sort-icon {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 4px;
  display: inline-block;
  min-width: 12px;
}

th[data-sort]:hover .sort-icon {
  opacity: 1;
}

td {
  padding: 12px 16px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Pills */
.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.compliant,
.status-pill.success {
  background: rgba(86, 211, 100, 0.15);
  color: #56d364;
}

.status-pill.non-compliant,
.status-pill.error {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
}

.status-pill.warning {
  background: rgba(240, 195, 70, 0.15);
  color: #f0c346;
}

/* Utility Classes */
.text-center {
  text-align: center;
}

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

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.mt-0 {
  margin-top: 0;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

/* Code Blocks */
.code-block {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.code-block code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.code-block strong {
  color: var(--accent-bright);
}

.code-block ul {
  margin: 8px 0 0 20px;
  padding: 0;
}

/* Subtitle */
.subtitle {
  font-size: 18px;
  color: var(--muted);
  margin-top: -8px;
  margin-bottom: 32px;
}

/* Home Page Hero */
.hero-block {
  max-width: 760px;
  padding: 24px 0 16px;
  margin-left: 40px;
}

.hero-content {
  max-width: 100%;
}

.hero-content h1 {
  font-weight: 700;
  font-size: 42px;
  line-height: 1.1;
  margin-bottom: 40px;
  color: var(--fg);
}

.hero-content .tagline {
  font-size: 20px;
  color: #9ca3af;
  margin-bottom: 24px;
  line-height: 1.5;
}

.hero-content .subtext {
  font-size: 16px;
  color: #6b7280;
  line-height: 1.6;
}

/* How It Works Section */
.how-it-works {
  max-width: 900px;
  margin-left: 40px;
}

.how-it-works h2 {
  text-align: left;
  font-size: 30px;
  font-weight: 700;
  margin: 8px 0 24px;
  color: var(--fg);
}

.how-it-works .lead {
  font-size: 18px;
  color: var(--fg);
  font-weight: 600;
  margin-bottom: 8px;
}

.steps-grid {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.step {
  flex: 1;
  text-align: left;
  padding: 20px 24px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}

.step-number {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(158, 193, 255, 0.12);
  border: 2px solid rgba(158, 193, 255, 0.35);
  border-radius: 50%;
}

.step h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--fg);
}

.step p {
  font-size: 14px;
  color: #9ca3af;
  line-height: 1.6;
  margin: 0;
}

/* Challenge Section */
.challenge {
  max-width: 900px;
  margin-left: 40px;
}

.challenge h2 {
  text-align: left;
  font-size: 30px;
  font-weight: 700;
  margin: 8px 0 16px;
  color: var(--fg);
}

.challenge .lead {
  font-size: 18px;
  color: var(--fg);
  font-weight: 600;
  margin-bottom: 8px;
}

.challenge .challenge-body p {
  margin-bottom: 12px;
}

/* Reports Pages - Shared Styles */
.reports-page .report-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

/* Expand reports pages to use full available width next to the side nav */
.page-content.reports-page {
  max-width: none; /* override the global 1200px cap */
}

.reports-page .badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
}

/* Card radius is already defined globally; keep a subtle bump for reports */
.reports-page .card {
  border-radius: 14px;
}

.reports-page .row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Inputs use global styling; slight tweak to align tone with reports */
.reports-page input,
.reports-page select {
  background: var(--card);
}

.reports-page button {
  background: var(--accent);
  color: #000;
  border: 0;
  border-radius: 10px;
}

.reports-page button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.reports-page th {
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.reports-page .pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.reports-page .pill.eligible { background: #0d3d2a; border-color: #1e7a4d; color: #4ade80; }
.reports-page .pill.active { background: #3d2a0d; border-color: #7a4d1e; color: #fbbf24; }
.reports-page .pill.compliant { background: #0d3d2a; border-color: #1e7a4d; color: #4ade80; }
.reports-page .pill.mismatch { background: #4d1515; border-color: #b91c1c; color: #fca5a5; }

.reports-page .footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
}

/* Report modal (used on model report) */
.reports-page .modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); align-items: center; justify-content: center; z-index: 1000; }
.reports-page .modal.show { display: flex; }
.reports-page .modal-content { background: #1a1d23; padding: 24px; border-radius: 14px; border: 1px solid var(--border); max-width: 400px; }
.reports-page .modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.reports-page .btn-cancel { background: #374151; color: white; }
.reports-page .btn-cancel:hover { background: #4b5563; }

.challenge .symptoms {
  margin: 8px 0 16px 20px;
  padding: 0;
  color: var(--muted);
}

.challenge .symptoms li {
  margin-bottom: 8px;
  line-height: 1.6;
}
