/* ==========================================================================
   Products page — toolbar, filter panel, catalogue grid, product card
   ========================================================================== */

/* ---------- toolbar ---------- */
.product-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 60;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.product-toolbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
    padding-block: var(--space-4);
}
.product-toolbar__form { display: flex; flex-wrap: wrap; gap: var(--space-3); flex: 1 1 520px; }
.product-toolbar__form .input-group { flex: 1 1 280px; }
.product-toolbar__form .select { flex: 0 1 200px; width: auto; }
.product-toolbar__meta { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; }
.product-count { font-size: var(--text-sm); color: var(--ink-600); white-space: nowrap; }
.product-count b { color: var(--navy-900); }
.filter-toggle { display: none; }

@media (max-width: 1024px) {
    .product-toolbar__form .select { display: none; }
    .filter-toggle { display: inline-flex; }
    .product-toolbar__meta { width: 100%; margin-left: 0; justify-content: space-between; }
}
@media (max-width: 600px) {
    .product-toolbar { position: static; }
}

/* ---------- chip rows ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
@media (max-width: 760px) {
    /* below tablet the segment row scrolls sideways instead of stacking 13 rows deep */
    .chip-row--scroll {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: var(--space-2);
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
}
.chip-row--letters .chip { font-size: var(--text-caption); }

.chip--segment { height: 44px; padding-inline: var(--space-4); gap: var(--space-2); }
.chip--segment img { width: 22px; height: 22px; object-fit: contain; }
.chip--segment[aria-pressed="true"] img, .chip--segment.is-active img { filter: brightness(0) invert(1); }
.chip.is-muted { color: var(--ink-400); border-color: var(--line); }
.chip.is-muted:hover { color: var(--brand-700); }

.filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pill-clear {
    display: inline-flex; align-items: center; gap: var(--space-2);
    height: 32px; padding-inline: var(--space-3);
    border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
    background: #fff; color: var(--ink-600);
    font-size: var(--text-caption); font-weight: 700; cursor: pointer;
    transition: border-color .18s var(--ease), color .18s var(--ease);
}
.pill-clear:hover { border-color: var(--danger); color: var(--danger); }
.pill-clear svg { width: 12px; height: 12px; }

/* ---------- layout ---------- */
.products-layout {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    gap: clamp(1.5rem, 1rem + 2vw, 3rem);
    align-items: start;
}
@media (max-width: 1024px) {
    .products-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- filter panel ---------- */
.filter-panel {
    position: sticky;
    top: calc(var(--header-h) + 96px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.filter-panel__head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--line);
}
.filter-panel__title { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--navy-900); }
.filter-group + .filter-group { border-top: 1px solid var(--line); }
.filter-group__trigger {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: none; border: 0; cursor: pointer; text-align: left;
    font-family: var(--font-heading); font-weight: 700; font-size: var(--text-caption);
    text-transform: uppercase; letter-spacing: .08em; color: var(--navy-800);
}
.filter-group__trigger:hover { background: var(--bg-subtle); }
.filter-group__trigger svg { width: 16px; height: 16px; color: var(--ink-500); transition: transform .2s var(--ease); flex: none; }
.filter-group__trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.filter-group__panel { padding: 0 var(--space-5) var(--space-5); display: grid; gap: var(--space-3); }
.filter-group__panel .check { font-size: var(--text-caption); line-height: 1.4; }
.filter-more {
    justify-self: start;
    background: none; border: 0; padding: 0; cursor: pointer;
    font-family: var(--font-heading); font-size: var(--text-caption); font-weight: 700; color: var(--brand-600);
}
.filter-more:hover { color: var(--brand-700); text-decoration: underline; }

/* Extra options stay collapsed only when JavaScript can reveal them again. */
.js .filter-group__panel .is-extra { display: none; }
.js .filter-group.is-expanded .filter-group__panel .is-extra { display: flex; }

.filter-group__panel .check input[type="radio"] { border-radius: 50%; }
.filter-panel__close { display: none; position: static; border-color: var(--line); }

