/**
 * Typesense Search Styles for MyPilotStore
 *
 * Combines Doofinder's 3-column grid with Findify's reviews/descriptions.
 * Color scheme matches MPS site (blue titles, teal buttons).
 */

/* ==========================================================================
   Layout
   ========================================================================== */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 8px 0;
    border-bottom: 1px solid #e8e8e8;
}

.results-header #stats {
    font-size: 13px;
    color: #555;
}

.results-header #stats strong {
    color: #222;
    font-weight: 600;
}

.search-layout {
    display: flex;
    gap: 30px;
}

.search-sidebar {
    width: 250px;
    flex-shrink: 0;
}

.search-results {
    flex: 1;
    min-width: 0;
}

/* ==========================================================================
   Mobile filter drawer (<=992px)

   Previously the sidebar simply stacked above the results, pushing the first
   hit ~2 screens down. Now results render immediately and the facets move into
   an off-canvas drawer behind a sticky "Filters" bar.

   The drawer chrome (.drawer-head/.drawer-foot/.drawer-backdrop) and the
   toggle button are mobile-only and stay hidden on desktop.
   ========================================================================== */

.drawer-head,
.drawer-foot,
.drawer-backdrop,
.mobile-filter-toggle {
    display: none;
}

@media (max-width: 992px) {
    .search-layout {
        flex-direction: column;
        gap: 0;
    }

    /* Pages without the drawer (findts.asp, providers/*) keep the original
       stacked sidebar. They have no toggle button and no drawer JS, so the
       off-canvas rules below must not reach them. */
    .search-layout:not(.has-filter-drawer) .search-sidebar {
        width: 100%;
        order: 1;
    }

    .search-layout:not(.has-filter-drawer) .search-results {
        order: 2;
    }

    /* Sticky results toolbar. --mps-fixed-header-h is measured at runtime from
       .head-mob-fixed (fixed, z-index 9999 at <=767px) so this parks directly
       beneath the site header instead of under it. */
    .has-filter-drawer .results-header {
        position: sticky;
        top: var(--mps-fixed-header-h, 0px);
        z-index: 1100;
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 8px 10px;
        background: #fff;
        margin-bottom: 14px;
        padding: 10px 0;
        box-shadow: 0 1px 0 #e8e8e8;
    }

    .has-filter-drawer .results-header #stats {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .mobile-filter-toggle {
        grid-row: 2;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 9px 14px;
        min-height: 42px;
        background: #fff;
        border: 1px solid #3a7ca5;
        border-radius: 4px;
        color: #3a7ca5;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .mobile-filter-toggle svg {
        width: 17px;
        height: 17px;
    }

    /* display:inline-flex would otherwise beat the UA's [hidden] rule */
    .mobile-filter-toggle .filter-badge[hidden] {
        display: none;
    }

    .mobile-filter-toggle .filter-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 19px;
        height: 19px;
        padding: 0 5px;
        border-radius: 10px;
        background: #3a7ca5;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
    }

    /* Active filters get a filled button so state is legible without opening */
    .mobile-filter-toggle.has-filters {
        background: #3a7ca5;
        color: #fff;
    }

    .mobile-filter-toggle.has-filters .filter-badge {
        background: #fff;
        color: #3a7ca5;
    }

    .has-filter-drawer .results-header #sort-by {
        grid-row: 2;
        justify-self: end;
    }

    .has-filter-drawer .results-header #sort-by .ais-SortBy-select {
        min-height: 42px;
        /* 16px avoids iOS Safari's focus zoom on select */
        font-size: 16px;
    }

    /* --- The drawer itself --- */
    .has-filter-drawer .search-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(87vw, 350px);
        /* Above .head-mob-fixed (9999) and .modal (10000) */
        z-index: 10002;
        display: flex;
        flex-direction: column;
        background: #fff;
        box-shadow: 2px 0 18px rgba(0, 0, 0, 0.2);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    }

    .has-filter-drawer .search-sidebar.is-open {
        transform: none;
        visibility: visible;
    }

    .drawer-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10001;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }

    .drawer-backdrop.is-open {
        opacity: 1;
        visibility: visible;
    }

    .drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        padding: 14px 16px;
        border-bottom: 1px solid #e8e8e8;
    }

    .drawer-title {
        font-size: 16px;
        font-weight: 700;
        color: #222;
    }

    .drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-right: -8px;
        background: none;
        border: none;
        color: #555;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
    }

    .facet-scroll {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 18px 16px 8px;
    }

    /* The drawer footer carries clear/apply, so the sidebar's own button is
       redundant here */
    .facet-scroll #clear-filters {
        display: none;
    }

    .drawer-foot {
        display: flex;
        flex-shrink: 0;
        gap: 10px;
        padding: 12px 16px;
        /* Clear the iOS home indicator */
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #e8e8e8;
        background: #fff;
    }

    .drawer-clear {
        flex: 0 0 auto;
        padding: 12px 16px;
        min-height: 46px;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: 4px;
        color: #444;
        font-size: 14px;
        cursor: pointer;
    }

    .drawer-clear:disabled {
        opacity: 0.45;
        cursor: default;
    }

    .drawer-apply {
        flex: 1;
        min-height: 46px;
        background: #3a7ca5;
        border: 1px solid #3a7ca5;
        border-radius: 4px;
        color: #fff;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
    }

    /* Bigger tap targets for facet rows inside the drawer */
    .has-filter-drawer .search-sidebar .ais-RefinementList-label,
    .has-filter-drawer .search-sidebar .ais-ToggleRefinement-label {
        padding: 7px 0;
        font-size: 14px;
    }

    .has-filter-drawer .search-sidebar .ais-RefinementList-checkbox,
    .has-filter-drawer .search-sidebar .ais-ToggleRefinement-checkbox {
        width: 19px;
        height: 19px;
    }

    .has-filter-drawer .search-sidebar .ais-RefinementList-labelText {
        max-width: none;
    }

    .has-filter-drawer .search-sidebar .ais-RefinementList-showMore {
        padding: 8px 0;
        font-size: 13px;
    }

    /* Locks the page behind the open drawer (scroll position is restored in JS) */
    body.mps-drawer-open {
        position: fixed;
        width: 100%;
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .has-filter-drawer .search-sidebar,
    .drawer-backdrop {
        transition: none;
    }
}

