/*
 * catalog.css — оформление каталога: строка поиска, таблица предложений,
 * карточка товара. Палитра взята из custom.css, чтобы каталог не выбивался
 * из остального сайта.
 */

:root {
    --scn-primary: #07575B;
    --scn-primary-dark: #04383b;
    --scn-accent: #007cbc;
    --scn-success: #146c43;
    --scn-line: #e0e0e0;
    --scn-bg-soft: #f5f7f8;
    --scn-text-muted: #7b7b7b;

    /* Типы складов. Цвета те же, что были в старой таблице, но приглушённые */
    --scn-stock-own: #dc3545;
    --scn-stock-order: #0dcaf0;
    --scn-stock-partner: #198754;
}

/* ── Строка поиска ─────────────────────────────────────────────── */

.search-hero {
    background: var(--scn-bg-soft);
    border-bottom: 1px solid var(--scn-line);
    padding: 1.75rem 0 1.5rem;
    margin-bottom: 1.5rem;
}

.search-hero__title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--scn-primary);
    margin-bottom: 0.9rem;
}

.search-form {
    display: flex;
    max-width: 620px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.search-form__input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid var(--scn-line);
    border-right: none;
    border-radius: 3px 0 0 3px;
    padding: 0.7rem 1rem;
    font-size: 1rem;
}

.search-form__input:focus {
    outline: none;
    border-color: var(--scn-primary);
}

.search-form__btn {
    flex: 0 0 auto;
    border: none;
    border-radius: 0 3px 3px 0;
    background: var(--scn-primary);
    color: #fff;
    padding: 0.7rem 1.6rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.search-form__btn:hover {
    background: var(--scn-primary-dark);
}

.search-hero__hint {
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    color: var(--scn-text-muted);
}

/* ── Панель пользователя ───────────────────────────────────────── */

.user-panel {
    background: #fff;
    border: 1px solid var(--scn-line);
    border-radius: 4px;
    padding: 0.9rem 1.1rem;
    font-size: 0.88rem;
}

.user-panel__row {
    display: flex;
    gap: 0.6rem;
    padding: 0.18rem 0;
}

.user-panel__label {
    flex: 0 0 92px;
    color: var(--scn-text-muted);
}

.user-panel__value {
    flex: 1 1 auto;
    color: #222;
}

.stock-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--scn-line);
    font-size: 0.78rem;
    color: var(--scn-text-muted);
}

.stock-legend__item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stock-legend__item::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--scn-stock-order);
}

.stock-legend__item--own::before { background: var(--scn-stock-own); }
.stock-legend__item--partner::before { background: var(--scn-stock-partner); }

/* ── Заголовки блоков результатов ──────────────────────────────── */

.results-title {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin: 1.6rem 0 0.7rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--scn-primary);
}

.results-title__count {
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--scn-text-muted);
}

.results-note {
    font-size: 0.8rem;
    color: var(--scn-text-muted);
    background: #fffaf0;
    border-left: 3px solid #e0a800;
    padding: 0.55rem 0.8rem;
    margin-bottom: 0.9rem;
}

.results-empty {
    padding: 2.2rem 1rem;
    text-align: center;
    color: var(--scn-text-muted);
    border: 1px dashed var(--scn-line);
    border-radius: 4px;
}

/* ── Таблица предложений ───────────────────────────────────────── */

.offers {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
    background: #fff;
}

.offers thead th {
    background: var(--scn-primary);
    color: #fff;
    font-weight: 400;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.55rem 0.6rem;
    text-align: left;
    white-space: nowrap;
}

.offers tbody td {
    border-bottom: 1px solid var(--scn-line);
    padding: 0.6rem;
    vertical-align: middle;
}

