/* ============================================================================
   Light, friendly product-catalog theme — white + soft blue surfaces, green
   accents. Built for fast searching / filtering / inspecting parts.
   Font: Plus Jakarta Sans. Rounded, airy, low-chrome. Pure visual layer.
   ============================================================================ */

:root {
    --bg:            #f2f7fc;   /* page */
    --surface:       #ffffff;   /* cards */
    --surface-2:     #eaf2fb;   /* soft blue fill */
    --surface-3:     #f5f9fd;   /* image tiles */
    --border:        #e4edf6;
    --border-strong: #d2e0ee;

    --ink:    #16273b;          /* primary text (deep navy) */
    --ink-2:  #38506a;
    --muted:  #6c8298;          /* labels / secondary */

    --primary:      #2b7cf0;    /* blue — links, active, primary action */
    --primary-700:  #1b62cf;
    --primary-soft: #e7f0fe;

    --green:      #15a06d;      /* success / scraped */
    --green-soft: #e1f4ea;
    --amber:      #d6852a;      /* pending */
    --amber-soft: #fbefda;

    --ring: 0 0 0 3px rgba(43, 124, 240, 0.22);
    --shadow-sm: 0 1px 2px rgba(22, 48, 92, 0.06);
    --shadow:    0 8px 24px -12px rgba(22, 48, 92, 0.22);
    --shadow-lg: 0 22px 48px -22px rgba(22, 48, 92, 0.34);

    --radius:    16px;
    --radius-md: 12px;
    --radius-sm: 9px;

    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background:
        radial-gradient(1200px 480px at 80% -8%, rgba(43, 124, 240, 0.06), transparent 60%),
        radial-gradient(900px 420px at -5% 0%, rgba(21, 160, 109, 0.05), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--primary-soft); color: var(--primary-700); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: #cfdcea; border: 3px solid var(--bg); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b6c8db; }

.shell { width: min(1500px, calc(100% - 44px)); margin: 0 auto; padding: 0 0 72px; }
.detail-shell { width: min(1320px, calc(100% - 44px)); }

/* ---------- header ---------- */
.topbar {
    display: flex; flex-wrap: wrap; gap: 20px;
    align-items: center; justify-content: space-between;
    padding: 26px 0 22px;
    animation: rise 0.45s ease both;
}
.brand-link { display: inline-flex; align-items: center; gap: 13px; }
.brand-link::before {
    content: "";
    width: 30px; height: 30px; border-radius: 9px; flex: none;
    background: linear-gradient(140deg, var(--primary), #57a6ff 70%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4), 0 4px 12px -3px rgba(43, 124, 240, 0.6);
}
h1 {
    margin: 0;
    font-size: clamp(1.4rem, 2.4vw, 1.95rem);
    font-weight: 800; letter-spacing: -0.02em; color: var(--ink);
}
.detail-shell h1 { font-size: clamp(1.7rem, 3vw, 2.5rem); }

.summary { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
    display: flex; flex-direction: column; gap: 1px;
    padding: 9px 16px; min-width: 92px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.stat strong { font-size: 1.3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat span { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat:nth-child(2) strong { color: var(--green); }
.stat:nth-child(3) strong { color: var(--amber); }

/* ---------- search panel ---------- */
.filters {
    display: grid;
    grid-template-columns: minmax(240px, 2.6fr) minmax(160px, 1fr) minmax(150px, 0.9fr) auto;
    gap: 12px; align-items: end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 24px;
    animation: rise 0.45s 0.05s ease both;
}
label { display: grid; gap: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
input, select, button, .button {
    min-height: 46px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit; font-size: 0.95rem;
    padding: 11px 13px; border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.1s;
}
input::placeholder { color: #9badbe; }
input[type="search"] {
    padding-left: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236c8298' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 14px center;
}
select {
    appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c8298' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
button, .button {
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-weight: 700; font-size: 0.9rem; letter-spacing: 0.01em;
    border-color: var(--primary); background: var(--primary); color: #fff;
    box-shadow: 0 6px 16px -8px rgba(43, 124, 240, 0.7);
}
button:hover, .button:hover { background: var(--primary-700); border-color: var(--primary-700); transform: translateY(-1px); }
.button.secondary { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); box-shadow: none; }
.button.secondary:hover { background: var(--surface-2); color: var(--primary-700); border-color: var(--primary); transform: translateY(-1px); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 22px; align-items: start; }

.category-nav {
    position: sticky; top: 18px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 16px 14px; max-height: calc(100vh - 36px); overflow: auto;
    animation: rise 0.45s 0.1s ease both;
}
.category-nav h2 { margin: 0 0 12px; padding: 0 6px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.all-link { display: block; margin-bottom: 8px; padding: 9px 11px; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem; color: var(--ink-2); }
.all-link:hover { background: var(--surface-2); }
.all-link.active { background: var(--primary-soft); color: var(--primary-700); }

.category-tree { list-style: none; margin: 0; padding: 0; }
.category-tree .category-tree { margin-left: 10px; padding-left: 8px; border-left: 1px solid var(--border); display: none; }
.category-tree .category-tree.expanded { display: block; }
.tree-item-row { display: flex; align-items: center; border-radius: var(--radius-sm); }
.tree-item-row:hover { background: var(--surface-2); }
.tree-item-row .category-link { flex-grow: 1; }
.toggle-arrow { display: inline-grid; place-items: center; width: 20px; height: 28px; cursor: pointer; color: var(--muted); font-size: 0.6rem; user-select: none; border-radius: 6px; }
.toggle-arrow:hover { color: var(--primary); background: var(--primary-soft); }
.toggle-spacer { width: 20px; display: inline-block; }
.category-link { display: block; padding: 7px 8px; color: var(--ink-2); font-size: 0.86rem; line-height: 1.3; border-radius: var(--radius-sm); }
.category-link.active { color: var(--primary-700); font-weight: 700; }
.tree-item-row:has(.category-link.active) { background: var(--primary-soft); }
.cat-count { margin-left: 5px; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.cat-count.empty { opacity: 0.5; }

/* ---------- results / product grid ---------- */
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.results-head p { margin: 0; color: var(--muted); font-weight: 600; font-size: 0.92rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 16px; }

.product {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
    animation: rise 0.4s ease both;
}
.grid .product:nth-child(1) { animation-delay: 0.02s; }
.grid .product:nth-child(2) { animation-delay: 0.04s; }
.grid .product:nth-child(3) { animation-delay: 0.06s; }
.grid .product:nth-child(4) { animation-delay: 0.08s; }
.grid .product:nth-child(5) { animation-delay: 0.10s; }
.grid .product:nth-child(6) { animation-delay: 0.12s; }
.grid .product:nth-child(n+7) { animation-delay: 0.14s; }
.product:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

.thumb {
    display: grid; place-items: center;
    width: 100%; height: 188px;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    overflow: hidden; color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 16px; transition: transform 0.25s ease; }
.product:hover .thumb img { transform: scale(1.04); }
.thumb-empty { font-size: 0.74rem; font-weight: 600; color: #9badbe; }

.product-body { display: flex; flex-direction: column; gap: 9px; padding: 14px 15px 16px; }
.product h2 { margin: 0; font-size: 0.98rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.product-link { color: var(--ink); }
.product:hover .product-link { color: var(--primary-700); }
.cat-link { color: var(--primary); font-weight: 600; }
.cat-link:hover { text-decoration: underline; }

.meta { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.category-links { font-size: 0.8rem; line-height: 1.4; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: 0.74rem; font-weight: 600; color: var(--ink-2);
    padding: 3px 9px; border-radius: 999px; background: var(--surface-2);
}

.status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.74rem; font-weight: 700;
    padding: 3px 10px 3px 8px; border-radius: 999px;
    color: var(--green); background: var(--green-soft);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.status.pending { color: var(--amber); background: var(--amber-soft); }
.status.pending::before { background: var(--amber); }
.chip.status { font-weight: 700; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 26px; align-items: center; }
.pager > span:first-child { color: var(--muted); font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.empty {
    padding: 48px 24px; text-align: center;
    background: var(--surface); border: 1px dashed var(--border-strong);
    border-radius: var(--radius); color: var(--muted); font-weight: 500;
}
.error {
    padding: 14px 18px; border-radius: var(--radius-md);
    background: #fdecea; border: 1px solid #f4c6c0; color: #a32c1e;
    margin-bottom: 20px; font-size: 0.92rem;
}

/* ---------- detail page ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 24px 0 20px; animation: rise 0.45s ease both; }
.toolbar .brand-link { font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.hero {
    display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr); gap: 26px;
    align-items: stretch; margin-bottom: 26px;
    animation: rise 0.45s 0.05s ease both;
}
.image-stage {
    min-height: 380px; display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.image-stage img { width: 100%; height: 100%; max-height: 520px; object-fit: contain; padding: 30px; }
.hero-text { align-self: center; }
.eyebrow, .eyebrow-categories { margin: 0 0 12px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.eyebrow-categories .cat-link { color: var(--primary); }
.hero-text h1 { letter-spacing: -0.025em; }
.hero .chips { margin-top: 16px; gap: 8px; }
.hero .chip { font-size: 0.8rem; padding: 5px 12px; background: var(--surface); border: 1px solid var(--border); }

.content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 0.42fr); gap: 22px; align-items: start; }
.section { margin-bottom: 22px; animation: rise 0.45s 0.1s ease both; }
h2 { margin: 0 0 13px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; }
.panel h2 { margin-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
th { width: 38%; color: var(--muted); font-weight: 600; }
td { color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
tr:last-child th, tr:last-child td { border-bottom: 0; }

.product-description { font-size: 0.95rem; line-height: 1.7; color: var(--ink-2); overflow-wrap: anywhere; }
.product-description a { color: var(--primary); }
/* keep raw scraped HTML from blowing out the layout */
.product-description img, .product-description svg, .product-description video, .product-description iframe { max-width: 100%; height: auto; }
.product-description table { display: block; max-width: 100%; overflow-x: auto; }

/* long attribute/spec blobs (raw submittal JSON, etc.) — capped + scrollable */
.cell-long { max-height: 170px; overflow: auto; padding: 9px 11px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px; font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.gallery a { height: 124px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.gallery a:hover { border-color: var(--primary); transform: translateY(-2px); }
.gallery img { width: 100%; height: 124px; object-fit: contain; padding: 10px; }

.links { display: grid; gap: 11px; }
.links a { overflow-wrap: anywhere; color: var(--primary); font-weight: 600; font-size: 0.9rem; }
.links a:hover { color: var(--primary-700); text-decoration: underline; }

.pdf-list { display: grid; gap: 10px; }
.pdf-link { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 13px 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.pdf-link strong { overflow-wrap: anywhere; min-width: 0; font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 9px; }
.pdf-link strong::before { content: ""; flex: none; width: 18px; height: 22px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='22' viewBox='0 0 24 24' fill='none' stroke='%23d6852a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E") center/contain no-repeat; }

.variation-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.variation-header { padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background 0.12s; }
.variation-header:hover { background: var(--surface-2); }
.variation-header h3 { margin: 0; font-size: 0.92rem; font-weight: 700; color: var(--primary-700); }
.variation-header > span { font-size: 0.88rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.variation-content { padding: 4px 15px 14px; display: none; }
.variation-content.active { display: block; }
.var-filter { width: 100%; margin-bottom: 12px; }
.variation-scroll.scrolling { max-height: 520px; overflow-y: auto; padding: 10px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.variation-scroll.scrolling .variation-card:last-child { margin-bottom: 0; }
.variation-card.hidden { display: none; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
    .layout, .filters, .hero, .content { grid-template-columns: 1fr; }
    .category-nav { position: static; max-height: none; }
}
@media (max-width: 560px) {
    .shell, .detail-shell { width: calc(100% - 26px); }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .thumb { height: 150px; }
    .topbar { gap: 14px; }
}
