/* ============================================================
   Compare PDF — compare-pdf.css
   Prefix: cp-   Accent: #8B5CF6 (violet)
   ============================================================ */

.cp-section {
    --tool-accent: #8B5CF6;
    padding: 40px 0 80px;
}

.cp-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 18px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #8B5CF6;
    margin-bottom: 12px;
}

/* Upload grid */
.cp-upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.cp-upload-zone {
    display: block;
    border: 2px dashed rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    background: rgba(139, 92, 246, 0.03);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    outline: none;
}

.cp-upload-zone:hover,
.cp-upload-zone:focus-visible {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.07);
}

.cp-upload-zone.cp-drag-over {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
}

.cp-upload-zone.cp-zone-loaded {
    border-color: #8B5CF6;
    border-style: solid;
    background: rgba(139, 92, 246, 0.05);
}

.cp-zone-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.cp-zone-badge--original {
    background: rgba(139, 92, 246, 0.12);
    color: #7C3AED;
}

.cp-zone-badge--revised {
    background: rgba(139, 92, 246, 0.12);
    color: #7C3AED;
}

.cp-upload-icon {
    font-size: 2.25rem;
    color: #8B5CF6;
    opacity: 0.55;
    margin-bottom: 10px;
    display: block;
}

.cp-upload-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 5px;
}

.cp-upload-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 6px;
}

