
/* Theme-specific WCAG compliant colors */
:root {
    /* Shared colors - work well in both themes */
    --color-issue: #3B82F6;  /* 5.2:1 light, 5.9:1 dark - perfect in both */
    --focus-ring: #7C3AED;    /* Strong indigo for focus states */
}

[data-theme="light"] {
    /* Light theme - systematic tonal hierarchy */
    --bg-page: #F9FAFB;        /* Neutral base */
    --bg-card: #F3F6FB;        /* Primary surface (+8% luminance) */
    --bg-filter: #E9EEF6;      /* Nested context (+4% luminance) */
    --border-accent: #C5B3F8;  /* Visual separation */
    --hover-accent: rgba(147,51,234,0.1); /* Subtle glow, not tone shift */
    
    /* Vibrant accent colors for light mode */
    --color-action: #B45309;   /* 5.3:1 contrast vs #F8FAFC */
    --color-advice: #0284C7;   /* 5.5:1 contrast vs #F8FAFC */
    --color-rule: #7C3AED;     /* 4.9:1 contrast vs #F8FAFC */
    --focus-ring: #7C3AED;     /* 5.1:1 contrast vs #F8FAFC */
    
    /* Legacy variables for compatibility */
    --accent-action: #B45309;
    --accent-advice: #0284C7;
    --accent-purple: #7C3AED;
}

[data-theme="dark"] {
    /* Dark theme - systematic tonal hierarchy */
    --bg-page: #0F172A;        /* Deep slate base */
    --bg-card: #1E293B;        /* Primary surface */
    --bg-filter: #2A3441;      /* Lighter still - subtle, non-competing */
    --border-accent: rgba(147, 51, 234, 0.25); /* Reduced strength */
    --hover-accent: rgba(147, 51, 234, 0.07); /* Soft glow */
    
    /* Vibrant accent colors for dark mode */
    --color-action: #F59E0B;   /* Golden warmth - brighter orange */
    --color-advice: #38BDF8;   /* Bright cyan - matches blue energy */
    --color-rule: #C084FC;     /* Luminous purple */
    --color-issue: #60A5FA;    /* Brighter blue pop */
    --focus-ring: #C084FC;     /* Focus ring color */
    
    /* Text contrast ladder */
    --text-heading: #FFFFFF;   /* Pure white headings */
    --text-body: #E2E8F0;       /* Slate-200 body text */
    --text-muted: #94A3B8;      /* Slate-400 muted labels */
    
    /* Legacy variables for compatibility */
    --accent-action: #F59E0B;
    --accent-advice: #38BDF8;
    --accent-purple: #C084FC;
}

/* Summary cards with inline icons */
.magic-summary-card {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 20px;
    position: relative;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow);
}