@media (max-width: 1024px) {
    .filter-panel {
        position: fixed; inset: 0 0 0 auto; z-index: 130;
        width: min(360px, 88vw);
        border-radius: 0; border: 0;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
        transform: translateX(100%);
        /* hidden (not just off-screen) while closed, so Tab never lands inside */
        visibility: hidden;
        transition: transform .28s var(--ease), visibility 0s linear .28s;
    }
    .filter-panel.is-open { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s; }
    .filter-panel__head { position: sticky; top: 0; background: #fff; z-index: 1; }
    .filter-panel__close { display: grid; }
    .filter-scrim { position: fixed; inset: 0; z-index: 125; background: rgba(11, 31, 63, .5); }
}

/* ---------- product grid ---------- */
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
@media (max-width: 1240px) { .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .product-grid { grid-template-columns: 1fr; } }

.product-card {
    position: relative;
    display: flex; flex-direction: column;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.product-card:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.product-card__media {
    position: relative;
    display: grid; place-items: center;
    aspect-ratio: 4 / 3;
    padding: var(--space-5);
    background: linear-gradient(180deg, var(--bg-brand-subtle), #fff);
    border-bottom: 1px solid var(--line);
}
.product-card__media img { max-height: 100%; width: auto; object-fit: contain; }
.product-card__media .tag--new { position: absolute; top: var(--space-3); left: var(--space-3); }
.product-card__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.product-card__cat {
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--brand-600);
}
.product-card__name { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-lg); line-height: 1.25; }
.product-card__name a { color: var(--navy-900); }
.product-card__name a:hover { color: var(--brand-700); }
/* the whole card reads as one target: the title link covers it, and the
   footer controls sit back on top so they stay separately clickable */
.product-card__name a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.product-card__foot { position: relative; z-index: 2; }
.product-card__comp { font-size: var(--text-sm); color: var(--ink-600); }
.product-card__meta {
    margin-top: auto; padding-top: var(--space-4);
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3);
    border-top: 1px solid var(--line);
}
.product-card__meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-400); }
.product-card__meta dd { margin: 2px 0 0; font-size: var(--text-caption); font-weight: 700; color: var(--navy-800); }
.product-card__foot { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-5) var(--space-5); }
.product-card__foot .btn { flex: 1; }

/* ---------- empty state ---------- */
.empty-state {
    display: grid; place-items: center; gap: var(--space-3);
    padding: var(--space-16) var(--space-6);
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
}
.empty-state h3 { font-size: var(--text-xl); }
.empty-state p { color: var(--ink-600); max-width: 46ch; }

/* ==========================================================================
   Single product page
   ========================================================================== */
.tag--stock { background: #e8f6ed; color: #12693a; }
.tag--request { background: #fdf3e2; color: #8a5a06; }

/* ---------- breadcrumbs ---------- */
.product-crumbs { border-bottom: 1px solid var(--line); background: var(--bg-subtle); }
.product-crumbs ol {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
    padding-block: var(--space-3);
    font-size: var(--text-caption); color: var(--ink-500);
}
.product-crumbs li { display: flex; align-items: center; gap: var(--space-2); }
.product-crumbs li + li::before { content: "/"; color: var(--line-strong); }
.product-crumbs a { color: var(--ink-600); }
.product-crumbs a:hover { color: var(--brand-700); }
.product-crumbs [aria-current] { color: var(--navy-900); font-weight: 700; }

/* ---------- layout ---------- */
.product-page__grid {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(2rem, 1rem + 4vw, 4rem);
    align-items: start;
}
.product-page__grid--flip { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }

.product-page__media {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.product-page__media img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; }
.product-page__media .tag--new { position: absolute; top: var(--space-4); left: var(--space-4); }

.product-page__name { margin-top: var(--space-3); }
.product-page__comp { margin-top: var(--space-3); color: var(--ink-600); }
.product-page__stock { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-5); }

.product-page__highlights {
    display: grid; gap: var(--space-3);
    margin-top: var(--space-6); padding-top: var(--space-6);
    border-top: 1px solid var(--line);
}
.product-page__highlights li {
    display: flex; align-items: flex-start; gap: var(--space-3);
    font-size: var(--text-sm); color: var(--ink-700);
}
.product-page__highlights svg { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--brand-600); }

.product-page__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }

/* ---------- specification card ---------- */
.product-page__specs { padding: var(--space-6); position: sticky; top: calc(var(--header-h) + var(--space-4)); }
.product-page__specs dl { margin-top: var(--space-5); }
.product-page__specs dl > div {
    display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: var(--space-4);
    padding-block: var(--space-3);
    border-top: 1px solid var(--line);
}
.product-page__specs dl > div:first-child { border-top: 0; padding-top: 0; }
.product-page__specs dt { font-size: var(--text-caption); color: var(--ink-500); }
.product-page__specs dd { font-size: var(--text-sm); font-weight: 600; color: var(--navy-800); }

.product-page__about > * + * { margin-top: var(--space-4); }
.product-page__about p { color: var(--ink-600); }
.product-page__rx {
    margin-top: var(--space-6); padding: var(--space-4) var(--space-5);
    background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--brand-300);
    border-radius: var(--radius-md);
    font-size: var(--text-caption); color: var(--ink-500);
}

@media (max-width: 900px) {
    .product-page__grid,
    .product-page__grid--flip { grid-template-columns: 1fr; }
    .product-page__specs { position: static; }
}
