/* ---- Design tokens: "onderdelen-datasheet" systeem ---- */
:root {
    --ink: #1b211d;
    --muted: #5b6459;
    --paper: #f3f5f0;
    --panel: #ffffff;
    --line: #d9dfd3;
    --circuit: #2f6e4f;
    --circuit-soft: #e7f0ea;
    --copper: #b5652b;
    --copper-soft: #f5e9de;
    --radius: 8px;
    --font-display: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--circuit); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--circuit);
    outline-offset: 2px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--ink); margin: 0 0 0.5em; }
.mono { font-family: var(--font-mono); }

/* ---- Header ---- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}
.site-header .brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ink);
}
.site-header .brand:hover { text-decoration: none; color: var(--circuit); }

.search-form { display: flex; gap: 0; flex: 1; max-width: 520px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.search-form input {
    flex: 1;
    padding: 11px 14px;
    border: none;
    font-size: 0.95rem;
    font-family: var(--font-body);
    background: var(--panel);
    color: var(--ink);
}
.search-form input:focus { outline: none; }
.search-form button {
    padding: 11px 20px;
    border: none;
    border-left: 1px solid var(--line);
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
}
.search-form button:hover { background: var(--circuit); }

.refresh-btn {
    flex-shrink: 0;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    font-weight: 600;
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
}
.refresh-btn:hover { border-color: var(--circuit); color: var(--circuit); }
.refresh-btn:disabled { opacity: 0.6; cursor: default; }

/* ---- Layout: sidebar + results ---- */
.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 28px 60px;
    align-items: start;
}

.sidebar h2 {
    font-size: 0.78rem;
    text-transform: none;
    color: var(--muted);
    font-family: var(--font-body);
    font-weight: 600;
    margin-bottom: 10px;
}
.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.category-list li { border-left: 2px solid transparent; }
.category-list a {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    color: var(--ink);
    font-size: 0.88rem;
    border-radius: 0 4px 4px 0;
}
.category-list a:hover { background: var(--circuit-soft); text-decoration: none; }
.category-list li.active { border-left-color: var(--copper); }
.category-list li.active a { background: var(--copper-soft); font-weight: 600; }
.category-list .count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 18px;
}
.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}
.filter-bar label.checkbox { flex-direction: row; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink); }
.filter-bar input[type="text"], .filter-bar select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    background: var(--paper);
    color: var(--ink);
    min-width: 160px;
}
.filter-bar button {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    background: var(--circuit);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.88rem;
}
.filter-bar button:hover { background: #255c41; }
.filter-bar .reset { font-size: 0.82rem; color: var(--muted); }

/* ---- Merk: doorzoekbare dropdown ---- */
.combobox { position: relative; }
.combo-input { width: 100%; }
.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    max-height: 260px;
    overflow-y: auto;
    min-width: 220px;
}
.combo-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 9px;
    border: none;
    background: none;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--ink);
    cursor: pointer;
}
.combo-option:hover, .combo-option.is-highlighted { background: var(--circuit-soft); }
.combo-empty { padding: 8px 9px; font-size: 0.82rem; color: var(--muted); }

.hint { color: var(--muted); font-size: 1rem; }
.result-count { color: var(--muted); margin-bottom: 16px; font-size: 0.9rem; }

/* ---- Product grid ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--ink);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--circuit); transform: translateY(-2px); text-decoration: none; }
.thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
.thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.thumb img.is-loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .thumb img { transition: none; }
}
.no-image { color: #a7ada2; font-size: 0.8rem; font-family: var(--font-mono); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; }
.card-brand { font-size: 0.72rem; color: var(--copper); font-weight: 600; }
.card-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; line-height: 1.3; }
.card-code { font-size: 0.76rem; color: var(--muted); }
.card-specs {
    list-style: none;
    margin: 8px 0 0;
    padding: 8px 0 0;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.card-specs li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.76rem;
    line-height: 1.4;
}
.spec-label {
    flex: 0 0 44px;
    color: var(--muted);
}
.spec-value {
    flex: 1;
    min-width: 0;
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 26px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination .ellipsis {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    padding: 0 8px;
}
.pagination a:hover { border-color: var(--circuit); text-decoration: none; }
.pagination a.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pagination .ellipsis { border: none; color: var(--muted); }
.pagination a.step { font-family: var(--font-body); font-weight: 600; }

/* ---- Product datasheet page ---- */
.product-page { max-width: 980px; margin: 0 auto; padding: 24px 28px 60px; }
.back { margin-bottom: 16px; font-size: 0.88rem; }
.back a { color: var(--muted); }