.magic-summary-card .count {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.magic-summary-card .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.magic-summary-card .icon {
    font-size: 1rem;
}

/* Accent colors for icons and borders */
.magic-summary-card.action .icon { 
    color: var(--accent-action); 
}

.magic-summary-card.advice .icon { 
    color: var(--accent-advice); 
}

.magic-summary-card.action { 
    border-bottom: 2px solid var(--accent-action); 
}

.magic-summary-card.advice { 
    border-bottom: 2px solid var(--accent-advice); 
}

.summary-number,
.summary-number-blue,
.summary-number-purple,
.summary-number-orange {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-number-blue { color: var(--color-issue); }   /* Perfect in both themes */
.summary-number-purple { color: var(--color-rule); }  /* Theme-specific WCAG compliant */
.summary-number-orange { color: var(--color-action); } /* Theme-specific WCAG compliant */

.summary-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-filename-section {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.summary-filename {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.summary-filename-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.severity-section {
    margin-top: 20px;
}

.severity-section h5 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.severity-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.severity-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
}

.severity-count {
    font-weight: 600;
    color: #1e293b;
}

.severity-name {
    color: #64748b;
    text-transform: capitalize;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Findings */
.findings {
    margin-top: 0;  /* Remove gap - controls sit directly on top */
}

/* Light mode file group row (unchanged) */
[data-theme="light"] .file-group,
:not([data-theme]) .file-group {
    background: #f9fafb;
    border: 1px solid #e2e8f0;
}

/* Dark mode file group row */
[data-theme="dark"] .file-group {
    background: #1e293b;   /* dark slate, matches your cards */
    border: 1px solid #334155;
}

/* Ensure key text stays readable in dark headers */
[data-theme="dark"] .file-header,
[data-theme="dark"] .file-name,
[data-theme="dark"] .file-path {
  color: #f1f5f9;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.file-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
}

.file-info {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow flex item to shrink */
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-path {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.file-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Don't shrink the right side */
}

.file-count-badge {
    background: #3b82f6;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
    border: 2px solid #2563eb;
    display: inline-flex;
    align-items: center;
}

.severity-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.severity-count-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    line-height: 1;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.severity-count-badge.action {
    background: #ea580c;
    color: #ffffff;
    border: 2px solid #c2410c;
}

.severity-count-badge.action::before {
    content: "■";
    font-size: 0.9em;
}

.severity-count-badge.advice {
    background: #756AA2;
    color: #ffffff;
    border: 2px dashed #6B5E94;
}

.severity-count-badge.advice::before {
    content: "◆";
    font-size: 0.9em;
}

/* Theme-specific severity badge colors */
[data-theme="dark"] .severity-count-badge.action {
    background: #f97316;
    color: #ffffff;
    border: 2px solid #fb923c;
}

[data-theme="dark"] .severity-count-badge.advice {
    background: #9F7AEA;
    color: #ffffff;
    border: 2px dashed #B794F4;
}

.file-findings {
    padding: 0 20px 20px;
    background: var(--bg-secondary);
}

.finding {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-light);
}

.finding:last-child {
    border-bottom: none;
}

.finding-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.finding-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 30px;
}

.no-issues {
    text-align: center;
    padding: 60px 40px;
    background: #f0fdf4;
    border-radius: 8px;
    color: #16a34a;
    font-size: 1.1rem;
}

/* Light mode hover effects */
[data-theme="light"] .config-option:hover,
:not([data-theme]) .config-option:hover {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}

/* Light-mode hover */
[data-theme="light"] .file-header:hover,
:not([data-theme]) .file-header:hover {
  background-color: #f9fafb;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

[data-theme="light"] {
    --bg-tertiary: #f0f4f8; /* improved separation only in light mode */
}

/* Dark-mode header base & hover */
[data-theme="dark"] .file-header {
  background: var(--bg-tertiary);           /* #334155 from your tokens */
}

[data-theme="dark"] .file-header:hover {
  background: #2a3647;                      /* subtle lift, still dark */
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  transform: translateY(-2px);
}

/* Dark-mode collapsed group header: ensure it never goes light */
[data-theme="dark"] .file-group.collapsed .file-header {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  color: #e5e7eb;
}

/* === Dark Mode File Group Borders Enhancements === */
[data-theme="dark"] .file-group,
[data-theme="dark"] .file-header {
border: 1px solid #475569; /* medium slate border for contrast */
border-radius: 6px;
}

[data-theme="dark"] .file-group + .file-group {
margin-top: 4px;
}

[data-theme="dark"] .file-group:hover {
border-color: #818cf8; /* indigo hover accent */
box-shadow: 0 2px 6px rgba(129, 140, 248, 0.25);
}  

/* Dark mode hover for config blocks */
[data-theme="dark"] .config-option:hover {
    border-color: #818cf8;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.3);
}

/* Dark mode hover text colors */
[data-theme="dark"] .config-option:hover .config-name {
    color: #ffffff;
}

[data-theme="dark"] .config-option:hover .config-description {
    color: #e2e8f0;
}

[data-theme="dark"] .config-option:hover .config-meta {
    color: #f1f5f9;
}

[data-theme="dark"] .config-option:hover .config-rules-count {
    background: rgba(129, 140, 248, 0.2);
    color: #f1f5f9;
}

[data-theme="dark"] .config-option:hover .config-performance {
    color: #f1f5f9;
}


/* === Color-blind friendly cues === */
.config-performance.fast::before {
    content: "⚡ ";
}

.config-performance.balanced::before {
    content: "⚖️ ";
}

.config-performance.thorough::before {
    content: "🔍 ";
}

/* === Reduced motion support === */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* ===  High contrast mode support (Windows / system setting) === */
@media (forced-colors: active) {
    .btn, .config-option, .file-group, .upload-area, .results-section, header {
        border: 1px solid CanvasText;
    }
    .btn { background: ButtonFace; color: ButtonText; }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .file-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .file-header-left {
        flex: none;
    }
    
    .file-header-right {
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .file-count-badge {
        order: -1; /* Show total count first on mobile */
    }
    
    /* Adjust theme toggle for mobile */
    .theme-toggle-fixed {
        bottom: 15px;
        right: 15px;
    }
    
    .theme-toggle-fixed .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        font-weight: 600;
        border-width: 2px;
    }
}

/* Arcane Control Bar - Theme-Specific WCAG 2.2 AA Compliant Palette
 * 
 * Light Theme Contrast Ratios vs #F8FAFC background:
 * - Blue (#3B82F6): 5.2:1 ✅ Pass (AA+AAA)
 * - Purple (#7C3AED): 4.9:1 ✅ Pass (AA)
 * - Orange (#B45309): 5.3:1 ✅ Pass (AA+AAA)
 * - Cyan (#0284C7): 5.5:1 ✅ Pass (AA+AAA)
 * 
 * Dark Theme Contrast Ratios vs #1E293B background:
 * - Blue (#3B82F6): 5.9:1 ✅ Pass (AA+AAA)
 * - Purple (#C084FC): 4.5:1 ✅ Pass (AA)
 * - Orange (#EAB308): 4.8:1 ✅ Pass (AA)
 * - Cyan (#38BDF8): 5.7:1 ✅ Pass (AA+AAA)
 */
.filter-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-filter);
    border: 1px solid var(--border-accent);
    border-radius: 12px;
    margin: auto auto 20px auto;
    backdrop-filter: blur(15px);
    transition: box-shadow 0.2s ease;
}

.filter-bar:hover {
    box-shadow: 0 0 8px var(--hover-accent);
    transform: translateY(-1px);
}


/* Nested Filters - Clean, Subtle Design (now inline) */

.findings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;          /* No gap at all */
    padding-bottom: 0.5rem;     /* Just enough for the border */
    border-bottom: 1px solid var(--border-subtle);
    margin-top: 1.25rem;       /* Add spacing from summary section */
}

.expand-collapse-buttons {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0; /* Prevent shrinking */
    margin-top: 0.75rem;        /* Separate from summary */
    margin-bottom: 0.75rem;     /* Space before filters */
}

.expand-collapse-buttons::after {
    content: "";
    display: block;
    border-top: 1px solid rgba(255,255,255,0.08); /* Subtle divider */
    margin-top: 0.75rem;
}

.filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0;
}