/* ==========================================================================
   Facets / Filters (Left Sidebar)
   ========================================================================== */

.facet-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.facet-section:last-of-type {
    border-bottom: none;
}

/* Shared with findts.asp and providers/*, whose headings are plain <h4>Brand</h4>
   with no button inside — these must keep styling them on their own. */
.facet-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Decorative caret for the plain-h4 pages (nothing there collapses) */
.facet-section h4::after {
    content: "^";
    font-size: 13px;
    color: #888;
    font-weight: 400;
}

/* find.asp only: the heading is a real collapse control, so the decorative
   caret gives way to the button's own state-reflecting chevron. */
.facet-section h4.facet-head {
    display: block;
}

.facet-section h4.facet-head::after {
    content: none;
}

.facet-section h4 .facet-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    /* Inherit from h4 so the two header styles can't drift apart */
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.facet-section h4 .facet-toggle::after {
    content: "";
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    margin-left: 10px;
    border-right: 2px solid #888;
    border-bottom: 2px solid #888;
    /* Caret up when open, down when collapsed */
    transform: translateY(2px) rotate(-135deg);
    transition: transform 0.2s;
}

.facet-section h4 .facet-toggle[aria-expanded="false"]::after {
    transform: translateY(-2px) rotate(45deg);
}

/* .facet-body is a sibling of h4, not of the button inside it, so this hangs
   off the section class rather than a sibling combinator */
.facet-section.is-collapsed .facet-body {
    display: none;
}

/* A collapsed section shouldn't hold open its bottom padding */
.facet-section.is-collapsed {
    padding-bottom: 12px;
}

/* Brand/Category search input */
.ais-RefinementList-searchBox {
    margin-bottom: 8px;
}

.ais-RefinementList-searchBox form {
    display: flex;
    position: relative;
}

.ais-RefinementList-searchBox .ais-SearchBox-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    height: 28px;
    box-sizing: border-box;
}

.ais-RefinementList-searchBox .ais-SearchBox-submit,
.ais-RefinementList-searchBox .ais-SearchBox-reset,
.ais-RefinementList-searchBox .ais-SearchBox-loadingIndicator {
    display: none;
}

