/* =====================================================================
   Каталог: меню «Каталог», хлебные крошки, галерея и карточка товара
   (подключается после site.css)
   ===================================================================== */

/* ---------- Читаемость (светлая и тёмная темы) ---------- */
:root { --muted-color: #566170; }
[data-theme="dark"] { --muted-color: #b4bcc8; }
.badge-hit { background: #e85d04; }

/* ---------- Меню «Каталог» ---------- */
.catalog-toggle { display: inline-flex; align-items: center; }
.catalog-toggle::after { margin-left: .5em; }
.mega-catalog {
    padding: 0; border: 1px solid var(--border-color); border-radius: 20px; background: var(--card-bg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28); overflow: hidden;
}
.mega-catalog.show { animation: megaIn .22s ease both; }
@keyframes megaIn { from { opacity: 0; margin-top: 8px; } to { opacity: 1; margin-top: 0; } }
.mega-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 22px; border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(255, 193, 7, .16), transparent 70%);
}
.mega-title { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 1.05rem; color: var(--body-color); }
.mega-title i { color: #d49a00; }
.mega-all { font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--primary-color); white-space: nowrap; }
.mega-all:hover { text-decoration: underline; }
.mega-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 14px; max-height: 68vh; overflow-y: auto; }
.mega-item {
    display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 14px;
    text-decoration: none; color: var(--body-color); border: 1px solid transparent; transition: background .18s, border-color .18s, transform .18s;
}
.mega-item:hover, .mega-item:focus-visible {
    background: var(--section-bg); border-color: var(--border-color); color: var(--body-color); transform: translateY(-1px); outline: 0;
}
.mega-thumb {
    position: relative; width: 54px; height: 54px; flex: 0 0 54px; border-radius: 14px; overflow: hidden;
    background: linear-gradient(135deg, #fff8dc, #ffe08a); display: flex; align-items: center; justify-content: center;
    color: #b78300; font-size: 1.35rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.mega-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.mega-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mega-name { font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mega-count { font-size: .78rem; color: var(--muted-color); margin-top: 2px; }
.mega-item:hover .mega-name { color: var(--primary-color); }

@media (min-width: 992px) {
    .navbar > .container { position: relative; }
    .navbar .catalog-dropdown { position: static; }
    .navbar .mega-catalog {
        position: absolute; top: calc(100% + 10px); left: 50%; right: auto; transform: translateX(-50%);
        width: min(900px, calc(100vw - 32px)); margin: 0;
    }
}
@media (max-width: 1199.98px) and (min-width: 992px) { .mega-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 991.98px) {
    .mega-catalog { position: static; width: 100%; transform: none; box-shadow: none; border-radius: 14px; margin: 6px 0 10px; }
    .mega-grid { grid-template-columns: 1fr 1fr; max-height: 55vh; padding: 10px; }
    .mega-head { padding: 12px 16px; }
}
@media (max-width: 520px) {
    .mega-grid { grid-template-columns: 1fr; }
    .mega-thumb { width: 46px; height: 46px; flex-basis: 46px; }
}

/* ---------- Хлебные крошки ---------- */
.crumbs { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; margin: 0 0 18px; border-radius: 16px; }
.crumb-back {
    flex: 0 0 38px; width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--section-bg); color: var(--body-color); text-decoration: none; border: 1px solid var(--border-color); transition: all .2s;
}
.crumb-back:hover { background: var(--warning-color); border-color: var(--warning-color); color: #1b1f27; transform: translateX(-2px); }
.crumb-list { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; }
.crumb-list::-webkit-scrollbar { display: none; }
.crumb { flex: 0 0 auto; }
.crumb a, .crumb.current .crumb-text { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 10px; font-size: .92rem; font-weight: 600; white-space: nowrap; }
.crumb a { color: var(--body-color); text-decoration: none; transition: background .18s, color .18s; }
.crumb a i { color: #d49a00; }
.crumb a:hover { background: var(--section-bg); color: var(--primary-color); }
.crumb.current { flex: 0 1 auto; min-width: 0; }
.crumb.current .crumb-text { background: rgba(255, 193, 7, .22); color: var(--body-color); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; display: block; }
[data-theme="dark"] .crumb.current .crumb-text { background: rgba(255, 212, 59, .16); }
.crumb-sep { flex: 0 0 auto; color: var(--muted-color); font-size: .68rem; padding: 0 1px; }
@media (max-width: 576px) {
    .crumb a, .crumb.current .crumb-text { padding: 6px 10px; font-size: .85rem; }
    .crumb:first-child a .crumb-text { display: none; }      /* у «Главной» на телефоне остаётся только домик */
    .crumb.current .crumb-text { max-width: 30ch; }
}
.page-hero .crumbs { margin-bottom: 22px; }

/* ---------- Полоса «найдено / сортировка» ---------- */
.list-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; padding: 0 4px; }
.list-found { font-weight: 600; color: var(--body-color); }
.has-bg .list-bar { background: var(--glass-bg); padding: 10px 16px; border-radius: 14px; border: 1px solid var(--glass-border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.sort-form .form-select { min-width: 190px; }

/* ---------- Галерея товара ---------- */
.product-detail { overflow: hidden; }
.gallery { display: grid; grid-template-columns: 88px 1fr; gap: 14px; padding: 24px; position: relative; outline: 0; }
.gallery.single { grid-template-columns: 1fr; }
.gallery:focus-visible .g-stage { box-shadow: 0 0 0 3px rgba(255, 193, 7, .6); }
@media (min-width: 992px) { .gallery { position: static; } .product-detail .row > [class*="col-"] { align-self: stretch; } }
.g-thumbs { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 560px; padding: 2px; scrollbar-width: thin; }
.g-thumb {
    flex: 0 0 auto; width: 100%; aspect-ratio: 1; padding: 4px; border-radius: 12px; background: #fff; cursor: pointer;
    border: 2px solid var(--border-color); opacity: .78; transition: all .18s;
}
.g-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px; }
.g-thumb:hover { opacity: 1; border-color: #f0b400; }
.g-thumb.active { opacity: 1; border-color: var(--warning-color); box-shadow: 0 0 0 3px rgba(255, 193, 7, .3); }
.g-stage {
    position: relative; background: #fff; border-radius: 18px; overflow: hidden; aspect-ratio: 1 / 1; max-height: 560px; width: 100%;
    display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); touch-action: pan-y; user-select: none;
}
.g-main { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; padding: 14px; cursor: zoom-in; animation: gFade .25s ease; }
@keyframes gFade { from { opacity: .35; } to { opacity: 1; } }
.g-badges { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; z-index: 2; }
.g-nav {
    position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: rgba(20, 24, 32, .72); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1rem;
    transition: background .18s, transform .18s; z-index: 3; cursor: pointer;
}
.g-nav:hover { background: var(--warning-color); color: #14171c; transform: translateY(-50%) scale(1.08); }
.g-prev { left: 12px; } .g-next { right: 12px; }
.g-zoom {
    position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 12px; border: 0; z-index: 3;
    background: rgba(20, 24, 32, .72); color: #fff; cursor: pointer; transition: background .18s;
}
.g-zoom:hover { background: var(--warning-color); color: #14171c; }
.g-count {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(20, 24, 32, .75); color: #fff;
    font-size: .8rem; padding: 4px 12px; border-radius: 20px; z-index: 3;
}
@media (max-width: 767.98px) {
    .gallery { grid-template-columns: 1fr; padding: 14px; }
    .g-thumbs { flex-direction: row; order: 2; overflow-x: auto; overflow-y: hidden; max-height: none; }
    .g-thumb { width: 66px; flex: 0 0 66px; }
    .g-nav { width: 38px; height: 38px; }
}

/* ---------- Сводка по товару ---------- */
.product-info { padding: 30px 32px 28px; }
.product-cat-chip {
    display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px; font-size: .8rem; font-weight: 600; text-decoration: none;
    background: var(--section-bg); border: 1px solid var(--border-color); color: var(--body-color); margin-bottom: 12px;
}
.product-cat-chip i { color: #d49a00; }
.product-cat-chip:hover { background: var(--warning-color); border-color: var(--warning-color); color: #1b1f27; }
.product-title { font-family: 'Montserrat', sans-serif; font-size: clamp(1.45rem, 2.6vw, 2rem); font-weight: 800; line-height: 1.2; margin-bottom: 12px; }
.product-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 18px; font-size: .92rem; }
.meta-item { color: var(--muted-color); }
.meta-item i { margin-right: 6px; }
.meta-item b { color: var(--body-color); }
.product-meta .product-stock { margin: 0; font-weight: 600; }
.price-box {
    padding: 18px 20px; border-radius: 16px; margin-bottom: 18px;
    background: linear-gradient(135deg, rgba(255, 193, 7, .16), rgba(255, 193, 7, .04)); border: 1px solid rgba(240, 180, 0, .45);
}
.price-main { font-size: clamp(1.9rem, 4vw, 2.5rem); font-weight: 800; line-height: 1.1; color: var(--body-color); font-variant-numeric: tabular-nums; }
.price-main .cur { font-size: .5em; font-weight: 700; color: var(--muted-color); }
.price-main .unit { font-size: .45em; }
.price-old { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.price-old .old-price { font-size: 1.05rem; }
.price-old .save { color: var(--success-color); font-weight: 600; font-size: .9rem; }
.product-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.btn-cta-call, .btn-cta-write { flex: 1 1 230px; padding: 13px 16px; white-space: nowrap; font-size: .95rem; border-radius: 14px; font-weight: 700; border: 2px solid transparent; transition: all .2s; }
.btn-cta-call { background: var(--warning-color); color: #14171c; box-shadow: 0 6px 18px rgba(255, 193, 7, .4); }
.btn-cta-call:hover { background: #ffca2c; color: #14171c; transform: translateY(-2px); }
.btn-cta-write { background: transparent; border-color: var(--border-color); color: var(--body-color); }
.btn-cta-write:hover { border-color: var(--primary-color); color: var(--primary-color); transform: translateY(-2px); }
.key-attrs { list-style: none; padding: 0; margin: 0 0 18px; border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden; }
.key-attrs li { display: flex; justify-content: space-between; gap: 14px; padding: 9px 16px; font-size: .93rem; }
.key-attrs li + li { border-top: 1px solid var(--border-color); }
.key-attrs li:nth-child(odd) { background: var(--section-bg); }
.key-attrs span { color: var(--muted-color); }
.key-attrs b { text-align: right; }

/* ---------- Вкладки под карточкой ---------- */
.product-tabs { padding: 8px 28px 28px; margin-top: 28px; }
.product-tabs .nav-tabs { border-bottom: 2px solid var(--border-color); gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.product-tabs .nav-link { color: var(--muted-color) !important; font-weight: 700; border: 0; border-bottom: 3px solid transparent; margin: 0 0 -2px; padding: 16px 20px; white-space: nowrap; background: transparent; }
.product-tabs .nav-link:hover { color: var(--body-color) !important; }
.product-tabs .nav-link.active { color: var(--body-color) !important; border-bottom-color: var(--warning-color); background: transparent; }
.tab-count { background: var(--warning-color); color: #14171c; border-radius: 20px; font-size: .72rem; padding: 1px 8px; margin-left: 4px; }
.product-tabs .tab-content { padding-top: 24px; }
.product-description { line-height: 1.8; font-size: 1.04rem; max-width: 80ch; }
.attrs-table { width: 100%; max-width: 760px; border-collapse: collapse; }
.attrs-table th, .attrs-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-color); background: transparent; vertical-align: top; }
.attrs-table th { width: 42%; font-weight: 500; color: var(--muted-color); }
.attrs-table td { font-weight: 600; color: var(--body-color); }
.attrs-table tr:nth-child(odd) { background: var(--section-bg); }
.product-tabs .contact-card-mini { max-width: 640px; }

/* ---------- Просмотр фото на весь экран ---------- */
.lightbox { background: rgba(8, 10, 14, .96); border: 0; border-radius: 0; align-items: center; justify-content: center; position: relative; }
.lightbox #imgModalImg { max-width: 94vw; max-height: 90vh; object-fit: contain; user-select: none; }
.lb-close { position: absolute; top: 18px; right: 20px; z-index: 5; font-size: 1.3rem; }
.lb-count { position: absolute; top: 22px; left: 22px; color: #fff; background: rgba(255, 255, 255, .14); padding: 4px 14px; border-radius: 20px; font-size: .9rem; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lightbox .g-nav { width: 52px; height: 52px; }

@media (max-width: 767.98px) {
    .product-info { padding: 20px 18px; }
    .product-tabs { padding: 4px 16px 20px; }
    .product-tabs .nav-link { padding: 12px 14px; }
    .attrs-table th, .attrs-table td { padding: 10px 8px; }
}