.micro-label {
    text-transform: uppercase;
    font-size: 0.7rem;         /* 11px - dev tools style */
    font-weight: 600;
    letter-spacing: 0.03em;     /* Tighter letter spacing */
    margin-bottom: 2px;
    text-align: center;
    white-space: nowrap;
    color: #F8FAFC;             /* Off-white like the summary cards */
}

/* Light theme micro-label - high contrast */
[data-theme="light"] .micro-label {
    color: #374151;            /* slate-700 - better contrast on light bg */
}

/* Button hover improvements for better accessibility */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid var(--color-rule);
}

/* Dark theme micro-label - improved contrast */
[data-theme="dark"] .micro-label {
    color: #C7D2FE;             /* Better contrast - indigo-200 */
}

.filter-group select {
    padding: 0.35rem 0.75rem;  /* Compact dev tools style */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Better contrast */
    border-radius: 6px;
    background-color: #1E293B;  /* Dark theme default */
    color: #CBD5E1;             /* Softer white text */
    font-size: 0.85rem;
    min-width: 100px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.filter-group select:hover {
    border-color: var(--color-rule);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.2);
    background: rgba(240,245,255,0.95);
    transform: translateY(-1px);
}

.filter-group select:focus {
    outline: 2px solid #C084FC;  /* Solid purple border instead of glow */
    outline-offset: 2px;
    border-color: var(--color-rule);
    background: rgba(240,245,255,0.98);
}