.ais-SearchBox-form {
    margin: 0;
    padding: 0;
}

/* Refinement list items */
.ais-RefinementList-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: none;
    overflow: visible;
}

.ais-RefinementList-item {
    margin-bottom: 9px;
}

.ais-RefinementList-item:first-child {
    margin-top: 0;
}

.ais-RefinementList-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #444;
}

.ais-RefinementList-label:hover {
    color: #0066a1;
}

.ais-RefinementList-item--selected .ais-RefinementList-label {
    color: #0066a1;
    font-weight: 600;
}

.ais-RefinementList-checkbox {
    margin-right: 9px;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.ais-RefinementList-labelText {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 165px;
}

.ais-RefinementList-count {
    margin-left: 8px;
    color: #999;
    font-size: 12px;
}

/* Remove default parentheses */
.ais-RefinementList-count::before,
.ais-RefinementList-count::after {
    content: "";
}

/* Show more / View more button */
.ais-RefinementList-showMore {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 0;
    margin-top: 6px;
    display: block;
    width: 100%;
    text-align: right;
}

.ais-RefinementList-showMore:hover {
    color: #0066a1;
}

.ais-RefinementList-showMore--disabled {
    display: none;
}

/* Price range slider.
   InstantSearch.js v4's rangeSlider renders rheostat (bundled), NOT noUiSlider
   — the track/handle/tooltip styling comes from the satellite theme. Only this
   container padding is ours. */
.ais-RangeSlider {
    padding: 15px 4px 42px;
}

/* In stock toggle */
.ais-ToggleRefinement-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #444;
}

.ais-ToggleRefinement-checkbox {
    margin-right: 8px;
}

/* Clear filters button */
.ais-ClearRefinements-button {
    width: 100%;
    padding: 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
}

.ais-ClearRefinements-button:hover {
    background: #eee;
}

.ais-ClearRefinements-button--disabled {
    display: none;
}

/* Current refinements (active filter pills) */
.ais-CurrentRefinements {
    margin-bottom: 15px;
}

.ais-CurrentRefinements-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.ais-CurrentRefinements-item {
    display: flex;
    align-items: center;
}

.ais-CurrentRefinements-category {
    display: flex;
    align-items: center;
    background: #e6f2ff;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
}

.ais-CurrentRefinements-delete {
    background: none;
    border: none;
    color: #0066a1;
    cursor: pointer;
    margin-left: 6px;
    font-size: 14px;
    line-height: 1;
}

/* ==========================================================================
   Stats & Sort Header
   ========================================================================== */

#sort-by {
    display: flex;
    align-items: center;
    gap: 6px;
}

#sort-by::before {
    content: "Sorted by:";
    color: #555;
    font-size: 13px;
    white-space: nowrap;
}

#sort-by .ais-SortBy {
    position: relative;
}

#sort-by .ais-SortBy::after {
    content: "▼";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: #555;
    pointer-events: none;
}

#sort-by .ais-SortBy-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 4px 28px 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 130px;
}

/* ==========================================================================
   Product Cards (Hits) - 3 Column Grid
   ========================================================================== */

