:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #020617;
    --accent-color: #38bdf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 8px;
    color: var(--accent-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.back-link:hover {
    background-color: var(--accent-color);
    color: white;
}

.search-container {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

#fileSearch {
    width: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 10px 10px 36px;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-speed);
}

#fileSearch:focus {
    border-color: var(--accent-color);
}

.file-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.file-list-container::-webkit-scrollbar {
    width: 4px;
}

.file-list-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    margin-bottom: 4px;
}

.file-item:hover {
    background-color: rgba(56, 189, 248, 0.1);
}

.file-item.active {
    background-color: rgba(56, 189, 248, 0.2);
    border-left: 3px solid var(--accent-color);
}

.file-icon {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.file-item.active .file-icon {
    color: var(--accent-color);
}

.file-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

.status-dot.completed {
    background-color: var(--success-color);
}

.status-dot.pending {
    background-color: var(--warning-color);
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#refreshBtn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-speed);
}

#refreshBtn:hover {
    color: var(--accent-color);
}

/* Main Content Styling */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view-controls {
    display: flex;
    align-items: stretch;
    /* Make them same height */
    gap: 16px;
}

.main-header {
    padding: 16px 24px;
    /* ... existing code ... */
    z-index: 999999;

    /* Reason Dropdown (Pass case) */
    .reason-container {
        position: relative;
        width: 100%;
    }

    .reason-btn {
        width: 100%;
        background-color: rgba(139, 92, 246, 0.15);
        color: #e2e8f0;
        border: 1px solid rgba(139, 92, 246, 0.3);
        padding: 6px 10px;
        border-radius: 6px;
        font-size: 0.8rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        transition: all 0.2s;
    }

    .reason-btn:hover {
        background-color: rgba(139, 92, 246, 0.25);
        border-color: #d8b4fe;
    }

    .reason-dropdown {
        position: absolute;
        /* bottom: calc(100% + 4px); */
        /* Go upwards */
        top: auto;
        left: 0;
        right: 0;
        background-color: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        padding: 12px;
        z-index: 50;
        box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.5);
        /* Shadow upwards */
        display: none;
        max-height: 300px;
        overflow-y: auto;
    }

    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.main-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.original {
    background-color: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
}

.badge.redacted {
    background-color: rgba(56, 189, 248, 0.2);
    color: var(--accent-color);
}

.badge.status {
    padding: 6px 12px;
}

.badge.status.ready {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.status.missing {
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.file-ai-score {
    font-size: 1rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-right: 8px;
    margin-left: auto;
    /* Push to right, before dot */
}

/* Comparison Viewer Grid */
/* Comparison Viewer Grid */
.comparison-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Back to full width split */
    gap: 1px;
    background-color: var(--border-color);
    overflow: hidden;
    position: relative;
    /* Context for overlay */
}

.central-controls {
    position: absolute;
    top: 10px;
    left: 48%;
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: none;
    /* Let clicks pass through outside the button */
    display: flex;
    justify-content: center;
}

.sync-toggle-container {
    pointer-events: auto;
    /* Re-enable clicks for the button */
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(30, 41, 59, 0.9);
    /* Semi-transparent dark */
    padding: 6px 12px;
    border-radius: 99px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    flex-direction: row;
    /* Horizontal layout */
}

.sync-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s;
}

input:checked+.slider {
    background-color: rgba(16, 185, 129, 0.2);
    border-color: var(--success-color);
}

input:checked+.slider:before {
    transform: translateX(16px);
    background-color: var(--success-color);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.viewer-section {
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.viewer-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.path-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
    text-align: left;
}

.pdf-viewer {
    flex: 1;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pdf-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pdf-page {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-color: white;
    max-width: 100%;
}

/* Hide iframes from previous implementation if any remain */
.pdf-viewer iframe,
.pdf-viewer object,
.pdf-viewer embed {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    /* Hide embeds */
}

.placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder i {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.2;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
    font-size: 2rem;
    color: var(--accent-color);
}

@media (max-width: 1024px) {
    .comparison-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        overflow-y: auto;
    }

    .pdf-viewer {
        height: 600px;
    }
}

/* Stats Panel Styling */
.stats-panel {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(16, 185, 129, 0.1));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 16px;
    margin-right: 16px;
    min-width: 320px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-header i {
    font-size: 1rem;
}

.stats-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

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

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 2px;
}

