/* Advanced Search (/products/product-search.php)
   Layout pieces only; cards, buttons, pagination, chips and fonts come from
   style.css, category.css and materialize. Scoped to #ps / .ps-* so nothing leaks. */

/* category.css offsets this banner heading for the category sidebar; there is none here */
div.top-category-heading { margin-left: 20px; }

.ps-layout {
    clear: both;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 28px;
    padding: 0 20px 40px;
    align-items: start;
}

/* ---------- filters sidebar ---------- */
.ps-filters {
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 20px);
    overflow: auto;
    padding: 4px 6px 0 0;
}
.ps-fhead { display: flex; align-items: center; justify-content: space-between; }
.ps-filters-title { font-family: 'Oswald', sans-serif; font-size: 26px; line-height: 1.2; margin: 6px 0; color: #000; }
.ps-close-filters { display: none; border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: #333; }
.ps-close-filters:hover { background: #f2f2f2; }
.ps-grp { border-bottom: 1px solid #e0e0e0; position: relative; }
.ps-grp > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0 8px;
    cursor: pointer;
    user-select: none;
    min-height: 24px;
}
.ps-grp > summary::-webkit-details-marker { display: none; }
.ps-gt { font-family: 'Oswald', sans-serif; font-size: 20px; line-height: 1.2; color: #000; }
.ps-help { font-size: 18px; color: #595959; }
.ps-chev { margin-left: auto; color: #595959; transition: transform .15s; }
.ps-grp[open] > summary .ps-chev { transform: rotate(180deg); }
.ps-gclear { position: absolute; right: 30px; top: 12px; }
.ps-gbody { padding: 2px 0 14px; }

.ps-list { margin: 0; padding: 0; list-style: none; }
.ps-cols2 { columns: 2; column-gap: 12px; }
.ps-opt { display: flex; align-items: center; gap: 7px; padding: 2px 0; font-size: 13px; color: #333; break-inside: avoid; }
.ps-opt input { accent-color: #cc0000; width: 16px; height: 16px; margin: 0; flex: none; }
.ps-opt label { font-size: 13px; color: #333; cursor: pointer; min-height: 24px; display: inline-flex; align-items: center; gap: 4px; }
.ps-n { font-size: 11px; color: #595959; }
.ps-opt.zero label { color: #767676; }
.ps-ctlsearch, .ps-range input {
    width: 100%;
    height: 34px;
    border: 0;
    border-bottom: 1px solid #9e9e9e;
    background: transparent;
    padding: 0 2px;
    font-size: 14px;
    border-radius: 0;
}
.ps-ctlsearch:focus, .ps-range input:focus { outline: none; border-bottom-color: #cc0000; box-shadow: 0 1px 0 0 #cc0000; }
.ps-ctlsearch { margin-bottom: 6px; }
.ps-ctllist { max-height: 200px; overflow: auto; }
.ps-range { display: flex; gap: 10px; align-items: flex-end; margin-top: 4px; }
.ps-range span { color: #595959; padding-bottom: 8px; font-size: 13px; }
.ps-hint { color: #595959; font-size: 12px; margin: 6px 0 0; }
.ps-hint-top { margin: 0 0 6px; }
.ps-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ps-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.ps-switch label { font-size: 13px; color: #333; cursor: pointer; }
.ps-switch input { accent-color: #cc0000; width: 18px; height: 18px; flex: none; margin: 0; }
.ps-factions { padding: 16px 0 4px; }
.ps-factions .filter-buttons:disabled { opacity: .5; cursor: default; }

/* pill buttons (presets, quick searches) */
.ps-pchip {
    border: 1px solid #c2c2c2;
    background: #fff;
    border-radius: 15px;
    padding: 5px 10px;
    font: 13px/1.15 Arial, Helvetica, sans-serif;
    color: #212121;
    cursor: pointer;
    min-height: 28px;
}
.ps-pchip:hover { border-color: #757575; background: #f2f2f2; }
.ps-pchip.on { background: #cc0000; border-color: #cc0000; color: #fff; }

/* ---------- main column ---------- */
.ps-main { min-width: 0; }
.ps-main h1.category-heading { margin: 10px 0 12px; }
.ps-intro { font-size: 16px; line-height: 22px; color: #333; margin: 0 0 16px; max-width: 1000px; }
.ps-intro a { color: #cc0000; text-decoration: underline; }

.ps-searchrow { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.ps-qbox {
    position: relative;
    flex: 1;
    max-width: 640px;
    display: flex;
    align-items: center;
    border: 1px solid #9e9e9e;
    border-radius: 8px;
    background: #fff;
}
.ps-qbox:focus-within { border-color: #cc0000; box-shadow: 0 0 0 1px #cc0000; }
.ps-qicon { position: absolute; left: 10px; color: #595959; pointer-events: none; }
.ps-qbox input {
    flex: 1;
    height: 42px;
    border: 0;
    background: transparent;
    padding: 0 40px 0 40px;
    font-size: 14px;
    color: #212121;
    outline: none;
    min-width: 0;
}
.ps-qx { position: absolute; right: 6px; border: 0; background: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: #595959; display: grid; place-items: center; }
.ps-qx:hover { background: #eee; }

.ps-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 16px; }
.ps-lbl { font-size: 14px; font-weight: bold; color: #000; margin-right: 4px; }

.ps-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ps-sortwrap { display: flex; align-items: stretch; }
.ps-sortwrap label {
    background: #f2f2f2;
    border-radius: 30px 0 0 30px;
    font-weight: bold;
    font-size: 14px;
    color: #000;
    padding: 10px 4px 10px 16px;
    display: flex;
    align-items: center;
}
.ps-sortwrap select {
    border: 1px solid #f2f2f2;
    background-color: #f2f2f2;
    border-radius: 0 30px 30px 0;
    padding: 8px 12px 8px 8px;
    font-size: 13px;
    color: #000;
    height: auto;
}
.ps-rcount { font-size: 14px; color: #333; }
.ps-rcount b { font-family: 'Oswald', sans-serif; font-weight: normal; font-size: 22px; color: #000; margin-right: 2px; }
.ps-spacer { flex: 1; }
.ps-viewseg { display: flex; background: #f2f2f2; border-radius: 30px; padding: 3px; }
.ps-viewseg button {
    border: 0;
    background: none;
    border-radius: 30px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #595959;
    cursor: pointer;
}
.ps-viewseg button .material-symbols-outlined { font-size: 18px; }
.ps-viewseg button.on { background: #fff; color: #000; box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.12), 0 1px 5px 0 rgba(0,0,0,.2); }
.ps-btn {
    border: 1px solid #c2c2c2;
    background: #fff;
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    color: #212121;
    cursor: pointer;
    height: auto;
    line-height: 1.3;
    text-transform: none;
}
.ps-btn .material-symbols-outlined { font-size: 18px; }
.ps-btn:hover { background: #f2f2f2; }
.ps-open-filters { display: none; }
.ps-menuwrap, .ps-colpick { position: relative; }
.ps-menu, .ps-colmenu {
    position: absolute;
    right: 0;
    top: 40px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
    padding: 6px 0;
    z-index: 30;
    min-width: 230px;
    display: none;
}
.ps-menu.open, .ps-colmenu.open { display: block; }
.ps-menu button {
    display: block;
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    padding: 10px 16px;
    font-size: 14px;
    color: #cc0000;
    cursor: pointer;
}
.ps-menu button:hover, .ps-menu button:focus { background: #eee; }
.ps-colmenu { padding: 10px 16px; width: 250px; max-height: 380px; overflow: auto; }
.ps-ttl { font-family: 'Oswald', sans-serif; font-size: 18px; margin: 0 0 6px; }
.ps-linkbtn { border: 0; background: none; color: #cc0000; padding: 0; font-size: 13px; cursor: pointer; text-decoration: underline; }

.ps-active { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.ps-active:empty { display: none; }
.ps-achip.chip { display: inline-flex; align-items: center; gap: 2px; margin: 0; padding: 0 4px 0 12px; color: rgba(0,0,0,.75); }
.ps-achip button { border: 0; background: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; padding: 0; cursor: pointer; color: rgba(0,0,0,.7); }
.ps-achip button .material-symbols-outlined { font-size: 16px; }
.ps-achip button:hover { background: rgba(0,0,0,.08); }

mark { background: #fff3a3; color: inherit; padding: 0; }

/* ---------- cards: reuse .category-product-box, but in a grid ---------- */
.ps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
#ps .category-product-box.ps-card {
    margin: 0;
    max-width: none;
    min-width: 0;
    min-height: 0 !important;
    padding: 12px 12px 0;
    display: flex;
    flex-direction: column;
    line-height: 15px;
    box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
}
.ps-card-img { display: grid; place-items: center; height: 150px; margin-bottom: 8px; }
.ps-card-img a { display: block; }
.ps-card-img img { max-width: 100%; max-height: 150px; width: auto; height: auto; object-fit: contain; display: block; }
.ps-card-img.noimg { background: #f2f2f2; border-radius: 10px; }
.ps-card-img.noimg::after { content: "Image coming soon"; color: #595959; font-size: 12px; }
#ps .ps-card a.category-product-title { text-align: left; color: #cc0000; font-size: 12px; line-height: 14px; margin: 0 0 4px; }
.ps-card-body strong { color: #333; }
.ps-stock { display: flex; align-items: flex-start; gap: 5px; margin: 8px 0; font-size: 12px; font-weight: bold; line-height: 15px; }
.ps-stock .material-symbols-outlined { font-size: 17px; }
.ps-stock.in { color: #00796b; }
.ps-stock.in b { color: #000; }
.ps-stock.out { color: #cc0000; }
#ps .ps-stock a.ps-leadtime { display: inline; font-size: 12px; line-height: 15px; color: #cc0000; text-decoration: underline !important; }
.ps-stock.bto, .ps-stock.so { color: #595959; }
.ps-cardfoot {
    margin: auto -12px 0;
    display: flex;
    border-top: 2px solid #e9e8e8;
}
#ps .ps-cardfoot a.ps-details {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    border-right: 2px solid #e9e8e8;
    color: #cc0000;
    line-height: 1;
    min-height: 36px;
}
.ps-details .material-symbols-outlined { font-size: 18px; color: #000; }
.ps-compare {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
}
.ps-compare input, .ps-rowcb { accent-color: #cc0000; width: 16px; height: 16px; margin: 0; }

/* ---------- table ---------- */
.ps-tablewrap {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
    overflow: auto;
    max-height: calc(100vh - 120px);
}
.ps-tablewrap:focus-visible { outline: 2px solid #cc0000; outline-offset: 2px; }
.ps-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; color: #333; }
.ps-table th, .ps-table td { padding: 8px 12px; text-align: left; white-space: nowrap; border-radius: 0; }
.ps-table th { position: sticky; top: 0; background: #fff; border-bottom: 1px solid rgba(0,0,0,.12); z-index: 1; }
.ps-table th button { border: 0; background: none; padding: 0; font: bold 13px Arial, Helvetica, sans-serif; color: #000; cursor: pointer; white-space: nowrap; }
.ps-table th button:hover { color: #cc0000; }
.ps-arr { color: #cc0000; margin-left: 4px; }
.ps-table tbody tr:nth-child(odd) td { background: #f2f2f2; }
.ps-table tbody tr:hover td { background: #ffecec; }
.ps-table td.num, .ps-table th.num { text-align: right; }
.ps-table td.pnc { font-weight: bold; }
.ps-table td a { color: #cc0000; }
.ps-table .first { position: sticky; left: 0; z-index: 2; }
.ps-table th.first { z-index: 3; }
.ps-table tbody tr:nth-child(even) td.first { background: #fff; }
.ps-cbcol { width: 34px; }
.ps-schip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.ps-schip .material-symbols-outlined { font-size: 16px; }
.ps-schip.in { color: #00796b; }
.ps-schip.out { color: #cc0000; }
.ps-schip.bto, .ps-schip.so { color: #595959; }

.ps-empty {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
    padding: 36px 20px;
    text-align: center;
    color: #333;
}
.ps-empty-title { font-family: 'Oswald', sans-serif; font-size: 26px; line-height: 1.2; color: #000; margin: 0 0 8px; }
.ps-empty a { color: #cc0000; text-decoration: underline; }

/* ---------- pagination (materialize .pagination) ---------- */
.ps-pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; font-size: 14px; color: #333; }
.ps-pager .pagination { margin: 0; display: flex; flex-wrap: wrap; }
.ps-pager .pagination li { height: auto; }
.ps-pager .pagination li button {
    min-width: 32px;
    height: 32px;
    border: 0;
    background: none;
    border-radius: 2px;
    font-size: 14px;
    display: grid;
    place-items: center;
    color: #212121;
    padding: 0 6px;
    cursor: pointer;
}
.ps-pager .pagination li.active { background: #cc0000; }
.ps-pager .pagination li.active button { color: #fff; }
.ps-pager .pagination li.disabled button { color: #9e9e9e; cursor: default; }
.ps-gap { padding: 0 4px; color: #595959; align-self: center; }
.ps-per { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #333; }
.ps-per select { width: auto; height: 32px; padding: 0 6px; border: 1px solid #c2c2c2; border-radius: 4px; }

/* ---------- compare tray ---------- */
.ps-tray {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    background: #27272a;
    color: #fff;
    border-radius: 15px;
    padding: 8px 12px 8px 16px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
    z-index: 40;
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
}
.ps-tray.show { display: flex; }
.ps-tray .ps-lbl { color: #fff; }
.ps-items { display: flex; gap: 6px; flex-wrap: wrap; }
.ps-it { background: #3f3f46; border-radius: 15px; padding: 3px 10px; font-size: 12px; font-weight: bold; }
.ps-tray .ps-cmp-go { margin: 0; }
.ps-tray .ps-cmp-go.disabled { background-color: #616161 !important; color: #e0e0e0 !important; pointer-events: auto; }
.ps-tray .ps-linkbtn { color: #d4d4d8; }

.ps-backdrop { display: none; }
.ps-noscript li { margin: 4px 0; }
.ps-noscript a { color: #cc0000; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
    .ps-layout { grid-template-columns: minmax(0, 1fr); padding: 0 12px 90px; }
    .ps-filters {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(340px, 88vw);
        max-height: none;
        height: 100vh;
        background: #fff;
        padding: 12px 16px;
        z-index: 1001;
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform .2s, visibility 0s linear .2s; /* hide only after sliding out */
        box-shadow: 0 8px 17px 2px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2);
    }
    .ps-filters.open { transform: none; visibility: visible; transition: transform .2s, visibility 0s; }
    .ps-close-filters { display: grid; place-items: center; }
    .ps-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; }
    .ps-open-filters { display: inline-flex; }
    .ps-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    html.ps-noscroll, html.ps-noscroll body { overflow: hidden; }
}
@media (max-width: 600px) {
    .ps-searchrow { flex-wrap: wrap; }
    .ps-qbox { flex: 1 1 100%; max-width: none; order: -1; }
    .ps-toolbar { gap: 8px; }
    /* leave room on the right for the chat bubble */
    .ps-tray { left: 8px; right: 76px; transform: none; bottom: 8px; border-radius: 12px; }
}
