/* ============================================
   Proposal Details — Redesigned UI
   4-section layout: Overview, Analysis, Decision, Validation
   ============================================ */

/* --- Section Card --- */
.proposal-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.proposal-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-inset);
}

.proposal-section__title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0;
}

.proposal-section__body {
    padding: 1.25rem;
}

/* Section accent variants */
.proposal-section--decision .proposal-section__header {
    background: var(--primary-light);
    border-bottom-color: var(--primary-100);
}

.proposal-section--decision .proposal-section__title {
    color: var(--primary-700);
}

/* --- Section Header Left --- */
.proposal-section__header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.proposal-header__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.proposal-header__separator {
    color: var(--slate-300);
}

/* --- Review Banner --- */
.review-banner {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

.review-banner--approved {
    background: var(--success-light);
    border: 1px solid #A7F3D0;
    color: var(--success-dark);
}

.review-banner--rejected {
    background: var(--danger-light);
    border: 1px solid #FECACA;
    color: var(--danger-dark);
}

.review-banner--cancelled {
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    color: var(--slate-600);
}

.review-banner__icon {
    font-size: 1.125rem;
    margin-top: 1px;
    flex-shrink: 0;
}

.review-banner__details {
    flex: 1;
}

.review-banner__title {
    font-weight: 600;
    margin-bottom: 2px;
}

.review-banner__comment {
    font-size: 0.8125rem;
    font-style: italic;
    margin-top: 0.25rem;
    opacity: 0.85;
}

/* --- Four-Column Address Table --- */
.address-table--four-col {
    table-layout: fixed;
}

.address-table--four-col th:nth-child(1) { width: 15%; }
.address-table--four-col td:nth-child(2) { width: 35%; }
.address-table--four-col th:nth-child(3) {
    width: 15%;
    border-left: 1px solid var(--border-subtle);
    padding-left: 1.25rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.address-table--four-col td:nth-child(4) {
    width: 35%;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* --- Address Table --- */
.address-table {
    width: 100%;
    margin: 0;
}

.address-table th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 0.875rem;
    width: 130px;
    vertical-align: top;
    border: none;
}

.address-table td {
    font-size: 0.9375rem;
    color: var(--text-primary);
    padding: 0.5rem 0.875rem;
    border: none;
    font-weight: 500;
}

/* --- Metadata Footer --- */
.proposal-meta-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0.875rem;
    margin-top: 0.875rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.proposal-meta-footer__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

/* --- System Suggestion Bar --- */
.system-suggestion-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    background: var(--bg-inset);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--slate-400);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.system-suggestion-bar__left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.system-suggestion-bar__left > i {
    color: var(--text-muted);
}

.system-suggestion-bar__separator {
    color: var(--slate-300);
    margin: 0 0.125rem;
}

.system-suggestion-bar__reason {
    color: var(--text-secondary);
}

/* --- Analysis Scores --- */
.analysis-scores {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem 0.75rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.analysis-scores__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.analysis-scores__label {
    color: var(--text-muted);
}

.analysis-scores__separator {
    width: 1px;
    height: 14px;
    background: var(--slate-200);
    margin: 0 0.125rem;
}

.analysis-scores__diff {
    color: #B45309;
    font-weight: 600;
}

/* --- Match Candidates Table --- */
.match-table {
    width: 100%;
    font-size: 0.8125rem;
    margin: 0;
}

.match-table thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.625rem 0.75rem;
    background: var(--bg-inset);
    border-bottom: 1px solid var(--border-color);
}

.match-table tbody td {
    padding: 0.625rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
}

.match-table tbody tr:last-child td {
    border-bottom: none;
}

.match-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.03);
}

/* Match row variants */
.match-row--best {
    border-left: 3px solid var(--success);
    background: rgba(16, 185, 129, 0.04);
}

.match-row--best:hover {
    background: rgba(16, 185, 129, 0.08);
}

.match-row--selected {
    background: rgba(16, 185, 129, 0.06);
    border-left: 3px solid var(--success);
}

.match-row--selected:hover {
    background: rgba(16, 185, 129, 0.1);
}

.match-row--highlighted {
    background: rgba(59, 130, 246, 0.04);
    border-left: 3px solid var(--info);
}

