﻿/* ========================================================================
   HJULGUIDE — Fitment UI
   Replace /css/_fitment.css with this file
   ===================================================================== */

/* ---------- Theme tokens ---------- */
:root {
    --bg: #f7f8fb;
    --card: #ffffff;
    --text: #121417;
    --muted: #6b7280;
    --border: #e5e7eb;
    --ring: #9ad72c; /* focus + accent */
    --primary: #b7ea29; /* lime button bg */
    --primary-ink: #0f172a;
    --chip-bg: #f3f4f6;
    --chip-on: #e8f7c4;
    --chip-ink: #0f172a;
    --badge: #eef2ff;
    --badge-wheels: #e6f0ff;
    --badge-tires: #e7ffe6;
    --badge-both: #fff6e6;
    --danger: #ef4444;
    --ok: #059669;
    --low: #ca8a04;
}

/* ---------- Resets / helpers ---------- */
html, body {
    background: var(--bg);
    color: var(--text);
}

#hjulguide {
    scroll-margin-top: 24px;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--muted);
}

.fitment-muted {
    color: var(--muted);
    font-style: italic;
}

.is-loading {
    overflow: hidden;
}

/* ---------- Buttons ---------- */
button, .btn-primary, .btn-secondary, .btn-tertiary, .btn-mode {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-ink);
    padding: 10px 16px;
    border-radius: 14px;
    font-weight: 700;
    transition: filter .15s ease, transform .02s ease;
}

    .btn-primary:hover {
        filter: brightness(0.98);
    }

    .btn-primary:active {
        transform: translateY(1px);
    }

    .btn-primary[disabled], .btn-primary[aria-disabled="true"] {
        opacity: .5;
        cursor: not-allowed;
    }

.btn-secondary {
    background: #eef2f7;
    color: #111827;
    padding: 9px 14px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-tertiary {
    background: transparent;
    color: #111827;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-weight: 600;
}

.btn-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    min-width: 140px;
    font-weight: 700;
}

    .btn-mode.is-active {
        outline: 2px solid var(--ring);
        outline-offset: 2px;
    }

/* ---------- Focus rings ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: 10px;
}

/* ---------- Header & row ---------- */
.fitment-app {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 16px 32px;
}

.fitment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 16px;
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--badge);
    padding: 6px 12px;
    border-radius: 9999px;
    font-weight: 800;
    letter-spacing: .2px;
    user-select: none;
}

.mode-badge--wheels {
    background: var(--badge-wheels);
}

.mode-badge--tires {
    background: var(--badge-tires);
}

.mode-badge--both {
    background: var(--badge-both);
}

/* Center the whole block on desktop */
.fitment-row {
    display: flex;
    align-items: center;
    justify-content: center; /* center contents horizontally */
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    /* keep the row nicely centered and not too wide */
    max-width: 720px; /* tweak to taste */
    margin: 0 auto; /* center the row in its parent */
}

    /* Inputs: centered text and flexible width */
    .fitment-row input[type="text"],
    .fitment-row input[type="number"] {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px 14px;
        text-align: center; /* center the text in the input */
        min-width: 260px;
        width: 100%;
        flex: 0 1 360px; /* allow input to grow/shrink but stay ~360px */
    }

/* Slightly wider & tighter on larger screens */
@media (min-width: 1024px) {
    .fitment-row {
        gap: 16px;
        max-width: 820px;
        padding: 20px;
    }

        .fitment-row input[type="text"],
        .fitment-row input[type="number"] {
            flex-basis: 420px; /* nicer default width on desktop */
        }
}


/* ---------- Manual form ---------- */
.manual-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    margin-top: 10px;
}

    .manual-wrap input {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px 12px;
    }

#manual-toggle {
    margin-left: auto;
}

/* ---------- Cards (vehicle/fitment) ---------- */
.cards {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
}

.card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

    .card__header img {
        width: 28px;
        height: 28px;
        object-fit: contain;
    }

.card__body {
    color: #111827;
}

    .card__body.grid {
        display: grid;
        gap: 8px 16px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

.card .label {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Chips ---------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    background: var(--chip-bg);
    color: var(--chip-ink);
    padding: 8px 12px;
    border-radius: 9999px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background .15s ease, border-color .15s ease;
}

    .chip:hover {
        background: #e9ecef;
    }

.chip--active {
    background: var(--chip-on);
    border-color: #cce79a;
}

.chip--trim {
    font-weight: 700;
}

/* ---------- Filters ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    margin-top: 10px;
}

    .filters select, .filters input {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 8px 10px;
    }

/* ---------- Results ---------- */
.result-block {
    margin-top: 16px;
}

.prod-grid {
    --min: 240px;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(var(--min), 1fr));
    margin-top: 10px;
}

.prod-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
}

.prod-media {
    display: grid;
    place-items: center;
    background: #f9fafb;
    border-radius: 12px;
    overflow: hidden;
}

