/* ═══════════════════════════════════════════════════════════════
   Compare  (cmp-)  — faithful translation of fr-compare.jsx
   ═══════════════════════════════════════════════════════════════ */

/* ── Modal overlay variant (used when compare is embedded in the parts list) ── */
.cmp-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background:
        radial-gradient(120% 80% at 20% 0%, rgba(16,185,129,0.18), transparent 55%),
        rgba(8,46,34,.9);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 60px;
    font-family: 'Geist','Inter',system-ui,sans-serif;
    color: #0F172A;
    box-sizing: border-box;
}
.cmp-overlay * { box-sizing: border-box; }
.cmp-overlay .cmp-texture { position: absolute; }
.cmp-overlay .cmp-scroll-hint { position: relative; z-index: 1; }

/* ── Full-viewport dark-green shell ── */
.cmp-shell {
    min-height: 100vh;
    background:
        radial-gradient(120% 80% at 20% 0%, rgba(16,185,129,0.18), transparent 55%),
        #0B3D2E;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 70px;
    font-family: 'Geist','Inter',system-ui,sans-serif;
    color: #0F172A;
    box-sizing: border-box;
}
.cmp-shell * { box-sizing: border-box; }

/* Faint horizontal-line texture overlay */
.cmp-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .06;
    background-image: repeating-linear-gradient(
        0deg, #fff 0 1px, transparent 1px 64px
    );
}

/* Nav hidden on compare page */
body:has(.cmp-shell) .nh-header { display: none; }
body:has(.cmp-shell) main { padding-top: 0 !important; }

/* ── White modal card ── */
.cmp-modal {
    position: relative;
    z-index: 1;
    width: min(1100px, 96vw);
    max-height: 90vh;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 50px 120px -30px rgba(8,46,34,.7);
    display: flex;
    flex-direction: column;
}