.filter-group select option {
    background: rgba(240,245,255,0.98);
    color: #374151;
    padding: 8px 12px;
}

.filter-group select option:hover,
.filter-group select option:focus {
    background-color: #EDE9FE;  /* indigo-100 for light theme */
    color: #1E1B4B;
}

/* Dark theme select elements with proper contrast */
[data-theme="dark"] .filter-group select {
    background-color: #1B2433;  /* Darker than filter panel for clarity */
    color: #F1F5F9;             /* Light neutral text */
    border: 1px solid rgba(147,51,234,0.3);
}

[data-theme="dark"] .filter-group select:hover {
    background-color: #222C3E;  /* Slight lift for feedback */
    border-color: rgba(167,139,250,0.8);
    box-shadow: 0 0 4px rgba(147,51,234,0.3);
}

[data-theme="dark"] .filter-group select:focus {
    background-color: #222C3E;  /* Slight lift for feedback */
    border-color: rgba(167,139,250,0.8);
    box-shadow: 0 0 4px rgba(147,51,234,0.3);
    outline: 2px solid #C084FC;  /* Solid purple border instead of glow */
    outline-offset: 2px;
}

[data-theme="dark"] .filter-group select option {
    background-color: #1B2433;
    color: #F1F5F9;
}

[data-theme="dark"] .filter-group select option:hover,
[data-theme="dark"] .filter-group select option:focus {
    background-color: #222C3E;
    color: var(--text-heading);
}

[data-theme="dark"] .filter-group select option:disabled {
    color: #64748B;             /* Mid-gray, still readable on dark background */
}

/* Light theme select elements */
[data-theme="light"] .filter-group select {
    background-color: #F8FAFC;  /* Light background */
    color: #1E293B;             /* Dark text */
    border: 1px solid rgba(0, 0, 0, 0.15); /* Better contrast */
}

[data-theme="light"] .filter-group select:hover {
    border-color: var(--color-rule);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.2);
    background-color: #F1F5F9;
}

[data-theme="light"] .filter-group select:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-color: var(--color-rule);
    background-color: #F1F5F9;
}

[data-theme="light"] .filter-group select option {
    background-color: #F8FAFC;
    color: #1E293B;
}

[data-theme="light"] .filter-group select option:hover,
[data-theme="light"] .filter-group select option:focus {
    background-color: #EDE9FE;
    color: #1E1B4B;
}

/* Light theme filter bar with proper luminance separation */
[data-theme="light"] .filter-bar {
    background: #E8EEF5;        /* Cooler, darker than page background */
    border: 1px solid #E2E8F0;   /* Subtle border for definition */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Soft shadow for depth */
}

[data-theme="light"] .filter-bar:hover {
    border-color: var(--color-rule);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}


[data-theme="light"] .divider {
    background: linear-gradient(to bottom, transparent, var(--color-rule), transparent);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-bar {
        padding: 1rem 1.5rem;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .divider {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right, transparent, var(--color-rule), transparent);
    }
    
    .filter-group select {
        min-width: 140px;
    }
}

/* Context Impact Styles */
.context-impact {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid #dc2626; /* Red border for not invoked */
}

.context-impact-partial {
    border-left: 4px solid #eab308; /* Yellow border for partially invoked */
    background: rgba(234, 179, 8, 0.05); /* Subtle yellow background */
}

