/* Compare Passports */
#compare-section .compare-header {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    padding: 0 34px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

#compare-section .compare-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

#compare-section .compare-combo {
    position: relative;
}

#compare-section .compare-combo input {
    width: 100%;
    max-width: none;
    padding-right: 32px; /* space for reset icon */
    box-sizing: border-box;
}

#compare-section .compare-combo .clear-filter-btn {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

#compare-section .compare-input-col {
    min-width: 0;
    flex: 1 1 0;
    max-width: 460px;
}

#compare-section .compare-center-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 0 0 auto;
}

#compare-section .compare-grid {
    margin-top: 16px;
}

#compare-section .compare-table-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 24px 34px;
    box-sizing: border-box;
}

#compare-section .compare-header-row {
    width: 100%;
}

#compare-section .compare-table-header {
    display: grid;
    grid-template-columns: 1fr 180px 1fr;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 6px;
    position: sticky;
    top: 60px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    z-index: 5;
}

#compare-section .compare-header-cell {
    font-size: 1.2rem;
    font-weight: 650;
    color: var(--primary-blue-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

#compare-section .compare-header-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#compare-section .compare-pqi-winner-label {
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.4);
    letter-spacing: 0.06em;
}

#compare-section .compare-header-cell.center {
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#compare-section .compare-passport-flag {
    width: 32px;
    height: 22px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#compare-section .compare-table-body {
    display: flex;
    flex-direction: column;
}

#compare-section .compare-row {
    display: grid;
    grid-template-columns: 1fr 180px 1fr; /* Fixed center width for symmetry */
    align-items: center;
    gap: 24px; /* Increased gap */
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

#compare-section .compare-row:last-child {
    border-bottom: none;
}

#compare-section .compare-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

#compare-section .compare-cell.left-cell {
    justify-content: space-between; /* Numbers far left */
    padding-left: 10px;
}

#compare-section .compare-cell.right-cell {
    justify-content: space-between; /* Numbers far right */
    flex-direction: row-reverse;
    padding-right: 10px;
}

#compare-section .compare-cell.center {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
}

#compare-section .compare-metric-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

#compare-section .compare-value {
    font-weight: 600;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

#compare-section .compare-value-winner {
    color: #111827;
}

#compare-section .compare-value-loser {
    color: #9ca3af;
    opacity: 0.7;
}

#compare-section .compare-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    background: #bbf7d0;
    color: #047857;
    font-weight: 700;
}

#compare-section .compare-indicator.equal {
    background: #e5e7eb;
    color: #374151;
}

#compare-section .compare-indicator-value {
    font-weight: 700;
}

#compare-section .compare-indicator-arrow {
    font-size: 1.1rem;
    font-weight: 800;
    color: #065f46; /* darker green for accent */
}

#compare-section .compare-indicator-flag {
    width: 18px;
    height: 12px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

#compare-section .compare-indicator.win-left {
    background: #ecfdf5; /* Green */
    color: #047857;
}
#compare-section .compare-indicator.win-right {
    background: #ecfdf5; /* Green */
    color: #047857;
}

/* Row backgrounds - applied to cells */
#compare-section .compare-cell-win {
    background: #f0fdf4; /* bg-green-50 */
    border-radius: 8px;
    padding: 8px 12px;
}

#compare-section .compare-cell-lose {
    background: #fef2f2; /* bg-red-50 */
    border-radius: 8px;
    padding: 8px 12px;
}

#compare-section .compare-cell-equal {
    background: #fffbeb; /* bg-amber-50 */
    border-radius: 8px;
    padding: 8px 12px;
}

#compare-section .compare-progress-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

#compare-section .compare-progress-wrapper-left {
    margin-left: 12px;
}

#compare-section .compare-progress-wrapper-left .compare-progress-track {
    justify-content: flex-end;
}

#compare-section .compare-progress-wrapper-right {
    margin-right: 12px;
}

#compare-section .compare-progress-wrapper-right .compare-progress-track {
    justify-content: flex-start;
}

#compare-section .compare-progress-track {
    width: 100%;
    height: 6px;
    background: transparent;
    display: flex;
    align-items: center;
}

#compare-section .compare-progress-fill {
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
}

#compare-section .compare-progress-fill.winner {
    background: #10b981; /* Green */
}

#compare-section .compare-progress-fill.loser {
    background: #ef4444; /* Red */
    opacity: 0.3;
}

/* Dark Mode Overrides */
[data-theme="dark"] #compare-section .compare-table-card {
    background: #1f2937;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] #compare-section .compare-table-header {
    background: rgba(31, 41, 55, 0.95);
    border-bottom-color: #374151;
}

