/* Security Reports - Modern Design System */

:root {
  /* Modern Color Palette - WCAG Compliant */
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --success-light: #10b981;
  --warning: #d97706;
  --warning-light: #f59e0b;
  --danger: #dc2626;
  --danger-light: #ef4444;
  --info: #0891b2;
  --info-light: #06b6d4;
  
  /* Neutral Colors */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Risk Level Colors - Subtle Tints with Readable Text */
  --risk-high-bg: #fef2f2;
  --risk-high-border: #fecaca;
  --risk-high-text: #dc2626;
  --risk-medium-bg: #fffbeb;
  --risk-medium-border: #fed7aa;
  --risk-medium-text: #d97706;
  --risk-low-bg: #f0fdf4;
  --risk-low-border: #bbf7d0;
  --risk-low-text: #059669;
  --risk-info-bg: #eff6ff;
  --risk-info-border: #bfdbfe;
  --risk-info-text: #0891b2;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Base Typography */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--gray-800);
}

/* Base text color for security reports - no !important to allow overrides */
.security-reports-page {
  color: var(--gray-800);
}

/* Ensure proper contrast for general text elements */
.security-reports-page p,
.security-reports-page li,
.security-reports-page span,
.security-reports-page div,
.security-reports-page h1,
.security-reports-page h2,
.security-reports-page h3,
.security-reports-page h4,
.security-reports-page h5,
.security-reports-page h6 {
  color: var(--gray-800);
}

/* Hero Section - Consistent with main site design */
.hero-section {
  background: linear-gradient(135deg, #ded3d1 0%, #f4f4f4 100%);
  position: relative;
  overflow: hidden;
  padding: 5rem 0;
}

.hero-section .display-4 {
  color: #333;
  font-weight: 700;
}

.hero-section .lead {
  color: #495057;
}

.hero-section .btn-primary {
  background-color: #333;
  border-color: #333;
  color: #fff;
  transition: all 0.3s ease;
}

.hero-section .btn-primary:hover {
  background-color: #495057;
  border-color: #495057;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.1;
}

/* Service Card - Consistent with main site design */
.service-card {
  padding: 2rem;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  background-color: #ffffff;
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Service Icons */
.service-icon {
  font-size: 2rem;
  color: #007BFF;
  margin-bottom: 10px;
}

/* Responsive adjustments for hero and service cards */
@media (max-width: 768px) {
  .hero-section {
    padding: 3rem 0;
  }
  
  .hero-section .display-4 {
    font-size: 2rem;
  }
  
  .service-card {
    padding: 1.5rem;
  }
}

/* Modern Table of Contents */
.toc {
  position: sticky;
  top: 20px; /* Reduced from 100px to allow more scrolling */
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: all 0.2s ease;
  max-height: calc(100vh - 100px); /* Adjusted for new top value */
  overflow-y: auto;
  /* Ensure smooth scrolling */
  scroll-behavior: smooth;
  /* Prevent horizontal overflow */
  overflow-x: hidden;
  /* Better mobile touch scrolling */
  -webkit-overflow-scrolling: touch;
  /* Ensure proper positioning context */
  position: -webkit-sticky;
  position: sticky;
}

.toc:hover {
  box-shadow: var(--shadow-lg);
}

.toc h4 {
  margin-bottom: var(--spacing-lg);
  color: var(--gray-800);
  font-weight: 600;
  font-size: var(--font-size-lg);
  border-bottom: 2px solid var(--primary);
  padding-bottom: var(--spacing-sm);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
  padding-top: var(--spacing-sm);
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin-bottom: var(--spacing-sm);
}

.toc a {
  color: var(--gray-600);
  text-decoration: none;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
  border: 1px solid transparent;
}

.toc a:hover {
  background: var(--gray-100);
  color: var(--primary);
  text-decoration: none;
  transform: translateX(4px);
  border-color: var(--gray-300);
}

.toc a.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

.toc a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-dark);
}

.toc a i {
  margin-right: var(--spacing-sm);
  font-size: 1.1em;
  transition: transform 0.2s ease;
}

.toc a:hover i {
  transform: scale(1.1);
}

/* Prevent heading hidden under sticky bar */
[role="region"] { 
  scroll-margin-top: 96px; /* tune to match header height */
}

.toc a.active { 
  font-weight: 600; 
  text-decoration: underline; 
}