/* ── Modal header ── */
.cmp-header {
    padding: 20px 26px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.cmp-kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #10B981;
    margin-bottom: 5px;
}
.cmp-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    color: #0F172A;
}
.cmp-close-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    border: 1px solid #E2E8F0;
    background: #fff;
    cursor: pointer;
    font-size: 19px;
    color: #64748B;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .12s, color .12s;
    line-height: 1;
}
.cmp-close-btn:hover { background: #F8FAFC; color: #0F172A; }

/* ── Scrollable body ── */
.cmp-body {
    overflow: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* ── Part header row (sticky) ── */
.cmp-head-row {
    display: grid;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 5;
    border-bottom: 1px solid #E2E8F0;
}
.cmp-head-spacer { padding: 18px; }
.cmp-head-cell {
    padding: 16px;
    border-left: 1px solid #E2E8F0;
    position: relative;
}
.cmp-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #64748B;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .1s, color .1s;
}
.cmp-remove-btn:hover { background: #FEF2F2; color: #DC2626; border-color: #FCA5A5; }
.cmp-head-img {
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #E2E8F0;
    margin-bottom: 12px;
}
.cmp-head-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cmp-head-stripe {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        45deg, rgba(16,185,129,.05) 0 9px, rgba(16,185,129,.10) 9px 18px
    );
    display: flex;
    align-items: center;
    justify-content: center;
}
.cmp-head-brand { font-size: 11px; color: #64748B; margin-bottom: 3px; }
.cmp-head-name  {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: #0F172A;
    line-height: 1.3;
    min-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ── Attribute rows ── */
.cmp-row {
    display: grid;
    border-bottom: 1px solid #E2E8F0;
    background: #fff;
}
.cmp-row.is-alt { background: #F8FAFC; }

.cmp-label {
    padding: 16px 18px;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748B;
    display: flex;
    align-items: center;
}
.cmp-cell {
    padding: 16px 18px;
    border-left: 1px solid #E2E8F0;
    font-size: 13.5px;
    color: #0F172A;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    background: transparent;
    transition: background .12s;
}
.cmp-cell.is-best { background: rgba(16,185,129,.07); }
.cmp-cell-mono {
    font-family: 'Geist Mono',ui-monospace,monospace;
    font-size: 12px;
    letter-spacing: .04em;
}

/* Price cell */
.cmp-price-amount {
    font-size: 22px;
    font-weight: 700;
    color: #0B3D2E;
    letter-spacing: -.02em;
    line-height: 1;
}
.cmp-best-badge {
    display: inline-flex;
    align-items: center;
    background: #10B981;
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .10em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Compat cells */
.cmp-compat-yes {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #14532D;
    font-weight: 600;
    font-size: 13.5px;
}
.cmp-compat-no {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #64748B;
    font-size: 13.5px;
}

/* Stock colours */
.cmp-stock-in  { color: #059669; font-weight: 600; }
.cmp-stock-low { color: #d97706; font-weight: 600; }
.cmp-stock-out { color: #64748B; }

/* ── Action row ── */
.cmp-action-row {
    display: grid;
}
.cmp-action-cell {
    padding: 18px;
    border-left: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cmp-add-btn {
    width: 100%;
    background: linear-gradient(135deg, #10B981 0%, #047857 100%);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-family: 'Geist','Inter',system-ui,sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .15s;
}
.cmp-add-btn:hover   { opacity: .9; }
.cmp-add-btn:disabled { opacity: .4; cursor: not-allowed; }
.cmp-add-btn.is-added { background: #047857; }
.cmp-view-btn {
    display: block;
    width: 100%;
    background: #fff;
    color: #0F172A;
    border: 1px solid #E2E8F0;
    padding: 11px;
    border-radius: 12px;
    font-family: 'Geist','Inter',system-ui,sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: border-color .12s;
}
.cmp-view-btn:hover { border-color: #10B981; color: #0B3D2E; }

/* ── Mobile scroll hint ── */
.cmp-scroll-hint {
    position: relative;
    z-index: 1;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,.55);
    font-family: 'Geist','Inter',system-ui,sans-serif;
}

/* ── Loading ── */
.cmp-loading {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Geist','Inter',system-ui,sans-serif;
    font-size: 15px;
    color: #64748B;
    background: #0B3D2E;
}

/* ── Empty state ── */
.cmp-empty {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 20px;
    padding: 60px 48px;
    text-align: center;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.cmp-empty h2 { font-size: 22px; font-weight: 700; margin: 0; color: #0F172A; }
.cmp-empty p  { font-size: 14.5px; color: #64748B; margin: 0; line-height: 1.6; }
.cmp-empty-btn {
    margin-top: 8px;
    display: inline-flex;
    padding: 13px 22px;
    background: #0B3D2E;
    color: #fff;
    border-radius: 12px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s;
}
.cmp-empty-btn:hover { background: #14532D; color: #fff; }

/* ── Responsive ── */
@media (max-width: 860px) {
    .cmp-shell { padding: 0; justify-content: flex-start; }
    .cmp-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
    .cmp-scroll-hint { display: none; }

    /* Mobile: horizontal scroll grid */
    .cmp-body {
        overflow-x: auto;
        overflow-y: auto;
    }
    .cmp-head-row,
    .cmp-row,
    .cmp-action-row {
        /* Override inline grid-template-columns with mobile values */
        grid-template-columns: 96px repeat(var(--cmp-cols, 2), 156px) !important;
        min-width: max-content;
    }

    /* Head */
    .cmp-head-cell   { padding: 12px; }
    .cmp-head-img    { border-radius: 9px; }
    .cmp-head-name   { font-size: 12px; min-height: unset; }
    .cmp-head-brand  { font-size: 10px; }
    .cmp-remove-btn  { width: 22px; height: 22px; font-size: 12px; }

    /* Rows */
    .cmp-label       { padding: 0 12px; font-size: 11.5px; height: 56px; }
    .cmp-cell        { padding: 0 12px; font-size: 12.5px; height: 56px; }
    .cmp-price-amount { font-size: 18px; }
    .cmp-compat-yes,
    .cmp-compat-no   { font-size: 12.5px; }
    .cmp-compat-yes svg,
    .cmp-compat-no svg { width: 14px; height: 14px; }

    /* Action */
    .cmp-action-cell { padding: 10px; height: 60px; justify-content: center; }
    .cmp-add-btn     { font-size: 12.5px; padding: 10px; border-radius: 10px; }
    .cmp-view-btn    { display: none; }
}

@media (max-width: 860px) {
    /* Use CSS custom property set by Blazor inline style workaround.
       Since we can't dynamically update a CSS variable from Razor easily,
       we override the grid columns via a JS-free approach:
       the cmp-body scrolls horizontally and the grid rows use min-width: max-content */
    .cmp-head-row,
    .cmp-row,
    .cmp-action-row { width: max-content; min-width: 100%; }
}
