/* === AI Governance Explorer — Repo-Specific Styles ===
   Base tokens, components, and dark mode are in base.css.
   This file contains ONLY AI-Governance-specific overrides and components. */

/* === AI-Governance Custom Tokens === */
:root {
  --card: var(--surface);
  --accent-dark: #1E3A8A;
  --accent-darker: #172554;
  --success-bg: var(--success-light);
  --warning-bg: var(--warning-light);
  --danger-bg: var(--danger-light);
  --info-bg: var(--info-light);
  --purple: #7C3AED;
  --purple-bg: #F5F3FF;
  --radius-lg: 12px;
  --shadow-md: var(--shadow-lg);
  --mono: var(--font-mono);
  --font: var(--font-sans);
}

/* === Header (AI-Gov branded dark header) === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--accent-dark);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.header-brand {
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.header-brand:hover { text-decoration: none; color: #fff; }

.header-brand h1 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.header-subtitle {
  font-size: var(--font-size-xs);
  opacity: 0.7;
  font-weight: 400;
}

.header-search {
  flex: 1;
  max-width: 400px;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}

.header-search input::placeholder { color: rgba(255,255,255,0.5); }
.header-search input:focus {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

/* === Navigation (sticky below branded header) === */
.nav {
  position: sticky;
  top: 52px;
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-link {
  padding: 0.75rem 1rem;
  border-bottom: 2px solid transparent;
}

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

/* === Main Content Container === */
.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem;
}