[data-theme="dark"] #compare-section .compare-header-cell {
    color: #60a5fa;
}

[data-theme="dark"] #compare-section .compare-row {
    border-bottom-color: #374151;
}

[data-theme="dark"] #compare-section .compare-value-winner {
    color: #f1f5f9;
}

[data-theme="dark"] #compare-section .compare-cell-win {
    background: rgba(6, 78, 59, 0.4);
    color: #e2e8f0;
}

[data-theme="dark"] #compare-section .compare-cell-lose {
    background: rgba(127, 29, 29, 0.4);
    color: #e2e8f0;
}

[data-theme="dark"] #compare-section .compare-cell-equal {
    background: rgba(113, 63, 18, 0.4);
    color: #e2e8f0;
}

[data-theme="dark"] #compare-section .compare-indicator.win-left,
[data-theme="dark"] #compare-section .compare-indicator.win-right {
    background: rgba(6, 78, 59, 0.4);
    color: #6ee7b7;
}

[data-theme="dark"] #compare-section .compare-indicator.equal {
    background: rgba(55, 65, 81, 0.6);
    color: #d1d5db;
}

[data-theme="dark"] #compare-section .compare-progress-fill {
    background: #4b5563;
}

[data-theme="dark"] #compare-section .compare-progress-fill.winner {
    background: #10b981;
}

[data-theme="dark"] #compare-section .compare-progress-fill.loser {
    background: #ef4444;
}

#compare-section .compare-progress-fill.equal {
    background: #fbbf24; /* Amber */
    opacity: 0.6;
}


#compare-section .compare-overall-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#compare-section .compare-overall-badge-equal {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.5);
}

#compare-section .compare-placeholder {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

#compare-section .compare-value-equal {
    color: #111827;
}

#compare-section .compare-row-region {
    position: relative;
}

#compare-section .compare-row-region::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.06);
}

@media (max-width: 900px) {
    #compare-section .compare-table-card {
        padding: 16px;
    }

    #compare-section .compare-table-header {
        grid-template-columns: 3fr 0.5fr 3fr; /* Very narrow center, use space for countries */
        gap: 4px;
        padding: 8px 10px 10px; /* Slightly reduced horizontal padding */
    }

    /* Fix Table Layout: Reduce center column width to allow values to fit */
    #compare-section .compare-row {
        gap: 8px;
        grid-template-columns: 3fr 0.5fr 3fr; /* Mirror header: narrow center, wider sides */
    }

    /* 1) Hide "Metric and difference" header text */
    #compare-section .compare-header-cell.center {
        visibility: hidden;
    }

    /* 2) Hide PQI WINNER label */
    #compare-section .compare-pqi-winner-label {
        display: none;
    }

    /* Compare header: stacked layout on mobile, aligned with card padding */
    #compare-section .compare-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 8px;
        padding: 0 16px;
        position: relative;
        z-index: 20;
        box-sizing: border-box;
    }

    #compare-section .compare-input-col {
        width: 100%;
        min-width: 0;
        padding: 0;
        position: relative;
        overflow: visible;
        max-width: none;
        flex: 1 1 auto;
    }

    #compare-section .compare-input-col:first-child {
        order: 1;
    }

    #compare-section .compare-input-col:last-child {
        order: 2;
    }

    #compare-section .compare-center-controls {
        width: 100%;
        padding: 0;
        justify-content: center;
        order: 3;
    }
    
    #compare-section .compare-center-controls button {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.95rem;
        min-height: 48px;
        height: auto;
        white-space: nowrap;
    }
    
    /* 4) Fix Header Alignment and Overflow */
    #compare-section .compare-header-cell {
        min-width: 0; /* Allow grid item to shrink below content size */
    }
    
    /* Ensure Country Names are visible */
    #compare-section .compare-header-main {
        max-width: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 4px; /* Prevent text from touching card edges */
    }

    #compare-section .compare-header-main span {
        flex: 1 1 auto;
        white-space: normal;
        word-break: break-word;
        font-size: 0.9rem; /* Slightly smaller font for long names on mobile */
    }

    #compare-section .compare-table-header .compare-passport-flag {
        flex-shrink: 0;
    }

    #compare-section .compare-table-header .compare-header-cell:first-child {
        justify-content: flex-end;
    }

    #compare-section .compare-table-header .compare-header-cell:last-child {
        justify-content: flex-start !important;
    }

    #compare-section .compare-table-header .compare-header-cell:first-child .compare-header-main {
        justify-content: flex-end;
        text-align: left; /* First country: left-aligned text */
    }

    #compare-section .compare-table-header .compare-header-cell:last-child .compare-header-main {
        justify-content: flex-start;
        text-align: right; /* Second country: right-aligned text */
    }
    
    /* 2) Remove PQI WINNER label from table header */
    #compare-section .compare-pqi-winner-label {
        display: none !important;
    }

    /* 4) Suggestions Styling - Match Main Page (High Z-Index, Proper Width) */
    #compare-section .suggest-box {
        z-index: 1000 !important; /* Force high z-index */
        min-width: 100%; /* At least input width */
        width: max-content; /* Allow to be wider if text is long */
        max-width: 80vw; /* Prevent overflow off screen */
    }
    
    /* Specific adjustments for left/right suggestion alignment */
    #compare-section .compare-input-col:first-child .suggest-box {
        left: 0 !important;
        right: auto !important;
    }
    
    #compare-section .compare-input-col:last-child .suggest-box {
        right: 0 !important;
        left: auto !important;
    }

    /* 5) Fix Regional Table Centering and Alignment */
    #compare-section .compare-cell-region {
        text-align: center;
        display: inline-block;
        width: auto;
    }

    /* Ensure values align to the edges */
    #compare-section .compare-cell.left-cell {
        justify-content: flex-start;
    }

    #compare-section .compare-cell.right-cell {
        justify-content: flex-end;
        text-align: right;
        justify-self: end;
        margin-left: auto;
    }

    /* 6) Compact, equal-width value blocks (PQI / VFE / Visa-free / Regional) */
    #compare-section .compare-cell-win,
    #compare-section .compare-cell-lose,
    #compare-section .compare-cell-equal {
        max-width: 88px;
        width: 88px;
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Center numbers inside all colored blocks (left and right country) */
    #compare-section .compare-cell .compare-value {
        display: block;
        width: 100%;
        text-align: center;
    }

    #compare-section .compare-cell.left-cell,
    #compare-section .compare-cell.right-cell {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* 7) Remove Regional Bars */
    #compare-section .compare-row-region .compare-progress-wrapper {
        display: none !important;
    }
}