.prod-img {
    width: 100%;
    height: 180px;
    object-fit: contain;
}

.prod-title {
    font-weight: 700;
    line-height: 1.25;
    min-height: 2.5em;
}

.size-badge {
    padding: 2px 8px;
    border-radius: 9999px;
    background: #eef2ff;
    font-weight: 700;
}

.prod-meta {
    color: var(--muted);
    font-size: 14px;
}

.prod-price {
    font-weight: 800;
    font-size: 18px;
}

.prod-qty .qty-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 12px;
}

.qty--ok {
    background: #ecfdf5;
    color: var(--ok);
}

.qty--low {
    background: #fefce8;
    color: var(--low);
}

.qty--out {
    background: #fee2e2;
    color: var(--danger);
}

.prod-cta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.prod-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 10px;
    background: #eef2f7;
    color: #111827;
    font-weight: 700;
    text-decoration: none;
}

.prod-cart, .prod-pick {
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #fff;
}

    .prod-pick.chip {
        border: 1px dashed #cbd5e1;
    }

    .prod-cart[disabled], .prod-pick[disabled] {
        opacity: .45;
        cursor: not-allowed;
    }

.paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

    .paging #wheels-info, .paging #tires-info {
        font-weight: 700;
    }

/* ---------- Combo tray ---------- */
.combo {
    position: sticky;
    bottom: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(16,24,40,.05);
}

.combo__row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.combo__total {
    margin-left: auto;
    font-size: 18px;
}

.combo__actions {
    display: flex;
    gap: 8px;
}

/* ---------- Loading overlay ---------- */
.fitment-loading {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.7);
    z-index: 80;
}

.fitment-loading__box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.fitment-spinner {
    width: 18px;
    height: 18px;
    border-radius: 9999px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--ring);
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Mode picker dialog ---------- */
.mode-modal {
    width: min(560px, 92vw);
    border: 0;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(16,24,40,.2);
}

.mode-modal__inner {
    background: #fff;
}

.mode-modal__head {
    padding: 18px 18px 0;
}

.mode-modal__title {
    margin: 0 0 4px;
}

.mode-modal__sub {
    margin: 0 0 10px;
    color: var(--muted);
}

.mode-modal__actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 18px;
}

.mode-modal__foot {
    padding: 0 18px 18px;
    display: flex;
    justify-content: flex-end;
}

.mode-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}

    .mode-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
    }

/* Fallback for browsers without <dialog> support */
.no-dialog .mode-modal[open] {
    display: block;
    position: fixed;
    inset: 50% auto auto 50%;
    transform: translate(-50%,-50%);
}

/* ---------- FAQ ---------- */
#faq .card details {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

    #faq .card details:last-child {
        border-bottom: 0;
    }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .fitment-row {
        flex-wrap: wrap;
    }

    .manual-wrap {
        grid-template-columns: 1fr 1fr;
    }

    .card__body.grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .mode-modal__actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .fitment-row input[type="text"] {
        min-width: 0;
        flex: 1 1 220px;
    }

    .prod-img {
        height: 150px;
    }

    .combo__total {
        margin-left: 0;
    }
}

/* ===== BETA banner ===== */
.beta-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    margin: 12px 0;
    padding: 10px 12px;
    background: #fffbeb; /* soft gul */
    border: 1px solid #f5e3a3;
    color: #1f2937;
    border-radius: 12px;
}

.beta-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #f59e0b;
    box-shadow: 0 0 0 2px #fde68a inset;
    display: inline-block
}

.beta-link {
    margin-left: auto;
    font-weight: 700;
    color: #111827;
    text-decoration: underline
}

.beta-dismiss {
    position: absolute;
    right: 8px;
    top: 6px;
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

    .beta-dismiss:hover {
        color: #111827
    }

/* ===== Plate widget (SE style) ===== */
.plate-widget {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;
    background: #f9fafb;
}

.plate-header h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
}

.plate-sub {
    margin: 0 0 10px;
    color: #6b7280;
}

.plate-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.plate-flag {
    background: #006aa7;
    color: #fff;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: .95rem;
    line-height: 1;
}

#plate {
    flex: 1 1 220px;
    height: 44px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 0 12px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: #fff;
    color: #111827;
}

    #plate:focus {
        outline: none;
        border-color: #CEE646;
        background: #fff;
        box-shadow: 0 0 0 3px rgba(206,230,70,.25);
    }

.btn-primary, .btn-ghost {
    height: 44px;
    border-radius: 12px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: #CEE646;
    color: #000;
}

    .btn-primary:hover {
        filter: brightness(.96);
    }

.btn-ghost {
    background: #f3f4f6;
    color: #111827;
    border-color: #e5e7eb;
}

.plate-status {
    margin-top: 8px;
    font-size: .95rem;
    color: #374151;
}

    .plate-status.ok {
        color: #16a34a;
    }

    .plate-status.err {
        color: #dc2626;
    }

    .plate-status.loading {
        color: #6b7280;
    }
