/* ── Catalog Page Layout ──────────────────────────────────────────────── */

.catalog-page {
    padding-top: calc(var(--header-height) + 24px);
    min-height: 100vh;
}

.catalog-page h1 {
    font-size: 1.75rem;
    margin-bottom: 24px;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    align-items: start;
}

/* ── Breadcrumbs ─────────────────────────────────────────────────────── */

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs__sep { color: var(--text-muted); }

/* ── Sidebar Filters ─────────────────────────────────────────────────── */

.catalog-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

.sidebar-inner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.sidebar-header h3 { margin: 0; font-size: 1.1rem; }
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.filter-block {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.filter-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filter-block__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Category tree */
.cat-tree {
    list-style: none;
    font-size: 0.875rem;
}
.cat-tree > li { margin-bottom: 2px; }
.cat-tree__link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.cat-tree__link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}
.cat-tree__link--active {
    color: var(--accent);
    background: rgba(245,158,11,0.08);
    font-weight: 600;
}
.cat-tree__count {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 24px;
    text-align: right;
}
.cat-tree__sub {
    list-style: none;
    padding-left: 16px;
    display: none;
}
.cat-tree__parent--open > .cat-tree__sub {
    display: block;
}
.cat-tree__parent > .cat-tree__link::before {
    content: '▸';
    margin-right: 6px;
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.cat-tree__parent--open > .cat-tree__link::before {
    transform: rotate(90deg);
}

/* Brand checkboxes */
.brand-checks {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.check-label input[type="checkbox"],
.check-label input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
.check-label span:first-of-type { flex: 1; }
.check-label__count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Price range */
.price-range {
    display: flex;
    align-items: center;
    gap: 8px;
}
.price-range span { color: var(--text-muted); }
.price-range .form-control--sm { width: 100%; }

.form-control--sm {
    padding: 8px 10px;
    font-size: 0.8125rem;
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.catalog-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.catalog-toolbar__left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.catalog-toolbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.catalog-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.catalog-filter-toggle {
    display: none;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.view-btn {
    padding: 8px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.view-btn svg { fill: currentColor; }
.view-btn:hover { color: var(--text-primary); }
.view-btn--active {
    background: var(--bg-card);
    color: var(--accent);
}

/* ── Product Grid ────────────────────────────────────────────────────── */

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* List view */
.product-grid--list {
    grid-template-columns: 1fr;
}
.product-grid--list .pcard {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0;
}
.product-grid--list .pcard__img {
    aspect-ratio: 1;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.product-grid--list .pcard__body {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.product-grid--list .pcard__title { flex: 1; min-width: 200px; }

/* Product card */
.pcard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.pcard:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-light);
}

.pcard__img {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4/3;
    background: var(--bg-secondary);
    overflow: hidden;
}
.pcard__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.pcard:hover .pcard__img img {
    transform: scale(1.03);
}

.pcard__body {
    padding: 16px;
}

.pcard__brand {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.pcard__title {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.pcard__title:hover { color: var(--accent); }

.pcard__specs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 10px;
}
.pcard__spec {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.pcard__price {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.stock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 10px;
}
.stock::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.stock--in { color: var(--success); }
.stock--in::before { background: var(--success); }
.stock--order { color: var(--warning); }
.stock--order::before { background: var(--warning); }
.stock--out { color: var(--text-muted); }
.stock--out::before { background: var(--text-muted); }

.pcard__btn {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

.pcard--compact {
    flex: 0 0 220px;
    scroll-snap-align: start;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* ── Pagination ──────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.pagination__btn,
.pagination__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.pagination__btn:hover,
.pagination__num:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.pagination__num--active {
    background: var(--accent);
    color: #000;
    font-weight: 700;
}
.pagination__dots {
    color: var(--text-muted);
    padding: 0 4px;
}

/* ── Product Detail Page ─────────────────────────────────────────────── */

.product-page {
    padding-top: calc(var(--header-height) + 24px);
    padding-bottom: 64px;
    min-height: 100vh;
}

.product-main {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 40px;
    margin-bottom: 48px;
}

/* Gallery */
.product-gallery__main {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
}
.product-gallery__main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.product-gallery__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-gallery__thumbs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
}
.product-gallery__thumb {
    flex: 0 0 72px;
    height: 72px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-secondary);
    padding: 0;
    transition: border-color 0.15s;
}
.product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.product-gallery__thumb--active,
.product-gallery__thumb:hover {
    border-color: var(--accent);
}

/* Product info */
.product-info__brand {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 8px;
}

.product-info h1 {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.product-info__price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}
.product-info__price-value {
    font-size: 1.75rem;
    font-weight: 700;
}
.product-info__price-usd {
    font-size: 1rem;
    color: var(--text-secondary);
}
.product-info__price-old {
    font-size: 1rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-info__stock {
    margin-bottom: 20px;
}
.product-info__stock .stock { font-size: 0.875rem; }

.product-info__actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.product-info__short {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
}

/* Product sections */
.product-section {
    margin-bottom: 48px;
}
.product-section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.specs-table {
    width: 100%;
    max-width: 600px;
}
.specs-table tr { border-bottom: 1px solid var(--border); }
.specs-table tr:last-child { border-bottom: none; }
.specs-table td { padding: 10px 16px 10px 0; font-size: 0.875rem; }
.specs-table__key {
    color: var(--text-secondary);
    width: 40%;
    white-space: nowrap;
}
.specs-table__val {
    color: var(--text-primary);
    font-weight: 500;
}

.product-desc {
    color: var(--text-secondary);
    line-height: 1.8;
    max-width: 700px;
}

/* ── Lightbox ────────────────────────────────────────────────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: center;
    justify-content: center;
}
.lightbox--open {
    display: flex;
}
.lightbox__img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}
.lightbox__close,
.lightbox__prev,
.lightbox__next {
    position: absolute;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 16px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover { opacity: 1; }
.lightbox__close { top: 16px; right: 16px; }
.lightbox__prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 16px; top: 50%; transform: translateY(-50%); }

/* ── Modal ───────────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal--open { display: flex; }
.modal__content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal__header h3 { margin: 0; }
.modal__close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(0,0,0,0.5);
}
.sidebar-overlay--visible { display: block; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .product-main { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .catalog-layout {
        grid-template-columns: 1fr;
    }

    .catalog-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100%;
        z-index: 900;
        background: var(--bg-primary);
        transition: left 0.3s;
        overflow-y: auto;
        padding: 20px;
    }
    .catalog-sidebar--open {
        left: 0;
    }
    .catalog-sidebar--open .sidebar-inner {
        border: none;
        padding: 0;
    }

    .sidebar-close { display: block; }
    .catalog-filter-toggle { display: inline-flex; }

    .product-grid { grid-template-columns: 1fr; }
    .product-grid--list .pcard { grid-template-columns: 80px 1fr; }
}