.cp-upload-formats {
    font-size: 0.75rem;
    color: var(--text-tertiary, #9CA3AF);
    margin: 0;
}

.cp-zone-file {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 0.8125rem;
    color: #8B5CF6;
    font-weight: 600;
}

.cp-zone-file[hidden] {
    display: none;
}

.cp-zone-check {
    font-size: 1.125rem;
}

.cp-zone-fname {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

/* Action bar */
.cp-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 12px;
}

.cp-action-bar[hidden] {
    display: none;
}

.cp-btn-compare {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cp-btn-compare:hover {
    background: #7C3AED;
}

.cp-btn-compare:disabled {
    background: var(--text-tertiary, #9CA3AF);
    cursor: not-allowed;
}

.cp-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.cp-reset-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

/* Progress */
.cp-progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.cp-progress-wrap[hidden] {
    display: none;
}

.cp-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color, #E5E7EB);
    border-radius: 3px;
    overflow: hidden;
}

.cp-progress-fill {
    height: 100%;
    width: 0;
    background: #8B5CF6;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.cp-progress-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 160px;
}

.cp-status {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.cp-status[hidden] {
    display: none;
}

.cp-status--success {
    background: rgba(22, 163, 74, 0.08);
    border: 1px solid rgba(22, 163, 74, 0.25);
    color: #15803D;
}

.cp-status--error {
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #B91C1C;
}

.cp-status--info {
    background: rgba(139, 92, 246, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #7C3AED;
}

/* Compare panel */
.cp-compare-panel[hidden] {
    display: none;
}

.cp-compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cp-summary {
    display: flex;
    gap: 8px;
}

.cp-summary-badge {
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

.cp-summary-added {
    background: rgba(22, 163, 74, 0.1);
    color: #15803D;
}

.cp-summary-removed {
    background: rgba(220, 38, 38, 0.1);
    color: #B91C1C;
}

.cp-summary-similarity {
    background: rgba(139, 92, 246, 0.1);
    color: #7C3AED;
}

.cp-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cp-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cp-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.cp-legend-added .cp-legend-swatch {
    background: rgba(22, 163, 74, 0.25);
}

.cp-legend-removed .cp-legend-swatch {
    background: rgba(220, 38, 38, 0.25);
}

.cp-legend-same .cp-legend-swatch {
    background: var(--border-color, #E5E7EB);
}

.cp-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 6px;
    background: var(--bg-secondary, #F9FAFB);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.cp-ghost-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.cp-compare-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-nav-changes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cp-nav-changes[hidden] {
    display: none;
}

.cp-nav-counter {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}

/* Diff layout with sidebar */
.cp-diff-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
}

/* When sidebar is hidden, side-by-side takes full width */
.cp-diff-layout:has(> .cp-sidebar[hidden]) {
    grid-template-columns: 1fr;
}

/* Sidebar */
.cp-sidebar {
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 10px;
    overflow: hidden;
    position: sticky;
    top: 16px;
    max-height: 534px;
    display: flex;
    flex-direction: column;
}

.cp-sidebar[hidden] {
    display: none;
}

.cp-sidebar-header {
    padding: 10px 14px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #7C3AED;
    background: rgba(139, 92, 246, 0.06);
    border-bottom: 1px solid var(--border-color, #E5E7EB);
    flex-shrink: 0;
}

.cp-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1;
}

.cp-sidebar-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
}

.cp-sidebar-item:hover {
    background: var(--bg-secondary, #F9FAFB);
}

.cp-sidebar-item.cp-sidebar-active {
    background: rgba(139, 92, 246, 0.08);
}

.cp-sidebar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.cp-sidebar-dot--del {
    background: #EF4444;
}

.cp-sidebar-dot--add {
    background: #22C55E;
}

.cp-sidebar-dot--mod {
    background: #F59E0B;
}

.cp-sidebar-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.cp-sidebar-page {
    font-size: 0.6875rem;
    color: var(--text-tertiary, #9CA3AF);
    flex-shrink: 0;
}

/* Side-by-side diff */
.cp-side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.cp-diff-col {
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 10px;
    overflow: hidden;
}

.cp-diff-col-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.06);
    border-bottom: 1px solid var(--border-color, #E5E7EB);
    font-size: 0.8125rem;
    font-weight: 700;
    color: #7C3AED;
}

.cp-diff-col-header--revised {
    background: rgba(139, 92, 246, 0.06);
    color: #7C3AED;
}

.cp-diff-content {
    padding: 16px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    background: var(--bg-input, #fff);
}

/* Collapse unchanged sections */
.cp-collapse-toggle {
    display: block;
    width: 100%;
    padding: 5px 12px;
    margin: 2px 0;
    background: rgba(139, 92, 246, 0.04);
    border: 1px dashed rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    color: #8B5CF6;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}

.cp-collapse-toggle:hover {
    background: rgba(139, 92, 246, 0.1);
}

.cp-collapse-block[hidden] {
    display: none;
}

/* Page label divider */
.cp-page-label {
    display: block;
    padding: 4px 6px;
    margin: 8px 0 2px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8B5CF6;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.cp-page-label:first-child {
    margin-top: 0;
    border-top: none;
}

/* Diff line highlight spans */
.cp-line {
    display: block;
    padding: 1px 6px;
    border-radius: 3px;
}

.cp-line-add {
    background: rgba(22, 163, 74, 0.15);
    color: #15803D;
}

.cp-line-del {
    background: rgba(220, 38, 38, 0.12);
    color: #B91C1C;
}

/* Modified line (paired del+add with word-level diff) */
.cp-line-mod {
    background: rgba(234, 179, 8, 0.08);
}

/* Intra-line word highlights */
mark.cp-word-del {
    background: rgba(220, 38, 38, 0.25);
    color: #B91C1C;
    border-radius: 2px;
    padding: 0 1px;
}

mark.cp-word-add {
    background: rgba(22, 163, 74, 0.25);
    color: #15803D;
    border-radius: 2px;
    padding: 0 1px;
}

@media (max-width: 700px) {
    .cp-section {
        padding: 24px 0 60px;
    }

    .cp-upload-grid {
        grid-template-columns: 1fr;
    }

    .cp-diff-layout {
        grid-template-columns: 1fr;
    }

    .cp-sidebar {
        position: static;
        max-height: 200px;
    }

    .cp-side-by-side {
        grid-template-columns: 1fr;
    }

    .cp-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .cp-btn-compare,
    .cp-reset-btn {
        justify-content: center;
    }

    .cp-zone-fname {
        max-width: 120px;
    }
}