/* Ensure scroll works properly */
html, body {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) { 
  html { 
    scroll-behavior: auto; 
  }
}

/* Modern Report Cards */
.report-card {
  transition: all 0.3s ease;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-xl);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: white;
}

.report-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Simplified Card Headers */
.card-header {
  background: var(--gray-50) !important;
  border-bottom: 1px solid var(--gray-200) !important;
  padding: var(--spacing-lg) var(--spacing-xl) !important;
}

.card-header h5 {
  color: var(--gray-800) !important;
  font-weight: 600;
  margin: 0;
  font-size: var(--font-size-xl);
}

.card-header i {
  color: var(--primary);
}

/* Modern Grade Badges */
.grade-badge {
  font-size: var(--font-size-xl);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-2xl);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.grade-badge:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.grade-badge--a {
  background: var(--risk-low-bg);
  color: var(--risk-low-text);
  border-color: var(--risk-low-border);
}

.grade-badge--b {
  background: var(--risk-low-bg);
  color: var(--risk-low-text);
  border-color: var(--risk-low-border);
}

.grade-badge--b-minus {
  background: var(--risk-low-bg);
  color: var(--risk-low-text);
  border-color: var(--risk-low-border);
}

.grade-badge--c {
  background: var(--risk-medium-bg);
  color: var(--risk-medium-text);
  border-color: var(--risk-medium-border);
}

.grade-badge--c-plus {
  background: var(--risk-medium-bg);
  color: var(--risk-medium-text);
  border-color: var(--risk-medium-border);
}

.grade-badge--d {
  background: var(--risk-medium-bg);
  color: var(--risk-medium-text);
  border-color: var(--risk-medium-border);
}

.grade-badge--f {
  background: var(--risk-high-bg);
  color: var(--risk-high-text);
  border-color: var(--risk-high-border);
}

/* Modern Risk Findings - Clean, Namespaced Approach */
#security-reports .finding-item {
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  border-radius: var(--radius-lg);
  border: 1px solid #e6e6e6;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  color: var(--gray-800);
}

#security-reports .finding-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Risk Level Styling - Clean and Isolated */
#security-reports .finding-item.risk-high {
  border-left-color: var(--risk-high-border);
  color: var(--risk-high-text);
  background: var(--risk-high-bg);
}

#security-reports .finding-item.risk-medium {
  border-left-color: var(--risk-medium-border);
  color: var(--risk-medium-text);
  background: var(--risk-medium-bg);
}

#security-reports .finding-item.risk-low {
  border-left-color: var(--risk-low-border);
  color: var(--risk-low-text);
  background: var(--risk-low-bg);
}

/* Ensure nested text elements don't inherit unwanted colors */
#security-reports .finding-item h3,
#security-reports .finding-item h4,
#security-reports .finding-item h5,
#security-reports .finding-item h6,
#security-reports .finding-item p,
#security-reports .finding-item li,
#security-reports .finding-item span,
#security-reports .finding-item div,
#security-reports .finding-item strong,
#security-reports .finding-item em,
#security-reports .finding-item code,
#security-reports .finding-item a {
  color: inherit;
}

/* Footer Styling - Clean and Namespaced */
#security-reports .finding-item.risk-high .owasp-footer {
  background: #dc3545;
  color: white;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  border-radius: 0.375rem;
  border: none;
}

#security-reports .finding-item.risk-high .owasp-footer * {
  color: white;
}

#security-reports .finding-item.risk-high .owasp-footer a {
  color: white;
  text-decoration: underline;
}

#security-reports .finding-item.risk-high .owasp-footer a:hover {
  color: #f3f4f6;
  text-decoration: none;
}

#security-reports .finding-item.risk-medium .owasp-footer {
  background: #d97706;
  color: white;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  border-radius: 0.375rem;
  border: none;
}

#security-reports .finding-item.risk-medium .owasp-footer * {
  color: white;
}

#security-reports .finding-item.risk-medium .owasp-footer a {
  color: white;
  text-decoration: underline;
}

#security-reports .finding-item.risk-medium .owasp-footer a:hover {
  color: #f3f4f6;
  text-decoration: none;
}

#security-reports .finding-item.risk-low .owasp-footer {
  background: #059669;
  color: white;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  border-radius: 0.375rem;
  border: none;
}

#security-reports .finding-item.risk-low .owasp-footer * {
  color: white;
}