.context-impact h4 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-impact-subtitle {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.context-impact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-impact-item {
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.context-impact-item strong {
    color: var(--text-primary);
    margin-right: 8px;
}

.context-impact-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Context Config Styles */
.context-config {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid var(--color-rule);
}

.context-config h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-config-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.config-icon {
    font-size: 1rem;
}

.config-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Context Files Styles */
.context-files {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid var(--color-rule);
}

.context-files h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.file-icon {
    font-size: 1rem;
}

.file-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* ===== Code Snippet Styles ===== */

.finding-snippet {
    position: relative;
    margin: 8px 0 4px 30px;
    border-radius: 6px;
    max-height: 220px;
    overflow: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
    scrollbar-width: none;
}

.finding-snippet::-webkit-scrollbar {
    display: none;
}

.finding-snippet:hover {
    border-color: var(--text-secondary);
    scrollbar-width: thin;
}

.finding-snippet:hover::-webkit-scrollbar {
    display: block;
    width: 6px;
}

.finding-snippet:hover::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.finding-snippet pre {
    margin: 0;
    padding: 8px 0;
    font-size: 0.8rem;
    line-height: 1.5;
    background: transparent;
}

.finding-snippet code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: transparent;
}

.snippet-line {
    display: block;
    padding: 0 12px 0 0;
    white-space: pre;
}

.snippet-lineno {
    display: inline-block;
    width: 3.5em;
    text-align: right;
    padding-right: 1em;
    color: var(--text-secondary);
    opacity: 0.5;
    user-select: none;
    border-right: 1px solid var(--border-color);
    margin-right: 1em;
}

.snippet-highlight {
    background: rgba(255, 220, 100, 0.2);
    border-left: 3px solid #f59e0b;
}

.snippet-highlight .snippet-lineno {
    opacity: 0.8;
    color: #f59e0b;
}

[data-theme="dark"] .snippet-highlight {
    background: rgba(255, 220, 100, 0.08);
}

/* Fixed snippet highlight — green instead of yellow */
.snippet-highlight-fixed {
    background: rgba(16, 185, 129, 0.15);
    border-left: 3px solid #10b981;
}

.snippet-highlight-fixed .snippet-lineno {
    opacity: 0.8;
    color: #10b981;
}

[data-theme="dark"] .snippet-highlight-fixed {
    background: rgba(16, 185, 129, 0.1);
}

/* Fixed snippet container — subtle green border */
.snippet-fixed {
    border-color: #10b981;
}

/* ===== Inline AI Explanation (per-finding) ===== */

.finding-explanation {
    margin: 10px 0 4px 30px;
    padding: 10px 14px 10px 12px;
    border: 1px dashed var(--arcane-purple);
    border-left: 3px solid var(--arcane-purple);
    background: linear-gradient(135deg, var(--arcane-glow) 0%, transparent 100%);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    box-shadow: 0 1px 4px rgba(117, 106, 162, 0.15);
    position: relative;
}

.finding-explanation.action {
    border-color: #b91c1c;
    border-left-color: #dc2626;
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.08) 0%, transparent 100%);
    box-shadow: 0 1px 4px rgba(185, 28, 28, 0.12);
}

[data-theme="dark"] .finding-explanation {
    box-shadow: 0 1px 6px rgba(159, 122, 234, 0.2);
}

[data-theme="dark"] .finding-explanation.action {
    border-color: rgba(239, 68, 68, 0.5);
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, transparent 100%);
    box-shadow: 0 1px 6px rgba(239, 68, 68, 0.2);
}

.finding-explanation-ai-label {
    position: absolute;
    top: -1px;
    right: -1px;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--arcane-purple);
    color: #fff;
    border-radius: 0 8px 0 6px;
    letter-spacing: 0.08em;
    opacity: 0.85;
}

.finding-explanation.action .finding-explanation-ai-label {
    background: #b91c1c;
}

[data-theme="dark"] .finding-explanation.action .finding-explanation-ai-label {
    background: #dc2626;
}

.finding-explanation-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.finding-explanation-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.finding-explanation-badge.action {
    background: #dc2626;
    color: #fff;
}

.finding-explanation-badge.advice {
    background: #d97706;
    color: #fff;
}

[data-theme="dark"] .finding-explanation-badge.action {
    background: #ef4444;
}

[data-theme="dark"] .finding-explanation-badge.advice {
    background: #f59e0b;
    color: #1a1a1a;
}

