/* BMW Viewer v2 — mirrors ducati-viewer.css layout, BMW blue accent (#0066b3) */

/* Page: white body, content pads like Ducati's .viewer-container */
body.bmw-v2 { background: #ffffff; }
body.bmw-v2 > #level1 { margin: 0; }
.bmw2-container { padding: 0 1.5rem 2rem; }

/* One white bordered card */
.bmw2-fiche-layout {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 0.75rem;
}

/* ── Subheader: back link + title (left) | currently viewing (right) ── */
.brand-subheader {
    width: 100%;
    background: #fff;
    color: #333;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}
.brand-subheader .breadcrumb {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    text-transform: none;
    font-weight: 500;
}
.section-filter-back {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.section-filter-back:hover { color: #0066b3; text-decoration: underline; }
.brand-subheader h1 {
    font-size: 0.9rem;
    color: #0066b3;
    margin: 0;
    font-weight: bold;
    text-transform: uppercase;
}
.brand-subheader .model-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}
.brand-subheader .model-meta .diagram-name { color: #0066b3; font-weight: bold; }

/* ── Thumbnail panel + horizontal category strip ── */
.thumbnail-panel {
    border-top: 2px solid #0066b3;
    border-bottom: 2px solid #0066b3;
    background: #fff;
    padding: 0 0 10px;
}
.cat-strip {
    display: flex;
    align-items: stretch;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 30px 12px;
    scrollbar-width: none;
}
.cat-strip::-webkit-scrollbar { display: none; }

/* Scrollbar below the expanded row (proxy for the strip) */
.cat-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    margin: 6px 8px 0;
    scrollbar-width: auto;
    scrollbar-color: #0066b3 #fff;
}
.cat-scroll-inner { height: 1px; }
.cat-scroll::-webkit-scrollbar { height: 12px; background: #fff; }
.cat-scroll::-webkit-scrollbar-track { background: #fff; border-radius: 4px; }
.cat-scroll::-webkit-scrollbar-thumb { background: #0066b3; border-radius: 4px; }

.cat-item {
    flex-shrink: 0;
    width: 170px;
    background: #fff;
    border-radius: 8px;
    padding: 0 0 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: box-shadow 0.2s;
    user-select: none;
}
.cat-item:hover { box-shadow: 0 2px 10px rgba(0,102,179,0.35); }
.cat-item { position: relative; }
.cat-item.open {
    box-shadow: none;
    border-radius: 8px 8px 0 0;
}
/* open card: blue top + sides drawn 7.5px out (gap-center lines); ends at the card's bottom edge */
.cat-item.open::before {
    content: '';
    position: absolute;
    top: -7.5px;
    left: -7.5px;
    right: -7.5px;
    bottom: 0;
    box-sizing: border-box;
    border: 3px solid #0066b3;
    border-bottom: none;
    border-radius: 11.5px 11.5px 0 0;
    pointer-events: none;
}
.ci-collage {
    height: 100px;
    display: grid;
    gap: 2px;
    background: #e8e8e8;
    overflow: hidden;
}
.ci-collage.n1 { grid-template-columns: 1fr; }
.ci-collage.n2 { grid-template-columns: 1fr 1fr; }
.ci-collage.n3, .ci-collage.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.ci-collage img { width: 100%; height: 100%; min-height: 0; object-fit: contain; background: #fff; display: block; }
.cat-item .ci-name {
    font-size: 0.72em;
    color: #333;
    line-height: 1.2;
    text-align: center;
    min-height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.cat-item.open .ci-name { color: #0066b3; font-weight: 700; }
.cat-item .ci-meta { font-size: 0.68em; color: #000; text-align: center; }
.ci-chev { color: #0066b3; }
.ci-expand { font-weight: 700; color: #000; }

/* Accessories viewer: selected category card (no subrow notch like .open) */
.cat-item.active { outline: 3px solid #0066b3; }
.cat-item.active .ci-name { color: #0066b3; font-weight: 700; }

/* Accessories item grid (reuses .es-fluid-card from shared-header-footer) */
#es-acc-panel { padding: 14px 20px 8px; }
#es-acc-panel .es-fluids-grid { max-width: none; margin: 0; }
.es-fluid-desc.acc-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.es-fluid-img img { cursor: zoom-in; }
.es-fluid-name.acc-title {
    padding: 10px 12px 6px;
    text-align: center;
    min-height: calc(2.6em + 16px);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
#es-acc-panel .es-fluid-img { height: 180px; border-top: 1px solid #eee; }

/* Second row: diagrams of the expanded category, centered under its card */
.cat-subrow-wrap { position: relative; margin-top: -3px; }
.cat-subrow-wrap:empty { display: none; }
.cat-subrow {
    position: relative;
    display: block;
    margin: 0;
    padding: 0 4.5px;
    box-sizing: border-box;
    border: 3px solid #0066b3;
    border-radius: 10px;
    background: #fff;
}
.cat-subrow.edge-l { border-top-left-radius: 0; }
.cat-subrow.edge-r { border-top-right-radius: 0; }
.cat-subrow-thumbs {
    display: flex;
    flex-wrap: wrap;
    column-gap: 12px;
    row-gap: 0;
}
.diag-cell { position: relative; flex: 0 0 170px; width: 170px; padding: 14px 0 12px; }
.diag-cell .diag-thumb { display: block; width: 100%; min-width: 0; }
.diag-cell .dt-name { min-width: 0; height: calc(2.4em + 8px); min-height: 0; box-sizing: border-box; overflow: hidden; }
.diag-cell .dt-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.diag-cell[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% - 8px);
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    padding: 6px 10px;
    background: #222;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.3;
    text-align: center;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 80;
    pointer-events: none;
}
.cat-subrow-gap.no-l::before { width: 3px; border: none; border-radius: 0; background: #0066b3; }
.cat-subrow-gap.no-r::after { width: 3px; border: none; border-radius: 0; background: #0066b3; }

/* notch: removes the row's top border under the open card so the shape is continuous */
.cat-subrow-gap {
    position: absolute;
    top: -3px;
    height: 4px;
    background: #fff;
    box-shadow: -12px 0 0 #fff, 12px 0 0 #fff;
    pointer-events: none;
}
.cat-subrow-gap.no-l { box-shadow: 12px 0 0 #fff; }
.cat-subrow-gap.no-r { box-shadow: -12px 0 0 #fff; }
.cat-subrow-gap::before,
.cat-subrow-gap::after {
    content: '';
    position: absolute;
    top: -9px;
    width: 12px;
    height: 12px;
}
.cat-subrow-gap::before {
    right: 100%;
    box-sizing: border-box;
    border-right: 3px solid #0066b3;
    border-bottom: 3px solid #0066b3;
    border-bottom-right-radius: 12px;
}
.cat-subrow-gap::after {
    left: 100%;
    box-sizing: border-box;
    border-left: 3px solid #0066b3;
    border-bottom: 3px solid #0066b3;
    border-bottom-left-radius: 12px;
}

.diag-thumb {
    flex-shrink: 0;
    width: 170px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.diag-thumb:hover { box-shadow: 0 2px 8px rgba(0,102,179,.25); }
.diag-thumb.active { outline: 3px solid #0066b3; }
.diag-thumb img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    background: #fff;
    display: block;
}
.diag-thumb .dt-name {
    padding: 6px 8px 2px;
    font-weight: 600;
    font-size: 0.72em;
    color: #0066b3;
    line-height: 1.2;
    min-height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.diag-thumb .dt-meta { padding: 0 8px 6px; font-size: 0.68em; color: #000; text-align: center; }

/* ── Stacked sections: diagram | parts, divided by blue lines ── */
.bmw2-section {
    display: grid;
    grid-template-columns: 55fr 45fr;
    background: #fff;
}
.bmw2-section + .bmw2-section { border-top: 2px solid #0066b3; }

.bmw2-section .diagram-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
}
.bmw2-section .diagram-panel img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s;
}
.bmw2-section .diagram-panel img:hover { transform: scale(1.02); }

.bmw2-section .parts-panel {
    display: flex;
    flex-direction: column;
    max-height: 700px;
}
.bmw2-section-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: #0066b3;
    padding: 12px 14px 8px;
    border-bottom: 1px solid #e0e0e0;
}
.bmw2-section-count { font-size: 0.75rem; font-weight: 500; color: #888; margin-left: 6px; }
.bmw2-section .parts-table-container {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85em;
    padding: 0 10px 4px;
}
.bmw2-section .parts-table-container::-webkit-scrollbar { width: 8px; }
.bmw2-section .parts-table-container::-webkit-scrollbar-track { background: #e0e0e0; border-radius: 4px; }
.bmw2-section .parts-table-container::-webkit-scrollbar-thumb { background: #0066b3; border-radius: 4px; }

@media (max-width: 900px) {
    .bmw2-container { padding: 0 0.5rem 1.5rem; }
    .brand-subheader { flex-direction: column; align-items: center; text-align: center; }
    .brand-subheader .breadcrumb, .brand-subheader .model-meta { align-items: center; text-align: center; }
    .bmw2-section { grid-template-columns: 1fr; }
    .bmw2-section .diagram-panel { border-right: none; border-bottom: 1px solid #e0e0e0; }
    .bmw2-section .diagram-panel img { max-height: 320px; }
    .bmw2-section .parts-panel { max-height: none; }
    .bmw2-section .parts-table-container { max-height: none; overflow-y: visible; }
    .cat-item { width: 140px; }
}

/* ── BMW part detail modal (bmw-part-modal.js) ── */
.bpm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 10000; padding: 20px; }
.bpm-overlay.active { display: flex; }
.bpm-card { background: #fff; border-radius: 10px; max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.bpm-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 1.8rem; color: #666; cursor: pointer; line-height: 1; }
.bpm-close:hover { color: #0066b3; }
.bpm-img-wrap { display: flex; align-items: flex-start; justify-content: center; background: #f7f7f7; border: 1px solid #e8e8e8; border-radius: 8px; padding: 10px; }
.bpm-img-wrap img { max-width: 100%; max-height: 260px; object-fit: contain; }
.bpm-info { min-width: 0; }
.bpm-name { font-size: 1.15rem; font-weight: 700; color: #1a1a1a; line-height: 1.3; margin-bottom: 6px; }
.bpm-partnum { font-size: .82rem; color: #888; letter-spacing: .3px; margin-bottom: 8px; }
.bpm-ref { font-size: .85rem; color: #0066b3; font-weight: 600; margin-bottom: 10px; }
.bpm-desc { font-size: .88rem; color: #444; line-height: 1.5; margin-bottom: 14px; }
.bpm-price-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bpm-price { font-size: 1.3rem; font-weight: 700; color: #0066b3; }
.bpm-avail { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .4px; }
.bpm-avail .es-avail-text.in { color: #1a7a1a; }
.bpm-avail .es-avail-text.so { color: #b8860b; }
.bpm-avail .es-avail-text.na { color: #b00; }
.bpm-actions { display: flex; gap: 10px; align-items: center; }
.bpm-actions .cart-qty-input { width: 60px; }
.bpm-actions .add-btn { flex: 1; padding: 10px 16px; }
.bmw-acc .parts-table tbody tr { cursor: pointer; }
.bmw-acc .parts-table tbody tr:hover td { background: #f0f7fc; }

@media (max-width: 640px) {
    .bpm-card { grid-template-columns: 1fr; padding: 18px; }
    .bpm-img-wrap img { max-height: 200px; }
}

/* ── Accessories item cards (Ducati-style: name / image / dot+price) ── */
.es-fluids-grid .acc-item { background: #fff; border: 2px solid #0066b3; border-radius: 8px; overflow: hidden; transition: all .25s ease; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.12); display: flex; flex-direction: column; }
.es-fluids-grid .acc-item:hover { transform: translateY(-4px); box-shadow: 0 4px 16px rgba(0,102,179,.25); }
.es-fluids-grid .acc-item.in-stock { border-color: #2e7d32; }
.es-fluids-grid .acc-item.in-stock:hover { box-shadow: 0 4px 16px rgba(46,125,50,.35); }
.acc-item-name { font-size: .9rem; font-weight: 600; color: #1a1a1a; line-height: 1.3; text-align: center; padding: .9rem .75rem .35rem; min-height: 2.8em; display: flex; align-items: center; justify-content: center; }
.acc-item-img { width: 100%; height: 190px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.acc-item-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.acc-item-footer { display: flex; justify-content: center; align-items: center; margin-top: auto; padding: .4rem .75rem; border-top: 1px solid #eee; position: relative; }
.acc-item-price-wrap { display: flex; align-items: center; justify-content: center; flex: 1; }
.acc-item .es-fluid-price { font-size: 1rem; font-weight: 700; color: #0066b3; }
.acc-item .acc-item-avail { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; }