.offers tbody tr:hover { background: #f8fbfb; }

/* Тип склада показан полосой слева, а не заливкой всей строки:
   так цветом не забивается текст */
.offers tbody tr { border-left: 3px solid transparent; }
.offers tbody tr.is-own { border-left-color: var(--scn-stock-own); }
.offers tbody tr.is-order { border-left-color: var(--scn-stock-order); }
.offers tbody tr.is-partner { border-left-color: var(--scn-stock-partner); }

.offers__brand {
    text-transform: uppercase;
    font-weight: 500;
    color: var(--scn-primary);
    white-space: nowrap;
}

.offers__num {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.85rem;
    white-space: nowrap;
}

.offers__name {
    color: #222;
    min-width: 220px;
}

.offers__name a { color: #222; text-decoration: none; }
.offers__name a:hover { color: var(--scn-accent); text-decoration: underline; }

.offers__photo-flag {
    color: var(--scn-accent);
    margin-left: 0.35rem;
    font-size: 0.8rem;
}

/* Табличные цифры — колонка цен читается как столбик */
.offers__price {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.offers__price span { font-size: 0.8rem; font-weight: 400; color: var(--scn-text-muted); }

.offers__qty { white-space: nowrap; font-variant-numeric: tabular-nums; }

.offers__term { white-space: nowrap; }

.offers__term--stock {
    color: var(--scn-success);
    font-weight: 500;
}

.offers__updated {
    font-size: 0.78rem;
    color: var(--scn-text-muted);
    white-space: nowrap;
}

.offers__cond, .offers__addr {
    font-size: 0.8rem;
    color: var(--scn-text-muted);
}

/* Форма добавления в корзину */
.buy-form {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.buy-form__qty {
    width: 58px;
    padding: 0.28rem 0.35rem;
    border: 1px solid var(--scn-line);
    border-radius: 3px;
    font-size: 0.85rem;
    text-align: center;
}

.buy-form__btn {
    border: none;
    border-radius: 3px;
    background: var(--scn-success);
    color: #fff;
    padding: 0.32rem 0.7rem;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s;
}

.buy-form__btn:hover { background: #0f5132; }

/* ── Выбор бренда и детали ─────────────────────────────────────── */

.choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.choice-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 190px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--scn-line);
    border-radius: 4px;
    background: #fff;
    text-decoration: none;
    color: #222;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.choice-card:hover {
    border-color: var(--scn-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    color: #222;
}

.choice-card__brand {
    text-transform: uppercase;
    font-weight: 500;
    color: var(--scn-primary);
}

.choice-card__num {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.82rem;
}

.choice-card__name { font-size: 0.8rem; color: var(--scn-text-muted); }

/* ── Панель входа в шапке ──────────────────────────────────────── */

.login-panel {
    background: var(--scn-primary-dark);
    padding: 0.85rem 0;
}

.login-panel .form-control { min-width: 180px; }

.btn-accent {
    background: var(--scn-accent);
    color: #fff;
    border: none;
}

.btn-accent:hover { background: #00669b; color: #fff; }

.login-error { color: #ffb3b3; margin-right: 0.4rem; }

.nav-link--accent { font-weight: 500; }
.nav-link--muted { opacity: 0.75; }

.nav-cart { display: inline-flex; align-items: center; gap: 0.4rem; }

.cart-badge {
    display: inline-block;
    min-width: 20px;
    padding: 0 0.32rem;
    border-radius: 10px;
    background: var(--scn-accent);
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.35;
}

.cart-badge--empty { background: rgba(255, 255, 255, 0.25); }

/* ── Карточка товара ───────────────────────────────────────────── */

.product-head { margin-bottom: 1.2rem; }

.product-title {
    font-size: 1.4rem;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.4rem;
    font-size: 0.86rem;
    color: var(--scn-text-muted);
}

.product-meta strong { color: #222; font-weight: 500; }

.product-gallery {
    border: 1px solid var(--scn-line);
    border-radius: 4px;
    background: #fff;
    padding: 0.9rem;
}

.product-gallery__main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    background: var(--scn-bg-soft);
    border-radius: 3px;
    overflow: hidden;
}

.product-gallery__main img { max-width: 100%; max-height: 320px; object-fit: contain; }

.product-gallery__empty {
    color: var(--scn-text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem 1rem;
}

.product-gallery__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.7rem;
}

.product-gallery__thumb {
    width: 62px;
    height: 62px;
    border: 1px solid var(--scn-line);
    border-radius: 3px;
    padding: 2px;
    background: #fff;
    cursor: pointer;
    object-fit: contain;
    transition: border-color 0.15s;
}

.product-gallery__thumb:hover,
.product-gallery__thumb.is-active { border-color: var(--scn-primary); }

/* Сводка: лучшее предложение */
.product-summary {
    border: 1px solid var(--scn-line);
    border-radius: 4px;
    background: #fff;
    padding: 1.1rem 1.2rem;
}

.product-summary__label {
    font-size: 0.8rem;
    color: var(--scn-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.product-summary__price {
    font-size: 2rem;
    font-weight: 500;
    color: var(--scn-primary);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.product-summary__price small { font-size: 1rem; color: var(--scn-text-muted); }

.product-summary__row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.42rem 0;
    border-bottom: 1px solid var(--scn-line);
    font-size: 0.88rem;
}

.product-summary__row:last-of-type { border-bottom: none; }

.product-summary__row span:first-child { color: var(--scn-text-muted); }

.badge-stock {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    background: #e6f4ec;
    color: var(--scn-success);
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-order {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    background: #e7f6fb;
    color: #0b6a86;
    font-size: 0.8rem;
    font-weight: 500;
}

.product-section { margin-top: 2rem; }

.product-section__title {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--scn-primary);
    padding-bottom: 0.45rem;
    margin-bottom: 0.9rem;
    border-bottom: 2px solid var(--scn-primary);
}

.spec-table { width: 100%; font-size: 0.88rem; }
.spec-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--scn-line); }
.spec-table td:first-child { color: var(--scn-text-muted); width: 42%; }

/* ── Адаптив: на узких экранах таблица становится карточками ───── */

@media (max-width: 991px) {
    .offers { font-size: 0.85rem; }
    .offers thead { display: none; }

    .offers tbody tr {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.2rem 0.7rem;
        border: 1px solid var(--scn-line);
        border-left-width: 3px;
        border-radius: 4px;
        margin-bottom: 0.7rem;
        padding: 0.7rem 0.85rem;
    }

    .offers tbody td {
        display: flex;
        justify-content: space-between;
        gap: 0.8rem;
        grid-column: 1 / -1;
        border: none;
        padding: 0.18rem 0;
    }

    /* Подпись поля берём из data-label, чтобы не дублировать разметку */
    .offers tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--scn-text-muted);
        font-size: 0.78rem;
    }

    .offers__price { text-align: left; }
    .offers__name { min-width: 0; }
    .buy-form { justify-content: flex-end; }
}

@media (max-width: 575px) {
    .search-form { flex-wrap: wrap; }
    .search-form__input { border-right: 1px solid var(--scn-line); border-radius: 3px; }
    .search-form__btn { width: 100%; margin-top: 0.5rem; border-radius: 3px; }
    .product-summary__price { font-size: 1.6rem; }
}