.finding-explanation-text {
    margin: 0 0 4px 0;
}

.finding-explanation-suggestion {
    margin: 4px 0 0 0;
    color: var(--text-primary);
    font-style: italic;
}

/* ===== Explain Cards ===== */

.explain-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.explain-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.explain-content tr:nth-child(even) {
    background: var(--bg-tertiary);
}

.explain-content tr:hover {
    background: var(--arcane-glow);
}

.explain-card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.explain-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-hover);
}

[data-theme="light"] .explain-card:hover,
:not([data-theme]) .explain-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .explain-card {
    background: #1e293b;
    border-color: #475569;
}

[data-theme="dark"] .explain-card:hover {
    background: #2a3647;
    border-color: #818cf8;
    box-shadow: 0 2px 6px rgba(129, 140, 248, 0.25);
}

.explain-card-summary {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .explain-card-summary {
    background: #253447;
}

.explain-card > h1:first-child,
.explain-card > h2:first-child,
.explain-card > h3:first-child,
.explain-card > h4:first-child {
    margin-top: 0;
}

.explain-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8em;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s ease, color 0.15s ease;
    opacity: 0;
    z-index: 1;
}

.explain-card:hover .explain-copy-btn {
    opacity: 1;
}

.explain-copy-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--arcane-purple);
}

[data-theme="dark"] .explain-copy-btn {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .explain-copy-btn:hover {
    background: #475569;
    color: #f1f5f9;
}

.explain-content blockquote {
    border-left: 3px solid var(--arcane-purple);
    padding: 8px 16px;
    margin: 8px 0;
    color: var(--text-secondary);
    background: var(--arcane-glow);
    border-radius: 0 6px 6px 0;
}

/* ===== Resolved finding state ===== */

.finding-resolved {
    opacity: 0.55;
}

.finding-resolved .finding-header {
    text-decoration: none;
}

.resolved-badge {
    display: inline-block;
    background: #10b981;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
    text-decoration: none;
    vertical-align: middle;
}

[data-theme="dark"] .resolved-badge {
    background: #059669;
}

/* Dismissed finding */
.finding-dismissed {
    opacity: 0.45;
}

.finding-dismissed .finding-header {
    text-decoration: none;
}

.dismissed-badge {
    display: inline-block;
    background: #6b7280;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

[data-theme="dark"] .dismissed-badge {
    background: #4b5563;
}

.file-all-fixed-badge.has-dismissed {
    background: #6b7280;
    border-color: #4b5563;
}

[data-theme="dark"] .file-all-fixed-badge {
    background: #059669;
    border-color: #10b981;
}

[data-theme="dark"] .file-all-fixed-badge.has-dismissed {
    background: #4b5563;
    border-color: #6b7280;
}

.file-all-fixed-badge {
    font-size: 0.8rem;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 12px;
    background: #10b981;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    border: 2px solid #059669;
}

/* ===== Export ZIP bar ===== */

.export-zip-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 20px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.08));
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.export-zip-message {
    font-weight: 600;
    color: #10b981;
    font-size: 0.95rem;
}

[data-theme="dark"] .export-zip-message {
    color: #34d399;
}

.export-zip-btn {
    font-size: 0.85rem;
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: #10b981;
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
}

.export-zip-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.35);
}

/* ===== Fix progress badge in file header ===== */

.file-fix-progress {
    color: #10b981;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 8px;
}

[data-theme="dark"] .file-fix-progress {
    color: #34d399;
}

/* ===== Fix All button (file header) ===== */

.fix-all-btn {
    font-size: 0.8rem;
    line-height: 1;
    font-family: inherit;
    padding: 4px 10px;
    border-radius: 12px;
    border: 2px solid var(--arcane-purple);
    background: var(--arcane-purple);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    /* Match span badge height exactly */
    min-height: 0;
    box-sizing: border-box;
}

.fix-all-btn:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.fix-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fix-all-btn.loading {
    cursor: wait;
}

/* ===== Auto-fix button (per finding) ===== */

