/* ================================================================
   Auto Part Finder — finder.css
   Desktop: single-row dropdowns + blue button  (image reference)
   Mobile:  compact box → bottom sheet modal
   ================================================================ */

/* ── Shared tokens ── */
.apf-finder {
    --apf-blue:   #2451ff;
    --apf-blue-h: #1c3fd1;
    --apf-ink:    #11162b;
    --apf-slate:  #5b6178;
    --apf-line:   #e3e6f0;
    --apf-bg:     #f6f7fb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--apf-ink);
}

.apf-finder * { box-sizing: border-box; }

/* ================================================================
   DESKTOP WIDGET
   ================================================================ */
.apf-finder--desktop {
    display: block;
    max-width: 1100px;
    margin: 0 auto;
}
.apf-finder--mobile { display: none; }

@media (max-width: 767px) {
    .apf-finder--desktop { display: none; }
    .apf-finder--mobile  { display: block; }
}

/* ── Widget header (title) ── */
.apf-widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.apf-widget-header__icon {
    width: 32px;
    height: 32px;
    background: rgba(36,81,255,.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--apf-blue);
}

.apf-widget-header__text {
    font-size: 15px;
    font-weight: 700;
    color: var(--apf-ink);
    letter-spacing: -.01em;
}

/* ── Row container ── */
.apf-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px 0;
    background: #fff;
    border: 1px solid var(--apf-line);
    border-radius: 16px;
    padding: 0 0 14px;
    box-shadow: 0 2px 16px -6px rgba(17,22,43,.10);
}

/* ── Each dropdown field ── */
.apf-row__field {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apf-row__label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--apf-slate);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 0 2px;
    white-space: nowrap;
}

.apf-row__label svg {
    color: var(--apf-blue);
    flex-shrink: 0;
}

.apf-row__select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    color: var(--apf-ink);
    background: #fff;
    border: 1px solid var(--apf-line);
    border-radius: 10px;
    padding: 11px 34px 11px 14px;
    cursor: pointer;
    transition: border-color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apf-row__select:disabled {
    color: var(--apf-slate);
    cursor: not-allowed;
    opacity: .55;
}

.apf-row__select:not(:disabled):hover { border-color: var(--apf-blue); }
.apf-row__select:focus { outline: none; border-color: var(--apf-blue); }

.apf-row__arrow {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--apf-slate);
    pointer-events: none;
}

/* ── Find Parts button ── */
.apf-row__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    color: #fff;
    background: var(--apf-blue);
    border: none;
    border-radius: 10px;
    padding: 11px 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .1s;
    letter-spacing: .01em;
}

.apf-row__btn:hover:not(:disabled) { background: var(--apf-blue-h); }
.apf-row__btn:active:not(:disabled) { transform: scale(.98); }

.apf-row__btn:disabled {
    background: var(--apf-line);
    color: var(--apf-slate);
    cursor: not-allowed;
}

/* ── Results ── */
.apf-finder__results { margin-top: 20px; }
.apf-finder__results:empty { margin-top: 0; }

/* ================================================================
   MOBILE WIDGET
   ================================================================ */

/* ── Closed box ── */
.apf-mob-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--apf-line);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 2px 10px -4px rgba(17,22,43,.08);
}

.apf-mob-box__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.apf-mob-box__icon {
    width: 36px;
    height: 36px;
    background: rgba(36,81,255,.08);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 19px;
    color: var(--apf-blue);
}

.apf-mob-box__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--apf-ink);
    line-height: 1.2;
}

.apf-mob-box__sub {
    font-size: 11.5px;
    color: var(--apf-slate);
    margin-top: 2px;
}

.apf-mob-box__btn {
    width: 36px;
    height: 36px;
    background: var(--apf-blue);
    border: none;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}

.apf-mob-box__btn:hover { background: var(--apf-blue-h); }

/* ── Selected state ── */
.apf-mob-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--apf-line);
    border-radius: 14px;
    padding: 10px 12px;
}

.apf-mob-selected__chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(36,81,255,.07);
    border: 1px solid rgba(36,81,255,.2);
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--apf-blue);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apf-mob-selected__chip i { font-size: 14px; flex-shrink: 0; }

.apf-mob-selected__search {
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 9px;
    flex-shrink: 0;
}

.apf-mob-selected__change {
    width: 34px;
    height: 34px;
    background: var(--apf-bg);
    border: 1px solid var(--apf-line);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--apf-slate);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .15s, color .15s;
}

.apf-mob-selected__change:hover { border-color: var(--apf-blue); color: var(--apf-blue); }