/* --- Search Tag --- */
.search-tag {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-tag--zip {
    background: var(--info-light);
    color: var(--info-dark);
}

.search-tag--address {
    background: #F3E8FF;
    color: #7C3AED;
}

/* --- Score Badge --- */
.score-badge {
    font-size: 0.625rem;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    white-space: nowrap;
    margin-left: 0.25rem;
}

.score-badge--high {
    background: var(--success-light);
    color: var(--success-dark);
}

.score-badge--medium {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.score-badge--low {
    background: var(--danger-light);
    color: var(--danger-dark);
}

/* --- Tooltip on Cells --- */
[data-search-tooltip] {
    position: relative;
    cursor: help;
}

[data-search-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-bottom: 1px dotted var(--slate-400);
}

[data-search-tooltip]:hover::before {
    content: attr(data-search-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    background: var(--slate-800);
    color: var(--text-inverse);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 400;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

/* --- Comparison Table V2 --- */
.comparison-table-v2 {
    width: 100%;
    font-size: 0.8125rem;
    margin: 0;
}

.comparison-table-v2 thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 0.875rem;
    background: var(--bg-inset);
    border-bottom: 1px solid var(--border-color);
}

.comparison-table-v2 tbody td {
    padding: 0.75rem 0.875rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
}

.comparison-table-v2 tbody tr:last-child td {
    border-bottom: none;
}

/* Changed row */
.comparison-row--changed {
    border-left: 3px solid var(--warning);
    background: var(--warning-light);
}

.comparison-row--changed:hover {
    background: #FEF3C7;
}

/* Unchanged row */
.comparison-row--unchanged td {
    color: var(--text-muted);
}

.comparison-row--unchanged:hover td {
    color: var(--text-secondary);
}

/* Change marker */
.change-marker {
    color: #D97706;
    font-weight: 700;
    margin-left: 0.25rem;
    font-size: 0.75rem;
}

/* --- Action Toolbar --- */
.proposal-action-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 0 0;
    margin-top: 0.875rem;
    border-top: 1px solid var(--border-subtle);
}

.proposal-action-toolbar__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.proposal-action-toolbar__tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* --- Match Candidates Section --- */
.match-candidates-section {
    margin-bottom: 1.5rem;
}

.match-candidates-section__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.match-candidates-section__title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Decision Action Bar --- */
.decision-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 1rem 0;
}

.decision-actions--footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
}

/* --- No Changes Alert --- */
.no-changes-alert {
    padding: 1.25rem;
    background: var(--success-light);
    border: 1px solid #A7F3D0;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.no-changes-alert__title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--success-dark);
    margin-bottom: 0.25rem;
}

.no-changes-alert__text {
    font-size: 0.8125rem;
    color: var(--success-dark);
    margin-bottom: 0;
    opacity: 0.85;
}

/* --- Expandable Other Matches --- */
.other-matches {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.other-matches summary {
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    background: var(--bg-inset);
    list-style: none;
    transition: background var(--transition-fast);
}

.other-matches summary:hover {
    background: var(--slate-100);
}

.other-matches summary::-webkit-details-marker {
    display: none;
}

.other-matches summary::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.625rem;
    margin-right: 0.5rem;
    display: inline-block;
    transition: transform var(--transition-base);
    color: var(--text-muted);
}

.other-matches[open] summary::before {
    transform: rotate(90deg);
}

.other-matches[open] summary {
    border-bottom: 1px solid var(--border-color);
}

/* --- Field Approval Status Summary --- */
.field-status-summary {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

/* --- Conflict Warning --- */
.conflict-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--warning-light);
    border: 1px solid #FDE68A;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--warning-dark);
    margin-bottom: 1rem;
    font-weight: 500;
}

/* --- Review History Panel --- */
.review-history-panel {
    font-size: 0.75rem;
}

/* --- Address Search Info --- */
.address-search-info {
    padding: 0.75rem 1rem;
    background: var(--warning-light);
    border: 1px solid #FDE68A;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--warning-dark);
}

/* --- Match Table Dropdown Fix --- */
.match-table .dropdown-menu {
    z-index: 1050;
}

.proposal-section .table-responsive,
.match-candidates-section .table-responsive {
    overflow: visible;
}

/* --- ZIP Lookup Link --- */
.zip-lookup-link {
    color: var(--text-muted);
    font-size: 0.6875rem;
    margin-left: 0.25rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.zip-lookup-link:hover {
    color: var(--primary);
}

/* --- Sticky Decision Bar --- */
.decision-bar-sticky {
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    border-top: 2px solid var(--border-color);
    padding: var(--space-4) var(--space-6);
    margin: 0 calc(-1 * var(--space-6));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.decision-bar-sticky .btn {
    min-width: 120px;
}

/* --- Responsive --- */
@media (max-width: 767px) {
    .proposal-section__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .proposal-section__header-left {
        flex-wrap: wrap;
    }
    .system-suggestion-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .decision-actions {
        flex-direction: column;
    }
    .proposal-action-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .address-table--four-col th:nth-child(3) {
        border-left: none;
        padding-left: 0.875rem;
    }
}