/* === AI-Governance Specific Badges === */
.badge-tier1 { background: var(--accent-light); color: var(--accent); }
.badge-tier2 { background: #F1F5F9; color: var(--text-secondary); }
.badge-binding { background: var(--danger-light); color: var(--danger); }
.badge-voluntary { background: var(--success-light); color: var(--success); }
.badge-proposed { background: var(--warning-light); color: var(--warning); }
.badge-home { background: #FEF3C7; color: #92400E; }
.badge-type { background: var(--purple-bg); color: var(--purple); }
.badge-preventive { background: var(--success-light); color: var(--success); }
.badge-detective { background: var(--info-light); color: var(--info); }
.badge-corrective { background: var(--warning-light); color: var(--warning); }
.badge-governance { background: var(--purple-bg); color: var(--purple); }
.badge-process { background: var(--info-light); color: var(--info); }
.badge-technology { background: var(--success-light); color: var(--success); }
.badge-constructed { background: var(--warning-light); color: var(--warning); font-style: italic; cursor: help; }
.badge-jurisdiction { background: #F0FDF4; color: #166534; }

/* === Cards (AI-Gov specific -- extends base surface) === */
.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.control-card:hover { box-shadow: var(--shadow-lg); }

.control-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.control-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.control-card-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 0.125rem;
}

.control-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.control-card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* === Clause List (gold-standard controls landing pattern) === */
.clause-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.clause-list li {
  border-bottom: 1px solid var(--border);
}

.clause-list li:last-child { border-bottom: none; }

.clause-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.25rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.clause-link:hover {
  background: var(--surface-hover);
}

.clause-title {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

/* === Grid Layouts === */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

/* === Stats Banner === */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* === Section Headers === */
.section-header { margin-bottom: 1rem; }

.page-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.page-sub {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

/* === Detail Views (framework detail, etc.) === */
.detail-header { margin-bottom: 1.5rem; }

.detail-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.detail-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* === Lists === */
.item-list { list-style: none; }

.item-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.item-list li:last-child { border-bottom: none; }

.item-list li::before {
  content: '\2192';
  color: var(--accent);
  margin-right: 0.5rem;
  font-weight: 600;
}

/* === Mapping / Data Tables === */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.mapping-table th {
  background: var(--bg);
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mapping-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.mapping-table tr:hover td { background: var(--surface-hover); }
.mapping-table a { color: var(--accent); text-decoration: none; }
.mapping-table a:hover { text-decoration: underline; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-table th {
  background: var(--bg);
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.data-table tr:hover td { background: var(--surface-hover); }
.data-table a { color: var(--accent); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* === Principle Cards (NGAIGE specific) === */
.principle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  border-left: 4px solid var(--accent);
}

.principle-number {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.principle-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.principle-definition {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.75rem;
}

/* === Legacy Tabs (used in some sub-views) === */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.625rem 1rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--accent); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === Accordion (legacy open/chevron pattern — extends base accordion) === */
.chevron {
  transition: transform 0.2s;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.accordion-item.open .chevron { transform: rotate(90deg); }
.accordion-item.open .accordion-content { display: block; }

.accordion-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  background: var(--surface);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
}

.accordion-header:hover { background: var(--surface-hover); }

.accordion-title {
  font-weight: 600;
  font-size: var(--font-size-base);
}

.accordion-body {
  display: none;
  padding: 0 1rem 1rem;
}

.accordion-item.open > .accordion-header > .accordion-icon {
  transform: rotate(90deg);
}

.accordion-item.open > .accordion-body { display: block; }

.audit-gaps-list li::before {
  content: '!';
  color: var(--warning);
}

/* === Search Results === */
.search-result {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child { border-bottom: none; }

.search-result-type {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.search-result-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.search-result-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.search-result-title a:hover { color: var(--accent); }

.search-result-excerpt {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.search-result-excerpt mark {
  background: #FEF3C7;
  padding: 0 0.125rem;
  border-radius: 2px;
}

/* === Framework Color Accents === */
.fw-my { border-left-color: #DC2626; }
.fw-eu { border-left-color: #1D4ED8; }
.fw-us { border-left-color: #059669; }
.fw-intl { border-left-color: #7C3AED; }
.fw-sg { border-left-color: #D97706; }
.fw-cn { border-left-color: #DC2626; }
.fw-uk { border-left-color: #0284C7; }
.fw-ca { border-left-color: #DC2626; }

/* === Coverage Matrix / Risk Taxonomy === */
.coverage-cell {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
}

.coverage-full { background: var(--success-light); color: var(--success); }
.coverage-partial { background: var(--warning-light); color: var(--warning); }
.coverage-none { background: #F1F5F9; color: var(--text-muted); }

.coverage-table th.coverage-th,
.coverage-table td.coverage-td {
  text-align: center;
  width: 100px;
  min-width: 80px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cov-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: default;
}

.cov-strong { background: #DCFCE7; color: #166534; }
.cov-moderate { background: #FEF3C7; color: #92400E; }
.cov-weak { background: #FEE2E2; color: #991B1B; }
.cov-none { background: #F1F5F9; color: #94A3B8; }

.risk-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.risk-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.coverage-notes {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.coverage-note {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.data-table .coverage-td { text-align: center; padding: 0.5rem; }
.data-table .coverage-th { text-align: center; font-size: var(--font-size-xs); }

/* === Risk Matrix Table === */
.matrix-table { border-collapse: collapse; width: 100%; }

.risk-matrix-cell {
  min-width: 56px;
  text-align: center;
  padding: 0.625rem 0.5rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.risk-matrix-header {
  font-weight: 600;
  background: var(--bg);
  padding: 0.625rem 0.5rem;
  text-align: center;
  font-size: var(--font-size-xs);
}

.risk-matrix-label {
  font-weight: 600;
  font-size: var(--font-size-xs);
  padding: 0.625rem 0.75rem;
  white-space: nowrap;
}

/* === Comparison Matrix === */
.comparison-matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.comparison-matrix-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.comparison-matrix-table th,
.comparison-matrix-table td {
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.cm-dimension-header {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  min-width: 130px;
  border-right: 2px solid var(--border);
}

.cm-fw-header {
  background: var(--bg);
  padding: 0.75rem 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  min-width: 150px;
  border-right: 1px solid var(--border);
}

.cm-fw-header:last-child { border-right: none; }
.cm-fw-header a { color: var(--accent); text-decoration: none; }
.cm-fw-header a:hover { text-decoration: underline; }

.cm-fw-jurisdiction {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.cm-dimension-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-primary);
  border-right: 2px solid var(--border);
  min-width: 130px;
}

.cm-dimension-name { font-size: var(--font-size-sm); font-weight: 600; }

.cm-cell {
  padding: 0.625rem 0.75rem;
  border-right: 1px solid var(--border);
  min-width: 150px;
}

.cm-cell:last-child { border-right: none; }

.cm-cell.cm-strong { background: var(--success-light); }
.cm-cell.cm-partial { background: var(--warning-light); }
.cm-cell.cm-none { background: var(--bg); }

.cm-indicator-row { margin-bottom: 0.375rem; }

.cm-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.cm-indicator.cm-strong { color: var(--success); }
.cm-indicator.cm-partial { color: var(--warning); }
.cm-indicator.cm-none { color: var(--text-muted); }

.cm-cell-summary {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

.cm-legend {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.25rem;
}

.cm-legend.cm-strong { background: var(--success); }
.cm-legend.cm-partial { background: var(--warning); }
.cm-legend.cm-none { background: var(--text-muted); }

.cm-summary-bar {
  display: flex;
  height: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  gap: 2px;
}

.cm-summary-segment { min-width: 4px; border-radius: 2px; }
.cm-summary-segment.cm-strong { background: var(--success); }
.cm-summary-segment.cm-partial { background: var(--warning); }
.cm-summary-segment.cm-none { background: var(--border); }

.cm-summary-counts {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: var(--font-size-xs);
}

.cm-count { font-weight: 500; }
.cm-count.cm-strong { color: var(--success); }
.cm-count.cm-partial { color: var(--warning); }
.cm-count.cm-none { color: var(--text-muted); }

/* === Dark Mode — AI-Governance-specific overrides ===
   Base dark mode tokens are in base.css.
   These are repo-specific component overrides for dark mode. */
@media (prefers-color-scheme: dark) {
  :root {
    --card: var(--surface);
    --accent-dark: #6366F1;
    --accent-darker: #4F46E5;
    --purple: #A78BFA;
    --purple-bg: rgba(167,139,250,0.12);
  }

  .header {
    background: #0f0f23;
    border-bottom-color: var(--border);
  }

  .header-search input {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
  }

  .header-search input:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.3);
  }

  .badge-tier2 { background: var(--surface-hover); color: var(--text-secondary); }
  .badge-home { background: rgba(251,191,36,0.15); color: #FBBF24; }
  .badge-jurisdiction { background: rgba(74,222,128,0.12); color: var(--success); }

  .coverage-none { background: var(--surface-hover); color: var(--text-muted); }
  .cov-strong { background: rgba(22,101,52,0.3); color: var(--success); }
  .cov-moderate { background: rgba(146,64,14,0.3); color: var(--warning); }
  .cov-weak { background: rgba(153,27,27,0.3); color: var(--danger); }
  .cov-none { background: var(--surface-hover); color: var(--text-muted); }

  .mapping-table tr:hover td,
  .data-table tr:hover td {
    background: rgba(255,255,255,0.03);
  }

  .search-result-excerpt mark {
    background: rgba(251,191,36,0.25);
    color: #FBBF24;
  }

  .cm-cell.cm-strong { background: rgba(74,222,128,0.08); }
  .cm-cell.cm-partial { background: rgba(251,191,36,0.08); }
  .cm-cell.cm-none { background: rgba(255,255,255,0.02); }
  .cm-dimension-cell { background: var(--surface); }
  .cm-dimension-header { background: var(--bg); }

  /* Framework color accents — brighter for dark bg */
  .fw-my { border-left-color: #F87171; }
  .fw-eu { border-left-color: #818CF8; }
  .fw-us { border-left-color: #34D399; }
  .fw-intl { border-left-color: #A78BFA; }
  .fw-sg { border-left-color: #FBBF24; }
  .fw-cn { border-left-color: #F87171; }
  .fw-uk { border-left-color: #38BDF8; }
  .fw-ca { border-left-color: #F87171; }
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .header-search {
    max-width: 100%;
    width: 100%;
  }

  .nav { top: 88px; }
  .main { padding: 1rem; }
  .control-grid, .grid-4 { grid-template-columns: 1fr; }
  .stats-banner { grid-template-columns: repeat(2, 1fr); }
  .detail-title { font-size: var(--font-size-lg); }
}

@media (max-width: 480px) {
  .stats-banner { grid-template-columns: 1fr; }
  .header-brand h1 { font-size: var(--font-size-md); }
}

/* === Print === */
@media print {
  .header, .nav, .header-search { display: none; }
  .main { max-width: 100%; padding: 0; }
  .control-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