.datasheet {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.datasheet-header {
    display: flex;
    gap: 28px;
    padding: 28px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.datasheet-image { flex: 0 0 260px; display: flex; align-items: center; justify-content: center; background: #fafbf9; border: 1px solid var(--line); border-radius: 6px; min-height: 220px; }
.datasheet-image img { max-width: 100%; max-height: 240px; object-fit: contain; }
.datasheet-meta { flex: 1; min-width: 260px; }
.eyebrow-brand { color: var(--copper); font-weight: 600; font-size: 0.85rem; }
.datasheet-meta h1 { font-size: 1.5rem; margin: 4px 0 14px; line-height: 1.25; }

.id-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 14px; }
.id-strip > div { display: flex; flex-direction: column; gap: 2px; }
.id-strip dt { font-size: 0.68rem; color: var(--muted); text-transform: none; }
.id-strip dd { margin: 0; font-size: 0.88rem; }

.summary { color: var(--ink); margin-top: 10px; }
.muted { color: var(--muted); }

/* Ruwe HTML-omschrijvingen zoals Icecat die aanlevert (met <b>, <br>, <ul>, ...) */
.rich-text { line-height: 1.6; }
.rich-text + .rich-text { margin-top: 12px; }
.rich-text b, .rich-text strong { color: var(--ink); font-weight: 600; }
.rich-text ul, .rich-text ol { margin: 8px 0; padding-left: 22px; }
.rich-text li { margin: 3px 0; }
.rich-text a { color: var(--circuit); }

.datasheet-section { padding: 24px 28px; border-bottom: 1px solid var(--line); }
.datasheet-section:last-child { border-bottom: none; }
.datasheet-section h2 { font-size: 1.05rem; margin-bottom: 14px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.section-heading h2 { margin-bottom: 0; }
.copy-buttons { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.copy-btn {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.78rem;
    cursor: pointer;
}
.copy-btn:hover { border-color: var(--circuit); color: var(--circuit); }
.copy-feedback {
    font-size: 0.78rem;
    color: var(--circuit);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.copy-feedback.is-visible { opacity: 1; }
.datasheet-section h3 { font-size: 0.92rem; margin: 18px 0 8px; color: var(--muted); font-family: var(--font-body); font-weight: 600; }
.datasheet-section h3:first-of-type { margin-top: 0; }

.gallery-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.gallery-thumb-btn {
    width: 96px;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafbf9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.gallery-thumb-btn img { width: 100%; height: 100%; object-fit: contain; padding: 4px; display: block; }
.gallery-thumb-btn:hover { border-color: var(--circuit); }

/* ---- Carrousel (Afbeeldingen) ---- */
.carousel-main {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    width: 100%;
    max-height: 420px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}
.carousel-image { max-width: 90%; max-height: 90%; object-fit: contain; opacity: 0; transition: opacity 0.2s ease; }
.carousel-image.is-loaded { opacity: 1; }
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carousel-nav:hover { border-color: var(--circuit); color: var(--circuit); }
.carousel-nav.prev { left: 12px; }
.carousel-nav.next { right: 12px; }
.carousel-counter {
    position: absolute;
    bottom: 10px;
    right: 12px;
    background: rgba(27, 33, 29, 0.72);
    color: var(--paper);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
}
.carousel-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.carousel-thumb {
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafbf9;
    cursor: pointer;
    line-height: 0;
    overflow: hidden;
}
.carousel-thumb img { height: 56px; width: 56px; object-fit: contain; padding: 3px; display: block; }
.carousel-thumb:hover { border-color: var(--circuit); }
.carousel-thumb.is-active { border-color: var(--circuit); border-width: 2px; }
.carousel-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}
.carousel-expand:hover { border-color: var(--circuit); color: var(--circuit); }
@media (max-width: 520px) {
    .carousel-main { max-height: 280px; }
}

/* ---- Lightbox (grote weergave van een afbeelding) ---- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(27, 33, 29, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.lightbox.is-open { display: flex; }
.lightbox-image { max-width: 88vw; max-height: 84vh; object-fit: contain; }
.lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: var(--paper);
    font-size: 1.2rem;
    cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: var(--paper);
    font-size: 1.1rem;
    cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--paper);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.12);
    padding: 3px 10px;
    border-radius: 4px;
}

.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.logo-card { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.logo-card img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.logo-card strong { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.logo-card p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

.media-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.media-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; }
.media-type { margin-left: auto; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); background: var(--paper); padding: 2px 8px; border-radius: 4px; }

.spec-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.spec-table tr:nth-child(odd) { background: var(--paper); }
.spec-table th, .spec-table td { text-align: left; padding: 8px 12px; font-size: 0.88rem; border-bottom: 1px solid var(--line); }
.spec-table th { width: 40%; color: var(--muted); font-weight: 500; }

.data-dump { list-style: none; margin: 0; padding-left: 14px; font-size: 0.86rem; }
.data-dump ul.data-dump { margin-top: 4px; border-left: 2px solid var(--line); }
.data-dump li { padding: 3px 0; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { order: 2; }
    .category-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 6px; }
    .category-list li { border-left: none; border-bottom: 2px solid transparent; flex-shrink: 0; }
    .category-list li.active { border-bottom-color: var(--copper); }
    .datasheet-header { flex-direction: column; }
    .datasheet-image { flex: none; width: 100%; }
}
@media (max-width: 520px) {
    .site-header { padding: 12px 16px; }
    .layout, .product-page { padding-left: 16px; padding-right: 16px; }
    .datasheet-section, .datasheet-header { padding: 18px; }
}

/* ---- Achtergrond-syncmelding ---- */
.sync-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ink);
    color: var(--paper);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
    max-width: min(90vw, 340px);
}
.sync-toast.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sync-spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid rgba(243, 245, 240, 0.35);
    border-top-color: var(--paper);
    border-radius: 50%;
    animation: sync-spin 0.8s linear infinite;
}
@keyframes sync-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .sync-spinner { animation: none; }
    .sync-toast { transition: none; }
}