#security-reports .finding-item.risk-low .owasp-footer a {
  color: white;
  text-decoration: underline;
}

#security-reports .finding-item.risk-low .owasp-footer a:hover {
  color: #f3f4f6;
  text-decoration: none;
}

#security-reports .finding-item.risk-info {
  border-left-color: var(--info);
  color: var(--risk-info-text);
}

/* Modern Executive Summary */
.executive-summary {
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  color: var(--gray-800);
  padding: var(--spacing-xl);
  border-radius: var(--radius-xl);
  margin-bottom: var(--spacing-xl);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.executive-summary h6 {
  color: var(--gray-800);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-lg);
}

.executive-summary p {
  font-size: var(--font-size-base);
  line-height: 1.7;
  margin: 0;
  color: var(--gray-800) !important;
}

/* Enhanced text contrast and readability */
.executive-summary * {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for all text elements */
.executive-summary h6,
.executive-summary p,
.executive-summary li,
.executive-summary span {
  color: var(--gray-800) !important;
}

/* Modern Section Headers */
.section-header {
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  font-weight: 600;
  color: var(--gray-800);
  position: relative;
  font-size: var(--font-size-lg);
}

.section-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.section-header.text-danger::after {
  background: var(--danger);
}

.section-header.text-warning::after {
  background: var(--warning);
}

.section-header.text-success::after {
  background: var(--success);
}

.section-header.text-info::after {
  background: var(--info);
}

/* Modern Tables */
.port-table {
  font-size: var(--font-size-sm);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.port-table th {
  background-color: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  padding: var(--spacing-md);
}

.port-table td {
  vertical-align: middle;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--gray-100);
}

.port-table tr:hover {
  background-color: var(--gray-50);
}

.port-table code {
  background: var(--gray-100);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--gray-700);
}

/* Modern Buttons - Complete Redesign */
.btn {
  border-radius: var(--radius-md);
  font-weight: 600;
  padding: var(--spacing-sm) var(--spacing-lg);
  transition: all 0.2s ease;
  border: 2px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Primary Button - Solid Blue */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  border-color: var(--primary-dark);
}

/* Secondary Button - White with Blue Border */
.btn-secondary {
  background: white;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Outline Primary - Transparent with Blue Border */
.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Outline Secondary - Transparent with Grey Border */
.btn-outline-secondary {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-400);
}

.btn-outline-secondary:hover {
  background: var(--gray-600);
  color: white;
  border-color: var(--gray-600);
}

/* Success Button */
.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
  color: white;
  border-color: var(--success);
}

.btn-success:hover {
  background: linear-gradient(135deg, var(--success) 0%, var(--success) 100%);
  color: white;
  border-color: var(--success);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger) 100%);
  color: white;
  border-color: var(--danger);
}

/* Info Button */
.btn-info {
  background: linear-gradient(135deg, var(--info) 0%, var(--info-light) 100%);
  color: white;
  border-color: var(--info);
}

.btn-info:hover {
  background: linear-gradient(135deg, var(--info) 0%, var(--info) 100%);
  color: white;
  border-color: var(--info);
}

/* Small Button Variant */
.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
}

/* Large Button Variant */
.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-lg);
}

/* Button with Icon */
.btn i {
  font-size: 1em;
  transition: transform 0.2s ease;
}

.btn:hover i {
  transform: translateX(2px);
}