.ais-Hits-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* 2 columns on tablet */
@media (max-width: 992px) {
    .ais-Hits-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 1 column on mobile */
@media (max-width: 576px) {
    .ais-Hits-list {
        grid-template-columns: 1fr;
    }
}

.ais-Hits-item {
    padding: 0;
}

.product-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s;
}

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-image {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-title {
    font-size: 14px;
    font-weight: 500;
    color: #0066a1;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title:hover {
    color: #004d7a;
    text-decoration: underline;
}

.product-title mark {
    background: #fff3cd;
    color: #0066a1;
    padding: 0 2px;
}

/* Reviews (like Findify) */
.reviews {
    font-size: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reviews i {
    color: #000;
}

.reviews span {
    color: #666;
    font-size: 11px;
}

/* Short description (like Findify) */
.product-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

/* Pricing */
.product-price {
    margin-bottom: 0;
}

.price {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.price-was {
    font-size: 13px;
    color: #999;
    text-decoration: line-through;
    display: block;
    margin-bottom: 2px;
}

.price-was::before {
    content: "List Price: ";
}

.price-now {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

/* See Details button (like Doofinder) */
.btn-see-details {
    display: block;
    width: 100%;
    padding: 12px;
    background: #3a7ca5;
    color: white;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-see-details:hover {
    background: #2d6180;
    color: white;
}

/* Inline link-style button (used in zero-results "clear filters" message) */
.link-btn {
    background: none;
    border: none;
    color: #0066a1;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}

/* ==========================================================================
   No Results
   ========================================================================== */

.no-results {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    grid-column: 1 / -1;
}

.no-results h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 10px;
}

.no-results p {
    color: #666;
    font-size: 14px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.ais-Pagination {
    margin-top: 30px;
}

.ais-Pagination-list {
    display: flex;
    justify-content: center;
    gap: 5px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.ais-Pagination-item {
    display: flex;
}

.ais-Pagination-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.ais-Pagination-link:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.ais-Pagination-item--selected .ais-Pagination-link {
    background: #3a7ca5;
    border-color: #3a7ca5;
    color: white;
}

.ais-Pagination-item--disabled .ais-Pagination-link {
    color: #ccc;
    cursor: not-allowed;
}

.ais-Pagination-item--disabled .ais-Pagination-link:hover {
    background: white;
    border-color: #ddd;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.hidden {
    display: none !important;
}

/* Make product card relative for badge positioning and overflow visible only on blog/support/badge cards */
.card-blog,
.card-support,
.product-card.has-badge {
    position: relative;
    overflow: visible !important;
}

/* Ensure top image container rounds top corners since card overflow is visible on blog/support/badge cards */
.card-blog .product-image,
.card-support .product-image,
.product-card.has-badge .product-image {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    overflow: hidden;
}

/* ==========================================================================
   Blog and Support Cards Styles
   ========================================================================== */

.card-blog {
    border-color: #bee5eb;
    background-color: #fcfcfd;
}

.card-support {
    border-color: #c3e6cb;
    background-color: #fcfdfc;
}

.btn-blog {
    background: #17a2b8;
}

.btn-blog:hover {
    background: #138496;
}

.btn-support {
    background: #28a745;
}

.btn-support:hover {
    background: #218838;
}

.support-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2f0d9;
    height: 180px;
    position: relative;
    border-bottom: 1px solid #eee;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    overflow: hidden;
}

.support-icon {
    width: 64px;
    height: 64px;
    color: #28a745;
}

/* Offer Ribbon Badge (Folded Ribbon) styles - renamed to avoid conflicts with global .offer-btn */
.mps-ribbon-badge {
    position: absolute;
    left: 0px;
    top: -10px;
    color: #fff;
    text-align: center;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 700;
    padding: 0px 15px;
    min-height: 25px;
    line-height: 25px;
    min-width: 80px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mps-ribbon-badge span {
    display: block;
    color: #fff;
}

/* CSS-only swallow-tail ribbon notch on the right */
.mps-ribbon-badge span:after {
    content: "";
    position: absolute;
    right: -10px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 12.5px solid transparent;
    border-bottom: 12.5px solid transparent;
    border-right: 10px solid transparent;
    border-left: 0;
}

/* Folded shadow corner on bottom-left */
.mps-ribbon-badge span:before {
    content: "";
    position: absolute;
    left: -15px; /* offsets the padding of .mps-ribbon-badge */
    bottom: -10px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-left: 10px solid transparent;
}

/* Color Modifiers */
.mps-ribbon-badge--blog {
    background: #17a2b8; /* teal */
}
.mps-ribbon-badge--blog span:after {
    border-top-color: #17a2b8;
    border-bottom-color: #17a2b8;
}
.mps-ribbon-badge--blog span:before {
    border-top-color: #117a8b;
}

.mps-ribbon-badge--support {
    background: #54b852; /* standard green */
}
.mps-ribbon-badge--support span:after {
    border-top-color: #54b852;
    border-bottom-color: #54b852;
}
.mps-ribbon-badge--support span:before {
    border-top-color: #3b7946;
}

.mps-ribbon-badge--webflag {
    background: #54b852; /* standard green */
}
.mps-ribbon-badge--webflag span:after {
    border-top-color: #54b852;
    border-bottom-color: #54b852;
}
.mps-ribbon-badge--webflag span:before {
    border-top-color: #3b7946;
}