/* ── Sheet overlay ── */
.apf-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.apf-sheet-overlay.apf-sheet-overlay--open {
    opacity: 1;
    pointer-events: all;
}

/* ── Bottom sheet ── */
.apf-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 10px 16px 28px;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
}

.apf-sheet-overlay--open .apf-sheet { transform: translateY(0); }

.apf-sheet__handle {
    width: 32px;
    height: 4px;
    background: var(--apf-line);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.apf-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.apf-sheet__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--apf-ink);
}

.apf-sheet__close {
    width: 28px;
    height: 28px;
    background: var(--apf-bg);
    border: 1px solid var(--apf-line);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--apf-slate);
    cursor: pointer;
}

/* ── Progress bars ── */
.apf-sheet__progress {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.apf-sheet__prog-bar {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--apf-line);
    transition: background .2s;
}

.apf-sheet__prog-bar.apf-prog--done   { background: var(--apf-blue); }
.apf-sheet__prog-bar.apf-prog--active { background: var(--apf-blue); opacity: .45; }

/* ── Sheet fields ── */
.apf-sheet__field { margin-bottom: 12px; }

.apf-sheet__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--apf-slate);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 5px;
}

.apf-sheet__two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.apf-sheet__cta {
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 13px;
    border-radius: 12px;
    margin-top: 4px;
}

/* ================================================================
   VEHICLE BAR  (persistent after selection)
   ================================================================ */
.apf-vehicle-bar {
    background: rgba(36,81,255,.05);
    border: 1.5px solid rgba(36,81,255,.15);
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 20px;
    font-family: inherit;
}

.apf-vehicle-bar__inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.apf-vehicle-bar__icon  { color: var(--apf-blue); font-size: 20px; flex-shrink: 0; }
.apf-vehicle-bar__name  { font-weight: 600; font-size: 14.5px; color: var(--apf-ink); flex: 1; }
.apf-vehicle-bar__actions { display: flex; gap: 8px; flex-shrink: 0; }

.apf-vehicle-bar__btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    text-decoration: none;
    border: 1.5px solid var(--apf-blue);
    transition: background .15s, color .15s;
}