.finding-actions {
    margin: 8px 0 0 30px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.autofix-btn {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--arcane-purple);
    background: var(--bg-secondary);
    color: var(--arcane-purple);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.autofix-btn:hover:not(:disabled) {
    background: var(--arcane-purple);
    color: #fff;
}

.autofix-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.autofix-btn.loading {
    cursor: wait;
}

.dismiss-btn {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dismiss-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.revert-fix-btn {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid #d97706;
    background: transparent;
    color: #d97706;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.revert-fix-btn:hover {
    background: rgba(217, 119, 6, 0.1);
    border-color: #b45309;
    color: #b45309;
}

/* ===== Diff warning (autofix removed suspicious lines) ===== */

.diff-warning {
    margin: 10px 0 6px 30px;
    padding: 10px 14px;
    border: 1px solid #d97706;
    border-radius: 8px;
    background: rgba(217, 119, 6, 0.08);
    font-size: 0.82rem;
}

.diff-warning-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #b45309;
    font-weight: 600;
    margin-bottom: 4px;
}

.diff-warning-details summary {
    cursor: pointer;
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 4px;
}

.diff-warning-details summary:hover {
    text-decoration: underline;
}

.diff-warning-code {
    margin: 6px 0 0;
    padding: 8px 10px;
    background: rgba(220, 38, 38, 0.06);
    border-left: 3px solid #dc2626;
    border-radius: 0 4px 4px 0;
    color: #dc2626;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

[data-theme="dark"] .diff-warning {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

[data-theme="dark"] .diff-warning-header {
    color: #fbbf24;
}

[data-theme="dark"] .diff-warning-details summary {
    color: #fcd34d;
}

[data-theme="dark"] .diff-warning-code {
    background: rgba(248, 113, 113, 0.1);
    border-left-color: #f87171;
    color: #fca5a5;
}

/* ===== Side-by-side diff view (auto-fix) ===== */

/* ===== Two-panel side-by-side diff ===== */

.finding-diff {
    margin: 8px 0 4px 30px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.diff-panels {
    display: flex;
}

.diff-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.diff-panel-header {
    padding: 4px 12px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.diff-panel-divider {
    width: 1px;
    background: var(--border-color);
    flex-shrink: 0;
}

.diff-scroll {
    max-height: 360px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.diff-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.diff-scroll::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.diff-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.diff-table {
    min-width: 100%;
    border-collapse: collapse;
}

.diff-table td {
    padding: 0;
    vertical-align: top;
    white-space: pre;
}

.diff-lineno {
    width: 3.5em;
    text-align: right;
    padding-right: 0.5em !important;
    color: var(--text-secondary);
    opacity: 0.5;
    user-select: none;
}

.diff-prefix {
    width: 1.2em;
    text-align: center;
    user-select: none;
    font-weight: 700;
}

.diff-code {
    padding-left: 0.5em !important;
    padding-right: 0.5em !important;
}

/* Row colors — light theme */
.diff-removed td {
    background: rgba(255, 220, 220, 0.45);
}
.diff-removed .diff-prefix {
    color: #b91c1c;
}

.diff-added td {
    background: rgba(220, 255, 228, 0.45);
}
.diff-added .diff-prefix {
    color: #15803d;
}

.diff-empty td {
    background: var(--bg-tertiary);
}

/* Row colors — dark theme */
[data-theme="dark"] .diff-removed td {
    background: rgba(248, 113, 113, 0.12);
}
[data-theme="dark"] .diff-removed .diff-prefix {
    color: #fca5a5;
}

[data-theme="dark"] .diff-added td {
    background: rgba(52, 211, 153, 0.12);
}
[data-theme="dark"] .diff-added .diff-prefix {
    color: #6ee7b7;
}

[data-theme="dark"] .diff-empty td {
    background: rgba(255, 255, 255, 0.03);
}

/* Unchanged rows */
.diff-unchanged td {
    background: var(--bg-primary);
}

.file-all-fixed-badge.has-warnings {
    background: #d97706;
    color: #fff;
}

[data-theme="dark"] .file-all-fixed-badge.has-warnings {
    background: #f59e0b;
    color: #1e1e1e;
}