/* Disabled State */
.btn:disabled,
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Button Groups */
.btn-group {
  display: inline-flex;
  gap: var(--spacing-xs);
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.btn-group .btn:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

/* Navigation Button Container */
.nav-buttons {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .nav-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Modern Alerts */
.alert {
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  padding: var(--spacing-lg);
}

.alert-info {
  background-color: var(--risk-info-bg);
  border-color: var(--risk-info-border);
  color: var(--risk-info-text);
}

/* Ensure proper text colors for Bootstrap text utilities */
.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-info {
  color: var(--info) !important;
}

.text-muted {
  color: var(--gray-600) !important;
}

/* Ensure proper contrast for text in light backgrounds */
.bg-light {
  color: var(--gray-800) !important;
}

.bg-light h6,
.bg-light p,
.bg-light li {
  color: var(--gray-800) !important;
}

/* Improve readability for alert content */
.alert-info h6,
.alert-info p,
.alert-info li,
.alert-info strong {
  color: var(--gray-800) !important;
}

.alert-info .text-danger,
.alert-info .text-warning,
.alert-info .text-success,
.alert-info .text-info {
  color: inherit !important;
}

/* External Links */
.external-links {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
}

.external-links .mb-2 {
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: var(--spacing-sm);
}

.external-links .mb-2:last-child {
  border-bottom: none;
}

.external-links small {
  font-size: var(--font-size-sm);
  line-height: 1.4;
  color: var(--gray-600);
}

.external-links .btn {
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
}

/* Assessment Details and Client Responses */
.assessment-details .card,
.client-responses .card {
  border-left: 4px solid var(--info);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.client-responses .border-start {
  border-color: var(--info) !important;
  border-width: 3px !important;
}

.client-responses p {
  font-style: italic;
  color: var(--gray-600);
}

/* Recommendations */
.alert-info ul {
  padding-left: var(--spacing-lg);
  margin-bottom: 0;
}

.alert-info li {
  margin-bottom: var(--spacing-sm);
  line-height: 1.6;
}

/* Enhanced readability for all text elements */
p, li, span, div {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for all text in the security reports */
.report-card,
.card-body,
.collapsible-content {
  color: var(--gray-800) !important;
}

.report-card p,
.report-card li,
.report-card span,
.report-card div,
.card-body p,
.card-body li,
.card-body span,
.card-body div,
.collapsible-content p,
.collapsible-content li,
.collapsible-content span,
.collapsible-content div {
  color: var(--gray-800) !important;
}

/* Improve contrast for section headers */
.section-header {
  color: var(--gray-800) !important;
}

/* Ensure proper text colors in timeline matrix */
.bg-light .text-danger,
.bg-light .text-warning,
.bg-light .text-success,
.bg-light .text-info {
  color: inherit !important;
}

/* Additional text color improvements for better readability */
.text-center {
  color: var(--gray-800) !important;
}

.text-center * {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for all text in the security reports */
.list-group-item {
  color: var(--gray-800) !important;
}

.table td,
.table th {
  color: var(--gray-800) !important;
}

/* Improve readability for specific content areas */
.alert-heading {
  color: var(--gray-800) !important;
}

.alert-heading * {
  color: var(--gray-800) !important;
}

/* Enhanced timeline matrix readability */
.bg-light.rounded {
  color: var(--gray-800) !important;
}

.bg-light.rounded * {
  color: var(--gray-800) !important;
}

.bg-light.rounded h6,
.bg-light.rounded p,
.bg-light.rounded li,
.bg-light.rounded span {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for timeline headers */
.bg-light.rounded .text-danger,
.bg-light.rounded .text-warning,
.bg-light.rounded .text-success,
.bg-light.rounded .text-info {
  color: inherit !important;
}

/* Improve badge readability */
.badge {
  color: white !important;
  font-weight: 600;
}

/* Ensure proper text colors in finding items */
.finding-item p,
.finding-item li,
.finding-item span {
  color: var(--gray-800) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .toc {
    position: sticky;
    top: 15px; /* Slightly lower on mobile for better visibility */
    margin-bottom: var(--spacing-md);
    max-height: calc(100vh - 80px); /* Adjust for mobile viewport */
    z-index: 1001; /* Ensure it's above other mobile elements */
  }
  
  .grade-badge {
    font-size: var(--font-size-lg);
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .finding-item {
    padding: var(--spacing-md);
  }
  
  .executive-summary {
    padding: var(--spacing-lg);
  }
  
  .card-header {
    padding: var(--spacing-md) !important;
  }
  
  .section-header {
    font-size: var(--font-size-base);
  }
}

/* Loading States */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-2xl);
  color: var(--gray-500);
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus States */
.finding-item:focus,
.grade-badge:focus,
.toc a:focus,
.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Collapsible Sections */
.collapsible-section {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-md);
  overflow: hidden;
  transition: all 0.2s ease;
  background: var(--gray-50);
  position: relative;
  animation: sectionPulse 2s ease-in-out infinite;
}

.collapsible-section:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  animation: none;
}

.collapsible-section::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.collapsible-section:hover::before {
  opacity: 1;
}

.collapsible-header {
  padding: var(--spacing-md);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
}

.collapsible-header:hover {
  background: var(--gray-50);
}

.collapsible-header:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.collapsible-header h6 {
  margin: 0;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  flex: 1;
}

.collapsible-header::after {
  content: "Click to expand";
  position: absolute;
  right: 3rem;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: normal;
  opacity: 0.7;
}

.collapsible-header.active::after {
  content: "Click to collapse";
}

.collapsible-icon {
  transition: transform 0.3s ease;
  color: var(--gray-600);
  font-size: 1.1em;
  margin-left: var(--spacing-sm);
}

.collapsible-header.active .collapsible-icon {
  transform: rotate(90deg);
}

.collapsible-content {
  padding: var(--spacing-lg);
  display: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  background: white;
  color: var(--gray-800) !important;
}

.collapsible-content.active {
  display: block;
  max-height: none;
  padding: var(--spacing-lg);
}

/* Ensure all text in collapsible content is readable */
.collapsible-content * {
  color: var(--gray-800) !important;
}

.collapsible-content p,
.collapsible-content li,
.collapsible-content span,
.collapsible-content div,
.collapsible-content h6 {
  color: var(--gray-800) !important;
}

/* Ensure content is hidden by default */
.collapsible-content:not(.active) {
  display: none !important;
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Smooth transition for content padding */
.collapsible-content.active {
  padding: var(--spacing-lg);
}

/* Expand/Collapse All Buttons */
#expand-all-btn,
#collapse-all-btn {
  transition: all 0.2s ease;
}

#expand-all-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

#collapse-all-btn:hover {
  background: var(--gray-600);
  color: white;
  border-color: var(--gray-600);
}

/* Modern Badges */
.badge {
  border-radius: var(--radius-md);
  font-weight: 500;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-sm);
}

/* Count Badges in Collapsible Headers */
.collapsible-header .badge {
  font-size: 0.75rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-left: var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Risk Level Badge Colors */
.badge.bg-danger {
  background-color: var(--danger) !important;
  color: white;
}

.badge.bg-warning {
  background-color: var(--warning) !important;
  color: white;
}

.badge.bg-success {
  background-color: var(--success) !important;
  color: white;
}

.badge.bg-info {
  background-color: var(--info) !important;
  color: white;
}

/* Improved Collapsible Header Layout */
.collapsible-header h6 {
  margin: 0;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

/* Responsive adjustments for badges */
@media (max-width: 768px) {
  .collapsible-header .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
  }
  
  .collapsible-header h6 {
    font-size: var(--font-size-base);
  }
}

/* Card Body Improvements */
.card-body {
  padding: var(--spacing-xl);
  color: var(--gray-800) !important;
}

/* Ensure all text in card body is readable */
.card-body * {
  color: var(--gray-800) !important;
}

.card-body p,
.card-body li,
.card-body span,
.card-body div,
.card-body h6 {
  color: var(--gray-800) !important;
}

/* Risk Level Headers */
.risk-level-high,
.risk-level-medium,
.risk-level-low,
.risk-level-info {
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.risk-level-high {
  background: var(--risk-high-bg);
  color: var(--risk-high-text);
}

.risk-level-medium {
  background: var(--risk-medium-bg);
  color: var(--risk-medium-text);
}

.risk-level-low {
  background: var(--risk-low-bg);
  color: var(--risk-low-text);
}

.risk-level-info {
  background: var(--risk-info-bg);
  color: var(--risk-info-text);
}

/* Risk Distribution Chart */
.risk-distribution-chart {
  display: flex;
  height: 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 1rem 0;
}

.risk-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  transition: width 0.3s ease;
  min-width: 60px;
}

.risk-bar.high-risk {
  background: var(--risk-high-bg);
}

.risk-bar.medium-risk {
  background: var(--risk-medium-bg);
}

.risk-bar.low-risk {
  background: var(--risk-low-bg);
}

.risk-bar.info-risk {
  background: var(--risk-info-bg);
  color: var(--risk-info-text);
}

.risk-label {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 0.25rem;
}

/* Implementation Details - Base Styling */
.implementation-details {
  background: #ffffff !important; /* Pure white background */
  border: 1px solid #e5e7eb !important;
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1f2937 !important; /* Dark text for readability */
}

.implementation-details code {
  background: #1f2937 !important;
  color: #f9fafb !important;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
}

.implementation-details p,
.implementation-details div,
.implementation-details span,
.implementation-details h6,
.implementation-details strong,
.implementation-details em {
  color: #1f2937 !important;
}

/* Force visibility for all text elements in implementation details */
.implementation-details * {
  color: #1f2937 !important;
}

/* Specific override for any Bootstrap or conflicting styles */
.implementation-details .text-muted,
.implementation-details .text-secondary {
  color: #1f2937 !important;
}

/* High-Specificity Overrides for Risk Levels */
#security-reports .finding-item.risk-high .implementation-details {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #dc3545 !important; /* Red border for High Risk */
  border-left: 4px solid #dc3545 !important;
}

#security-reports .finding-item.risk-high .implementation-details * {
  color: #1f2937 !important;
  -webkit-text-fill-color: #1f2937 !important;
  text-fill-color: #1f2937 !important;
}

#security-reports .finding-item.risk-medium .implementation-details {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #f0ad4e !important; /* Orange border for Medium Risk */
  border-left: 4px solid #f0ad4e !important;
}