.stat-item.success .stat-value {
    color: var(--success-color);
}

.stat-item.info .stat-value {
    color: var(--accent-color);
}

.stat-item.highlight {
    background: rgba(16, 185, 129, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.stat-item.highlight .stat-value {
    color: var(--success-color);
    font-size: 1rem;
}

.stat-item.highlight .stat-label {
    color: var(--success-color);
}

/* Stats panel no data state */
.stats-panel.no-data {
    opacity: 0.6;
    background: rgba(148, 163, 184, 0.1);
}

.stats-panel.no-data .stats-header {
    color: var(--text-secondary);
}

@media (max-width: 1400px) {
    .stats-panel {
        min-width: 300px;
    }

    .stats-grid {
        gap: 12px;
    }

    .stat-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 1200px) {
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        z-index: 999999;
    }

    .view-controls {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .stats-panel {
        min-width: auto;
        flex: 1;
    }
}

/* Feedback Controls */
.header-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.feedback-buttons {
    display: flex;
    gap: 8px;
}

.btn-feedback {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-feedback.pass {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-feedback.pass:hover,
.btn-feedback.pass.active {
    background-color: var(--success-color);
    color: white;
}

.btn-feedback.fail {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-feedback.fail:hover,
.btn-feedback.fail.active {
    background-color: var(--danger-color);
    color: white;
}

.comment-box-container {
    display: none;
    align-items: center;
    gap: 8px;
    animation: slideRight 0.3s ease;
}

.comment-box-container.visible {
    display: flex;
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#failComment {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 250px;
    outline: none;
}

#failComment:focus {
    border-color: var(--accent-color);
}

.btn-submit {
    background-color: var(--accent-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
}

.btn-submit:hover {
    background-color: #0ea5e9;
}

/* Overall Score Sidebar */
.overall-score-container {
    padding: 0 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    margin-top: -8px;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
    margin-bottom: 6px;
}

.score-bar-bg {
    width: 100%;
    height: 4px;
    background-color: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background-color: var(--success-color);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* AI Insights Panel */
.insights-panel {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 16px;
    margin-right: 16px;
    min-width: 280px;
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

.insights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #d8b4fe;
    /* Light purple */
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.insights-header i {
    font-size: 1rem;
    margin-right: 6px;
}

.ai-score-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-percent {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f0abfc;
    /* Light pink */
}

.insights-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Reason Dropdown (Pass case) */
.reason-container {
    position: relative;
    width: 100%;
}

.reason-btn {
    width: 100%;
    background-color: rgba(139, 92, 246, 0.15);
    color: #e2e8f0;
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;


}

.reason-btn:hover {
    background-color: rgba(139, 92, 246, 0.25);
    border-color: #d8b4fe;
}

.reason-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    /* bottom: auto; */
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    z-index: 50;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.reason-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.reason-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #cbd5e1;
}

/* Page Failure Blocks */
.page-blocks-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-block {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.page-block:hover {
    background-color: rgba(239, 68, 68, 0.3);
    border-color: #f87171;
    color: white;
    transform: translateY(-2px);
}

.fail-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background-color: #1e293b;
    /* Dark slate */
    border: 1px solid #ef4444;
    /* Red border */
    border-radius: 8px;
    padding: 12px;

    visibility: hidden;
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

/* Arrow for tooltip */
.fail-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: transparent transparent #ef4444 transparent;
}

.page-block:hover .fail-tooltip {
    visibility: visible;
    opacity: 1;
    top: calc(100% + 12px);

}

.tooltip-title {
    font-size: 0.75rem;
    color: #fca5a5;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
    text-transform: uppercase;
}

.tooltip-content {
    font-size: 0.8rem;
    color: #e2e8f0;
    line-height: 1.4;
}

/* Manual Pass Button */
.btn-manual-pass {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    min-width: 150px;
}

.btn-manual-pass:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.btn-manual-pass:active:not(:disabled) {
    transform: translateY(0);
}

.btn-manual-pass:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-manual-pass .btn-text,
.btn-manual-pass .btn-loader {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-manual-pass .btn-loader {
    color: rgba(255, 255, 255, 0.9);
}

.btn-manual-pass .btn-loader i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}