.apf-vehicle-bar__btn--change { background: var(--apf-blue); color: #fff; }
.apf-vehicle-bar__btn--change:hover { background: var(--apf-blue-h); color: #fff; }
.apf-vehicle-bar__btn--clear { background: #fff; color: #888; border-color: var(--apf-line); padding: 6px 10px; }
.apf-vehicle-bar__btn--clear:hover { border-color: #e53e3e; color: #e53e3e; }

/* ================================================================
   CATEGORY GRID
   ================================================================ */
.apf-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin: 20px 0 28px;
}

.apf-cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 10px 14px;
    border-radius: 14px;
    border: 1.5px solid var(--apf-line);
    background: #fff;
    text-decoration: none;
    color: var(--apf-slate);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, transform .12s;
}

.apf-cat-card:hover { border-color: var(--apf-blue); color: var(--apf-blue); transform: translateY(-2px); }
.apf-cat-card--active { border-color: var(--apf-blue); background: rgba(36,81,255,.04); color: var(--apf-blue); }

.apf-cat-card__img {
    width: 100px; height: 100px;
    border-radius: 10px;
    background: var(--apf-bg);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

.apf-cat-card__img img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.apf-cat-card__initial { font-size: 22px; font-weight: 700; color: var(--apf-blue); opacity: .5; }
.apf-cat-card__name { font-size: 12.5px; font-weight: 600; line-height: 1.3; color: inherit; }
.apf-cat-card__count { font-size: 11.5px; font-weight: 500; background: rgba(36,81,255,.08); color: var(--apf-blue); padding: 2px 9px; border-radius: 999px; }
.apf-cat-card--active .apf-cat-card__count { background: var(--apf-blue); color: #fff; }

@media (max-width: 480px) {
    .apf-cat-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
    .apf-cat-card__img { width: 80px; height: 80px; }
}

/* ================================================================
   PRODUCT STYLES
   ================================================================ */
.apf-product-price { font-weight: 700; color: var(--apf-blue); }
.apf-pc-compat { font-size: 11px; color: #22a55b; font-weight: 500; }

.apf-product-grid--4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.apf-product-card--a { border: 1px solid var(--apf-line); border-radius: 12px; background: #fff; overflow: hidden; transition: box-shadow .15s, transform .12s; }
.apf-product-card--a:hover { box-shadow: 0 8px 24px -12px rgba(17,22,43,.2); transform: translateY(-2px); }
.apf-pc-a-img { background: var(--apf-bg); }
.apf-pc-a-img img { width: 100%; height: 120px; object-fit: contain; padding: 8px; display: block; }
.apf-pc-a-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.apf-pc-a-name { font-size: 12.5px; font-weight: 500; color: var(--apf-ink); text-decoration: none; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.apf-product-card--a .apf-product-price { font-size: 13.5px; }

.apf-product-list { display: flex; flex-direction: column; gap: 8px; }
.apf-product-card--b { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 14px; border: 1px solid var(--apf-line); border-radius: 12px; background: #fff; padding: 12px; text-decoration: none; transition: border-color .15s; }
.apf-product-card--b:hover { border-color: var(--apf-blue); }
.apf-pc-b-img { width: 72px; height: 72px; background: var(--apf-bg); border-radius: 8px; overflow: hidden; }
.apf-pc-b-img img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.apf-pc-b-name { font-size: 13.5px; font-weight: 500; color: var(--apf-ink); margin-bottom: 3px; line-height: 1.3; }
.apf-pc-b-meta { font-size: 11.5px; color: var(--apf-slate); }
.apf-pc-b-right { text-align: right; }
.apf-pc-b-right .apf-product-price { font-size: 15px; display: block; margin-bottom: 4px; }

.apf-product-grid--3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.apf-product-card--c { border: 1px solid var(--apf-line); border-radius: 14px; background: #fff; overflow: hidden; transition: box-shadow .15s, transform .12s; }
.apf-product-card--c:hover { box-shadow: 0 10px 28px -14px rgba(17,22,43,.22); transform: translateY(-3px); }
.apf-pc-c-img { background: var(--apf-bg); }
.apf-pc-c-img img { width: 100%; height: 160px; object-fit: contain; padding: 12px; display: block; }
.apf-pc-c-body { padding: 12px 14px; }
.apf-pc-c-cat { font-size: 10.5px; color: var(--apf-slate); text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 4px; }
.apf-pc-c-name { font-size: 13px; font-weight: 500; color: var(--apf-ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; margin-bottom: 10px; }
.apf-pc-c-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.apf-pc-c-footer .apf-product-price { font-size: 14px; }
.apf-pc-c-btn { font-size: 11px; padding: 5px 12px; border-radius: 999px; border: 1.5px solid var(--apf-blue); color: var(--apf-blue); background: #fff; text-decoration: none; font-weight: 600; transition: background .15s, color .15s; white-space: nowrap; }
.apf-pc-c-btn:hover { background: var(--apf-blue); color: #fff; }

/* ================================================================
   RESULTS LAYOUT
   ================================================================ */
.apf-section-title { font-size: 18px; font-weight: 600; color: var(--apf-ink); margin: 0 0 18px; }

.apf-results-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
@media (max-width: 768px) { .apf-results-layout { grid-template-columns: 1fr; } }

.apf-sidebar { border: 1px solid var(--apf-line); border-radius: 14px; background: #fff; padding: 16px; position: sticky; top: 90px; }
.apf-sidebar__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.apf-sidebar__title { font-size: 14px; font-weight: 600; color: var(--apf-ink); display: flex; align-items: center; gap: 6px; }
.apf-sidebar__title .ti { font-size: 16px; color: var(--apf-blue); }
.apf-sidebar__reset { font-size: 12px; color: var(--apf-slate); background: none; border: none; cursor: pointer; font-family: inherit; padding: 0; text-decoration: underline; }
.apf-sidebar__reset:hover { color: var(--apf-blue); }
.apf-sidebar__section { border-top: 1px solid var(--apf-line); padding: 12px 0; }
.apf-sidebar__label { font-size: 12px; font-weight: 600; color: var(--apf-slate); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.apf-sidebar__check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--apf-ink); cursor: pointer; margin-bottom: 6px; }
.apf-sidebar__check input { accent-color: var(--apf-blue); }
.apf-price-range { display: flex; align-items: center; gap: 8px; }
.apf-price-input { flex: 1; border: 1px solid var(--apf-line); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; font-family: inherit; color: var(--apf-ink); background: var(--apf-bg); width: 0; }
.apf-price-input:focus { outline: none; border-color: var(--apf-blue); }

.apf-results-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.apf-results-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.apf-results-count { font-size: 14px; font-weight: 500; color: var(--apf-slate); }
.apf-back-cats { font-size: 13px; color: var(--apf-blue); text-decoration: none; font-weight: 500; }
.apf-back-cats:hover { text-decoration: underline; }
#apf-products-wrap { transition: opacity .2s ease; }

@media (prefers-reduced-motion: reduce) { .apf-sheet, .apf-sheet-overlay, .apf-row__btn { transition: none; } }

.apf-mob-hidden { display: none !important; }