#security-reports .finding-item.risk-medium .implementation-details * {
  color: #1f2937 !important;
  -webkit-text-fill-color: #1f2937 !important;
  text-fill-color: #1f2937 !important;
}

#security-reports .finding-item.risk-low .implementation-details {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #5cb85c !important; /* Green border for Low Risk */
  border-left: 4px solid #5cb85c !important;
}

#security-reports .finding-item.risk-low .implementation-details * {
  color: #1f2937 !important;
  -webkit-text-fill-color: #1f2937 !important;
  text-fill-color: #1f2937 !important;
}

/* Skip Links for Accessibility */
.skip-links {
  position: absolute;
  top: -40px;
  left: 6px;
  z-index: 10000;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  transition: top 0.3s;
}

.skip-link:focus {
  top: 6px;
}

/* Mobile TOC Improvements */
.toc.mobile-collapsible {
  position: relative;
  top: 0;
}

.toc.mobile-collapsible h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.toc-toggle {
  background: none;
  border: none;
  color: var(--gray-600);
  font-size: var(--font-size-lg);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.toc-toggle:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.toc.mobile-collapsible ul {
  transition: all 0.3s ease;
}

/* Collapsible Content Animation */
.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-content.active {
  max-height: none;
}

/* Print Styles */
@media print {
  .toc, .btn, .collapsible-header {
    display: none !important;
  }
  
  .collapsible-content {
    display: block !important;
    max-height: none !important;
  }
  
  .report-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid var(--gray-300) !important;
  }
  
  .skip-links {
    display: none !important;
  }
}