#compare-section .compare-row-section-title {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 20px 0 10px;
    margin-top: 10px;
    border-top: 1px solid #f3f4f6;
}

#compare-section .compare-cell-region {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--dark-blue);
    text-align: center;
    position: relative;
    z-index: 1;
    background-color: #ffffff;
    padding: 0 4px;
    display: inline-block;
    border-radius: 4px;
}

@media (min-width: 768px) {
    .logic-blocks {
        flex-direction: row;
        align-items: stretch;
    }
    .logic-block {
        flex: 1;
    }
}

/* Dark Mode Overrides */
[data-theme="dark"] #compare-section .compare-table-card {
    background: #1f2937;
    box-shadow: none;
}
[data-theme="dark"] #compare-section .compare-table-header {
    background: rgba(31, 41, 55, 0.95);
    border-bottom-color: #374151;
}
[data-theme="dark"] #compare-section .compare-header-cell {
    color: var(--text-main);
}
[data-theme="dark"] #compare-section .compare-row {
    border-bottom-color: #374151;
}
[data-theme="dark"] #compare-section .compare-cell-win {
    background: rgba(6, 78, 59, 0.4);
    color: #e5e7eb;
}
[data-theme="dark"] #compare-section .compare-cell-lose {
    background: rgba(127, 29, 29, 0.4);
    color: #e5e7eb;
}
[data-theme="dark"] #compare-section .compare-cell-equal {
    background: rgba(113, 63, 18, 0.4);
    color: #e5e7eb;
}
[data-theme="dark"] #compare-section .compare-value-winner {
    color: #fff;
}
[data-theme="dark"] #compare-section .compare-value-loser {
    color: #9ca3af;
}
[data-theme="dark"] #compare-section .compare-value-equal {
    color: #d1d5db;
}
[data-theme="dark"] #compare-section .compare-row-section-title {
    color: var(--text-muted);
    border-top-color: #374151;
}
[data-theme="dark"] #compare-section .compare-cell-region {
    color: var(--text-main);
    background-color: #1f2937;
}
[data-theme="dark"] #compare-section .compare-row-region::before {
    background: #374151;
}

[data-theme="dark"] #compare-section .compare-combo input {
    background-color: #1f2937;
    color: var(--text-main);
    border-color: #374151;
}

[data-theme="dark"] #compare-section .compare-combo input::placeholder {
    color: #9ca3af;
}


