/* ================================================================
   product.css — карточка товара
   Mobile-first. Без внешних зависимостей.
   Подключается только на is_product().
================================================================ */

/* ────────────────────────────────────────────────────────────────
   Страница товара
──────────────────────────────────────────────────────────────── */
.product-page {
    padding: 0 0 2.5rem;
}

/* ────────────────────────────────────────────────────────────────
   Хлебные крошки
──────────────────────────────────────────────────────────────── */
.breadcrumbs {
    padding: 0.75rem 0 1rem;
}

.breadcrumbs__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0;
    font-size: 0.8125rem;
    color: #6b7280;
}

.breadcrumbs__item {
    display: flex;
    align-items: center;
}

.breadcrumbs__item + .breadcrumbs__item::before {
    content: "›";
    margin: 0 0.35rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

.breadcrumbs__link {
    color: #2563eb;
    text-decoration: none;
}

.breadcrumbs__link:hover {
    text-decoration: underline;
}

.breadcrumbs__item--current {
    color: #374151;
    font-size: 0.8125rem;
    max-width: 28ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ────────────────────────────────────────────────────────────────
   Карточка — мобильный (single column)
──────────────────────────────────────────────────────────────── */
.product-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* ────────────────────────────────────────────────────────────────
   Галерея
──────────────────────────────────────────────────────────────── */
.product-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-gallery__main {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-gallery__main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.product-gallery__thumbs {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.product-gallery__thumb {
    width: 56px;
    height: 56px;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
    background: #fafafa;
    padding: 0;
    cursor: pointer;
    transition: border-color 0.15s;
}

.product-gallery__thumb:hover,
.product-gallery__thumb.is-active {
    border-color: #2563eb;
}

.product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Placeholder когда нет фото */
.product-gallery__placeholder {
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #9ca3af;
}

.product-gallery__placeholder svg {
    width: 80px;
    height: 80px;
    opacity: 0.35;
}

.product-gallery__placeholder span {
    font-size: 0.8125rem;
    color: #9ca3af;
}

/* ────────────────────────────────────────────────────────────────
   Заголовок товара
──────────────────────────────────────────────────────────────── */
.product-card__title {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.3;
    color: #111827;
    margin: 0 0 0.75rem;
}

/* Мета-строки (артикул, производитель, серия) */
.product-card__meta {
    display: grid;
    gap: 0.3rem;
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
}

.product-card__meta-row {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
}

.product-card__meta-row dt {
    color: #6b7280;
    font-weight: 400;
    white-space: nowrap;
    min-width: 0;
}

.product-card__meta-row dt::after {
    content: ":";
}

.product-card__meta-row dd {
    color: #111827;
    font-weight: 500;
    margin: 0;
}

.product-card__sku {
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 0.8125rem;
    color: #4b5563;
    background: #f3f4f6;
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

/* ────────────────────────────────────────────────────────────────
   Характеристики
──────────────────────────────────────────────────────────────── */
.product-card__section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.75rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #e5e7eb;
}

.product-specs-group {
    margin-bottom: 1rem;
}

.product-specs-group__title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin: 0 0 0.5rem;
}

.product-specs-group__list {
    display: grid;
    gap: 0;
    margin: 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.product-specs-group__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #f3f4f6;
}

.product-specs-group__row:last-child {
    border-bottom: none;
}

.product-specs-group__row:nth-child(even) {
    background: #f9fafb;
}

.product-specs-group__row dt {
    color: #6b7280;
    font-weight: 400;
}

.product-specs-group__row dd {
    color: #111827;
    font-weight: 500;
    margin: 0;
}

.product-specs__unit {
    color: #6b7280;
    font-weight: 400;
    margin-left: 0.2em;
    font-size: 0.8125rem;
}

/* ────────────────────────────────────────────────────────────────
   DataSheet
──────────────────────────────────────────────────────────────── */
.product-card__datasheet {
    margin-top: 1.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border: 1px solid transparent;
}

.btn--outline {
    border-color: #d1d5db;
    color: #374151;
    background: #fff;
}

.btn--outline:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.btn--datasheet svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────────
   Полезная информация
──────────────────────────────────────────────────────────────── */
.product-card__extra {
    margin-top: 1.5rem;
}

.product-card__extra-body {
    font-size: 0.875rem;
    line-height: 1.65;
    color: #374151;
}

.product-card__extra-body p {
    margin: 0 0 0.5rem;
}

/* ────────────────────────────────────────────────────────────────
   Боковая панель (aside)
──────────────────────────────────────────────────────────────── */
.product-card__aside {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-self: start;
}

/* Наличие */
.product-availability {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
}

.product-availability::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.product-availability--in-stock {
    background: #dcfce7;
    color: #15803d;
}

.product-availability--in-stock::before {
    background: #22c55e;
}

.product-availability--out-of-stock {
    background: #fee2e2;
    color: #dc2626;
}

.product-availability--out-of-stock::before {
    background: #ef4444;
}

/* Таблица цен */
.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.price-table th {
    text-align: left;
    color: #6b7280;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 0 0.4rem;
    border-bottom: 1px solid #e5e7eb;
}

.price-table td {
    padding: 0.45rem 0;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.price-table tr:last-child td {
    border-bottom: none;
}

.price-table__price {
    font-weight: 600;
    color: #111827;
    text-align: right;
    font-size: 1rem;
}

.price-table__row--base .price-table__price {
    font-size: 1.125rem;
    color: #1d4ed8;
}

.product-card__prices--none p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

/* Фасовка */
.product-card__package {
    font-size: 0.875rem;
    color: #374151;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.product-card__package-label {
    color: #6b7280;
}

.product-card__package-qty {
    font-weight: 500;
}

/* Контакты */
.product-card__contact {
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}

.product-card__contact-hint {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 0.35rem;
}

.product-card__phone {
    display: block;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
}

.product-card__phone:hover {
    color: #2563eb;
}

.product-card__phone-hours {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.2rem;
}

/* ────────────────────────────────────────────────────────────────
   Аналоги и замены
──────────────────────────────────────────────────────────────── */
.product-analogs {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.product-analogs__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 1rem;
}

.product-analogs__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.product-analogs__table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.product-analogs__table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    padding: 0.5rem 0.6rem;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.product-analogs__table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: middle;
}

.product-analogs__table tr:hover td {
    background: #f9fafb;
}

.product-analogs__table a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.product-analogs__table a:hover {
    text-decoration: underline;
}

.product-analogs__price {
    text-align: right;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.analog-type {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15em 0.5em;
    border-radius: 999px;
}

.analog-type--replacement {
    background: #fef3c7;
    color: #92400e;
}

.analog-type--analog {
    background: #dbeafe;
    color: #1e40af;
}

/* ────────────────────────────────────────────────────────────────
   Mobile: порядок блоков через order
   DOM-порядок: gallery(1) header(2) main(3) aside(4)
   Нужный порядок на mobile: gallery header aside main
──────────────────────────────────────────────────────────────── */
.product-card__gallery { order: 1; }
.product-card__header  { order: 2; }
.product-card__aside   { order: 3; }
.product-card__main    { order: 4; }

/* ────────────────────────────────────────────────────────────────
   Tablet: 2 колонки, ~68% / ~32%
──────────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .product-card {
        grid-template-columns: minmax(0, 68fr) minmax(0, 32fr);
        grid-template-areas:
            "gallery aside"
            "header  aside"
            "main    aside";
        align-items: start;
        gap: 1.25rem;
    }

    /* Сбрасываем мобильный order — grid-area управляет расположением */
    .product-card__gallery,
    .product-card__header,
    .product-card__main,
    .product-card__aside  { order: unset; }

    .product-card__gallery { grid-area: gallery; }
    .product-card__header  { grid-area: header;  }
    .product-card__main    { grid-area: main;    }

    .product-card__aside {
        grid-area: aside;
        position: sticky;
        top: 1rem;
        /* Компактнее на tablet */
        padding: 1rem;
        font-size: 0.875rem;
    }

    .product-card__title {
        font-size: 1.375rem;
    }
}

/* ────────────────────────────────────────────────────────────────
   Desktop: 3 колонки
──────────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
    .product-card {
        grid-template-columns: 280px minmax(0, 1fr) 280px;
        grid-template-areas:
            "gallery header aside"
            "gallery main   aside";
        gap: 2rem;
    }

    .product-card__gallery { grid-area: gallery; }
    .product-card__header  { grid-area: header;  }
    .product-card__main    { grid-area: main;    }

    .product-card__aside {
        grid-area: aside;
        padding: 1.25rem;
        font-size: 1rem;
    }

    .product-card__title {
        font-size: 1.5rem;
    }

    .product-specs-group__row {
        grid-template-columns: 1.2fr 1fr;
    }
}

@media (min-width: 1280px) {
    .product-card {
        grid-template-columns: 320px minmax(0, 1fr) 300px;
    }
}

/* ================================================================
   МИКРОПРАВКИ: аналоги (mobile-карточки), галерея, breadcrumbs
================================================================ */

/* ── Breadcrumbs: горизонтальный scroll только внутри nav ── */
.breadcrumbs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.breadcrumbs::-webkit-scrollbar { display: none; }
.breadcrumbs__list {
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* ── Gallery: ограничение высоты на mobile ── */
@media (max-width: 767px) {
    .product-gallery__main {
        aspect-ratio: unset;
        max-height: 56vw;
        min-height: 160px;
    }
    .product-gallery__placeholder {
        aspect-ratio: unset;
        max-height: 56vw;
        min-height: 160px;
    }
}

/* ================================================================
   АНАЛОГИ: карточный вид (< 1024px) / таблица (≥ 1024px)
================================================================ */
.product-analogs__cards      { display: flex; flex-direction: column; gap: 0.75rem; }
.product-analogs__table-wrap { display: none; }

@media (min-width: 1024px) {
    .product-analogs__cards      { display: none; }
    .product-analogs__table-wrap { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Одна карточка аналога ── */
.analog-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.analog-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}
.analog-card__name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #111827;
    flex: 1;
    min-width: 0;
}
.analog-card__name a {
    color: #2563eb;
    text-decoration: none;
    word-break: break-word;
}
.analog-card__name a:hover { text-decoration: underline; }
.analog-card__name span    { word-break: break-all; }

.analog-card__row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.875rem;
}
.analog-card__label { color: #6b7280; white-space: nowrap; flex-shrink: 0; }
.analog-card__label::after { content: ":"; }
.analog-card__val { color: #374151; }
.analog-card__val--mono {
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 0.8125rem;
    background: #f3f4f6;
    padding: 0.1em 0.4em;
    border-radius: 3px;
}
.analog-card__prices {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f3f4f6;
}
.analog-card__price-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.875rem;
}
.analog-card__price-label { color: #6b7280; }
.analog-card__price-val   { font-weight: 600; font-variant-numeric: tabular-nums; color: #111827; }