/* Loading Animation for Collapsible Sections */
@keyframes sectionPulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}

/* Final text color enforcement for maximum readability */
.security-reports-page .card,
.security-reports-page .card *,
.security-reports-page .alert,
.security-reports-page .alert *,
.security-reports-page .table,
.security-reports-page .table *,
.security-reports-page .list-group,
.security-reports-page .list-group * {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for all interactive elements */
.security-reports-page button,
.security-reports-page a,
.security-reports-page input,
.security-reports-page select,
.security-reports-page textarea {
  color: var(--gray-800) !important;
}

/* Override any Bootstrap text utilities that might cause issues */
.security-reports-page .text-white,
.security-reports-page .text-light {
  color: var(--gray-800) !important;
}

/* Ensure proper contrast for all text in the security reports */
.security-reports-page * {
  color: var(--gray-800) !important;
}

/* Robust TOC Sticky Positioning - Grid Layout */
.report-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.25rem;
  align-items: start; /* critical for sticky */
}

.report-toc {
  position: sticky;
  top: var(--toc-top, 88px);
  align-self: start;
  max-height: calc(100svh - var(--toc-top, 88px) - 12px);
  overflow: auto;
  will-change: scroll-position; /* hint */
  z-index: 1020;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Don't trap sticky inside an overflow context */
.report-layout,
.report-layout > * {
  overflow: visible !important;
}

/* Mobile: disable sticky */
@media (max-width: 991.98px) {
  .report-layout { 
    display: block; 
  }
  .report-toc { 
    position: static; 
    max-height: none; 
    overflow: visible; 
    margin-bottom: 1rem;
  }
}

/* Dynamic TOC top offset calculation */
.toc-top-calculator {
  --toc-top: 88px;
}

/* Fallback for older browsers */
@supports not (position: sticky) {
  .report-toc {
    position: relative;
    top: auto;
  }
}

/* Robust Implementation Details Text Visibility Fixes */
.report-card .implementation-details {
  background: var(--surface-50, #f9fafb) !important;
  color: #1f2937 !important; /* Dark text for proper contrast on light background */
  border: 1px solid var(--surface-200, #e5e7eb) !important;
  border-radius: 0.5rem;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Make children inherit and undo weird text-fill/gradient tricks */
.report-card .implementation-details :is(p, li, span, div, strong, em, h6, code, a) {
  color: inherit !important;
  -webkit-text-fill-color: initial !important;
  mix-blend-mode: normal !important;
}

/* Neutralize Bootstrap de-emphasis inside this block */
.report-card .implementation-details :is(.text-muted, .text-secondary) {
  color: #374151 !important; /* slate-700 */
  opacity: 1 !important;
}

/* If you ever used gradient text utilities, hard-reset them here */
.report-card .implementation-details [class*="text-gradient"],
.report-card .implementation-details .text-transparent {
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  color: inherit !important;
  -webkit-text-fill-color: initial !important;
}

/* Force visibility for all text elements in implementation details */
.report-card .implementation-details * {
  color: #1f2937 !important; /* Dark text for proper contrast on light background */
}

/* Specific override for any Bootstrap or conflicting styles */
.report-card .implementation-details .text-muted,
.report-card .implementation-details .text-secondary {
  color: #374151 !important;
}

/* Belt-and-suspenders fallback colors */
:root {
  --surface-50: #f9fafb;
  --surface-200: #e5e7eb;
  --ink-900: #111827;
}

/* CSS variable for TOC top offset - set on body element */
body {
  --toc-top: 88px;
}

/* Final Nuclear Override for Implementation Details */
.report-card .finding-item .implementation-details,
.report-card .finding-item .implementation-details *,
.report-card .finding-item .implementation-details p,
.report-card .finding-item .implementation-details div,
.report-card .finding-item .implementation-details span,
.report-card .finding-item .implementation-details strong,
.report-card .finding-item .implementation-details em,
.report-card .finding-item .implementation-details h6,
.report-card .finding-item .implementation-details li,
.report-card .finding-item .implementation-details code,
.report-card .finding-item .implementation-details a {
  color: #1f2937 !important;
  -webkit-text-fill-color: #1f2937 !important;
  text-fill-color: #1f2937 !important;
  background: #ffffff !important;
}

/* Ensure all risk levels have proper implementation details styling */
.finding-item.risk-high .implementation-details,
.finding-item.risk-medium .implementation-details,
.finding-item.risk-low .implementation-details {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.5rem;
  padding: 1rem;
}

/* Specific risk-level borders */
.finding-item.risk-high .implementation-details {
  border-left: 4px solid #dc3545 !important;
}

.finding-item.risk-medium .implementation-details {
  border-left: 4px solid #f0ad4e !important;
}

.finding-item.risk-low .implementation-details {
  border-left: 4px solid #5cb85c !important;
}

/* Clean, namespaced styling is now handled above */

/* Fix for inline code elements inside Implementation Details */
.finding-item .implementation-details code {
  background: #ffffff !important;   /* white background to match box */
  color: #1f2937 !important;        /* dark readable text */
  border: 1px solid #e5e7eb !important;
  border-radius: 0.25rem;
  padding: 0.15rem 0.35rem;
  font-size: 0.8rem;
}

/* Keep dark theme for block code (pre > code) */
.finding-item .implementation-details pre code {
  background: #1f2937 !important;  /* dark background */
  color: #f9fafb !important;       /* light text */
  display: block;
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow: auto;
}

/* Ensure all risk levels get the same code styling fix */
.risk-high .implementation-details code,
.risk-medium .implementation-details code,
.risk-low .implementation-details code {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #e5e7eb !important;
}

/* But preserve dark theme for block code */
.risk-high .implementation-details pre code,
.risk-medium .implementation-details pre code,
.risk-low .implementation-details pre code {
  background: #1f2937 !important;
  color: #f9fafb !important;
}

/* Collapsible Content Styles */
.collapsible-content {
    max-height: var(--max-height, 0px);
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-icon {
    transform: rotate(var(--rotation, 0deg));
    transition: transform 0.3s ease;
}

.collapsible-hover {
    cursor: pointer;
}

/* Print Styles */
@media print {
    .toc, .btn, .collapsible-header {
        display: none !important;
    }
    .collapsible-content {
        display: block !important;
    }
    .report-card {
        break-inside: avoid;
        box-shadow: none !important;
    }
}