/* ==========================================================================
   OT-Security — Repo-Specific Styles
   Loaded AFTER base.css. Only contains OT-specific overrides and components
   not covered by the shared base stylesheet.
   ========================================================================== */

/* ===== OT-Specific Domain Colors ===== */
:root {
  --domain-network: #0284C7;
  --domain-identity: #7C3AED;
  --domain-remote: #D97706;
  --domain-patch: #DC2626;
  --domain-monitoring: #16A34A;
  --domain-incident: #EF4444;
  --domain-asset: #0891B2;
  --domain-safety: #BE123C;
  --domain-config: #6366F1;
  --domain-supply: #CA8A04;
  --domain-backup: #059669;
  --domain-physical: #78716C;
  --domain-data: #2563EB;

  /* Security Level colors (IEC 62443) */
  --sl1: #64748B;
  --sl2: #2563EB;
  --sl3: #D97706;
  --sl4: #DC2626;

  /* Legacy compat */
  --accent2: #7C3AED;
  --bg-offset: #f8f9fa;
  --mono: var(--font-mono);
}

/* ===== Header (OT-specific dark blue banner) ===== */
.header {
  background: #1E3A8A;
  color: #fff;
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.header-brand { text-decoration: none; color: #fff; }
.header-brand:hover { text-decoration: none; color: #fff; }
.header-brand h1 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.header-subtitle { font-size: 0.75rem; opacity: 0.7; font-weight: 400; }
.header-search { flex: 1; max-width: 400px; }
.header-search input,
#search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}
#search-input::placeholder { color: rgba(255,255,255,0.5); }
#search-input:focus {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

/* ===== Nav (sticky below header) ===== */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 90;
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 0 1.5rem;
  -webkit-overflow-scrolling: touch;
}

/* ===== SL Badges (IEC 62443 Security Levels) ===== */
.badge-sl1 { background: #F1F5F9; color: var(--sl1); }
.badge-sl2 { background: var(--accent-light); color: var(--sl2); }
.badge-sl3 { background: #FEF3C7; color: var(--sl3); }
.badge-sl4 { background: #FEE2E2; color: var(--sl4); }

/* ===== Impact/Severity Badges ===== */
.badge-critical { background: #FEE2E2; color: var(--danger); }
.badge-significant { background: #FEF3C7; color: var(--warning); }
.badge-minor { background: #F1F5F9; color: var(--text-muted); }
.badge-malaysia { background: var(--accent-light); color: var(--accent); }
.badge-preventive { background: #DCFCE7; color: var(--success); }
.badge-detective { background: #EDE9FE; color: var(--accent2); }
.badge-corrective { background: #FEF3C7; color: var(--warning); }

/* ===== Stats Banner ===== */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Control Cards ===== */
.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}
.control-card-link { cursor: pointer; transition: all 0.2s; display: block; }
.control-card-link:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  border-color: var(--accent);
}
.control-card-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.25rem; color: var(--text-primary); }
.control-card-desc { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.6; }
.control-card-meta { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.75rem; }

/* ===== Section Headings ===== */
.page-title { font-size: var(--font-size-xl); font-weight: 700; margin-bottom: 0.25rem; }
.page-sub { font-size: var(--font-size-base); color: var(--text-secondary); margin-bottom: 1.5rem; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
th {
  background: var(--surface-hover);
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

/* SL colour rows (Purdue levels, zone tables) */
.sl-row-1 td:first-child { border-left: 3px solid var(--sl1); }
.sl-row-2 td:first-child { border-left: 3px solid var(--sl2); }
.sl-row-3 td:first-child { border-left: 3px solid var(--sl3); }
.sl-row-4 td:first-child { border-left: 3px solid var(--sl4); }

/* ===== SL Indicator Dots ===== */
.sl-indicator { display: flex; gap: 0.25rem; align-items: center; }
.sl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.sl-dot.active-1 { background: var(--sl1); }
.sl-dot.active-2 { background: var(--sl2); }
.sl-dot.active-3 { background: var(--sl3); }
.sl-dot.active-4 { background: var(--sl4); }

/* ===== Disclaimer ===== */
.disclaimer {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: var(--font-size-sm);
  color: #92400E;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* ===== Sub-tabs (legacy .tabs / .tab-btn compat) ===== */
.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);
}

/* (incident-card styles merged into inline control-card usage) */

/* ===== Attack Chain ===== */
.attack-chain { display: flex; flex-direction: column; gap: 0.5rem; }
.attack-step {
  background: var(--surface-hover);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: var(--font-size-sm);
  border-left: 3px solid var(--accent2);
}
.attack-step strong { color: var(--accent2); }

/* ===== Tag Cloud ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

/* ===== Detail Panel ===== */
.detail-body { font-size: 0.85rem; line-height: 1.6; }

/* ===== Back Link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ===== Risk Item ===== */
.risk-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.risk-item:hover { box-shadow: var(--shadow-lg); }

/* ===== Legacy Accordion (OT-specific style) ===== */
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-size-sm);
  background: var(--surface-hover);
  user-select: none;
}
.accordion-header:hover { background: var(--border); }
.accordion-arrow { font-size: 0.625rem; transition: transform 0.2s; }
.accordion-body { display: none; padding: 0.75rem; }
.accordion-item.open > .accordion-body { display: block; }
.accordion-item.open > .accordion-header .accordion-arrow { transform: rotate(90deg); }

/* Accordion content: hidden by default, shown when .open */
.accordion-content { display: none; padding: 0 1rem 0.75rem; }
.accordion-item.open > .accordion-content { display: block; }

/* Audit-package accordions use aria-expanded pattern */
.accordion-content[role="region"] { display: block; }
.accordion-trigger[aria-expanded="false"] + .accordion-content[role="region"] { display: none; }

/* Chevron indicator */
.chevron { font-size: 0.625rem; transition: transform 0.2s; color: var(--text-muted); }
.accordion-item.open > .accordion-trigger .chevron { transform: rotate(90deg); }

/* ===== Legacy Audit Package Overrides ===== */
.audit-package-section { margin-bottom: 1rem; }
.audit-package-section h3 { margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }

.artifact-link-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.5rem; background: var(--surface); }
.artifact-link-header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.artifact-link-name { font-weight: 600; font-size: var(--font-size-base); }
.artifact-link-meta { font-size: var(--font-size-xs); color: var(--text-muted); margin-bottom: 0.25rem; }
.artifact-link-desc { font-size: var(--font-size-sm); color: var(--text-primary); margin-top: 0.35rem; line-height: 1.5; }
.artifact-link-format { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 0.35rem; }

.evidence-how-to-verify { font-size: var(--font-size-sm); margin-bottom: 0.5rem; line-height: 1.5; }

/* ===== Utility ===== */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .control-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .header-search { max-width: 100%; }
  .nav-inner { padding: 0 0.75rem; }
  .stats-banner { grid-template-columns: repeat(2, 1fr); }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
  :root {
    /* SL colors for dark mode */
    --sl1: #94A3B8;
    --sl2: #60A5FA;
    --sl3: #FBBF24;
    --sl4: #F87171;

    --accent2: #A78BFA;
    --bg-offset: var(--surface);
  }

  .header {
    background: #0F172A;
  }

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

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

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

  .badge-sl1 { background: rgba(148,163,184,0.15); }
  .badge-sl2 { background: rgba(96,165,250,0.15); }
  .badge-sl3 { background: rgba(251,191,36,0.15); }
  .badge-sl4 { background: rgba(248,113,113,0.15); }
  .badge-critical { background: rgba(248,113,113,0.15); }
  .badge-significant { background: rgba(251,191,36,0.15); }
  .badge-minor { background: rgba(148,163,184,0.15); }
  .badge-malaysia { background: rgba(96,165,250,0.15); }
  .badge-preventive { background: rgba(52,211,153,0.15); }
  .badge-detective { background: rgba(167,139,250,0.15); }
  .badge-corrective { background: rgba(251,191,36,0.15); }

  .disclaimer {
    background: rgba(251,191,36,0.1);
    border-color: rgba(251,191,36,0.3);
    color: #FBBF24;
  }

  .attack-step {
    background: var(--surface);
    border-left-color: var(--accent2);
  }

  .attack-step strong { color: var(--accent2); }

  .tag {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-muted);
  }

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

/* ===== PRINT ===== */
@media print {
  header { position: static; }
  .search-container, nav { display: none; }
  .tab-panel { display: block !important; }
  .risk-card, .control-card { break-inside: avoid; }
}
