/* ============================================================
 *  catalog.css – стили каталога (таблица / карточки / панель)
 *  ============================================================ */

/* ---------- Переменные ---------- */
:root {
    --primary: #007cba;
    --danger: #dc3545;
    --success: #28a745;
}

/* ---------- Таблица ---------- */
.catalog-table-container {
    overflow: visible !important;
    width: 100%;
}
.catalog-table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
}
.catalog-table td,
.catalog-table th {
    word-wrap: break-word;
}

/* ---------- Единый sticky-заголовок ---------- */
.catalog-table thead th {
    position: sticky;
    z-index: 1100;
    border: none;
    background-clip: padding-box;
}

/* Ордер-бар (первая строка) */
.order-row th {
    top: 0;
    background: #f0f0f0 !important;
    z-index: 1101;
    padding: 0;
    box-shadow: 0 1px 0 #ddd;
}

/* Заголовки колонок (вторая строка) */
.catalog-table thead tr:not(.order-row) th {
    top: 61px;
    background: #f0f0f0;
    box-shadow: 0 1px 0 #ddd;
}

/* Внутренности ордер-бара */
.order-summary-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    padding: 15px 20px;
}
.summary-item {
    font-size: 14px;
    font-weight: bold;
    background: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #ddd;
}
.summary-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

/* ---------- Кнопки заказа ---------- */
.checkout-button,
.reset-btn-custom {
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    opacity: 0.5;
    cursor: pointer;
}
.checkout-button { background: var(--success); }
.reset-btn-custom { background: var(--danger); }
.checkout-button:enabled,
.reset-btn-custom:enabled { opacity: 1; }

/* ---------- Тело таблицы ---------- */
.catalog-table td {
    height: 50px;
    border: 1px solid #ddd;
    padding: 5px;
    text-align: center;
    vertical-align: middle;
    background: #fff;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.catalog-table td.col-name {
    text-align: left;
    padding-left: 10px;
}

/* ---------- ШИРИНА КОЛОНОК В ПРОЦЕНТАХ (адаптивность) ---------- */
.catalog-table th.col-name,
.catalog-table td.col-name {
    width: 30%;
}
.catalog-table th.col-weight,
.catalog-table td.col-weight {
    width: 8%;
}
.catalog-table th.col-box,
.catalog-table td.col-box {
    width: 8%;
}
.catalog-table th.col-shelf,
.catalog-table td.col-shelf {
    width: 8%;
}
.catalog-table th.col-price,
.catalog-table td.col-price {
    width: 10%;
}
.catalog-table th.col-pallet,
.catalog-table td.col-pallet {
    width: 8%;
}
.catalog-table th.col-qty,
.catalog-table td.quantity-cell {
    width: 8%;
}

/* ---------- Количество (блок ввода) ---------- */
.quantity-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.qty-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.qty-minus,
.qty-plus {
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    background: #c4c2c2;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 1;
}
.qty-input {
    width: 60px;
    height: 38px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 14px;
    -moz-appearance: textfield;
    padding: 0 !important;
    box-sizing: border-box;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.quantity-cell {
    padding: 5px 2px !important;
}
.box-total {
    font-size: 13px;
    color: var(--primary);
    font-weight: bold;
    margin-top: 0;
    display: block;
    margin-top: 6px;
}

/* ---------- Адаптивность таблицы ---------- */
@media (max-width: 1300px) and (min-width: 1025px) {
    .catalog-table {
        font-size: 0.9em;
    }
}
@media (max-width: 1024px) and (min-width: 769px) {
    .catalog-table {
        font-size: 0.85em;
    }
}

/* ============================================================
 *  МОБИЛЬНЫЕ СТИЛИ (экраны до 768px)
 *  ============================================================ */
.mobile-product-cards { display: none; }
.mobile-order-bar { display: none; }

@media (max-width: 768px) {
    /* Скрыть таблицу */
    .catalog-table-container {
        display: none !important;
    }

    /* Контейнер карточек */
    .mobile-product-cards {
        display: block !important;
        padding: 0 1px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Сама карточка */
    .product-card {
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 12px 16px;
        margin: 0 0 12px 0;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .card-title {
        font-weight: bold;
        font-size: 16px;
        margin-bottom: 8px;
        line-height: 1.3;
		word-wrap: break-word;       /* Перенос слишком длинных слов */
        overflow-wrap: break-word;   /* Современный стандарт переноса */
        word-break: break-word;      /* Защита для старых браузеров */
    }

    .card-params-inline {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 16px;
        font-size: 13px;
        margin-bottom: 10px;
        color: #555;
    }
    .card-params-inline span {
        white-space: nowrap;
    }

    .card-quantity {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
    }

    .card-quantity .qty-input {
        width: 70px;
        height: 38px;
        text-align: center;
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 4px;
        padding: 0;
        box-sizing: border-box;
    }

    .qty-buttons {
        display: flex;
        flex-direction: row-reverse;
        gap: 7px;
    }

    .qty-buttons .qty-minus,
    .qty-buttons .qty-plus {
        width: 38px;
        height: 38px;
        min-width: 38px;
        max-width: 38px;
        background: #c4c2c2;
        color: #fff;
        border: none;
        border-radius: 3px;
        font-weight: bold;
        font-size: 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        margin: 0;
        line-height: 1;
    }
    .qty-buttons .qty-plus:hover,
    .qty-buttons .qty-minus:hover {
        background: #d0d0d0;
    }
    .qty-buttons .qty-plus:active,
    .qty-buttons .qty-minus:active {
        background: #bbb;
    }

    .quantity-wrapper .qty-btns {
        display: none !important;
    }

    .card-photo {
        display: none !important;
    }

    /* ---------- Мобильный ордербар (трёхстрочный) ---------- */
    .mobile-order-bar {
        display: flex !important;
        flex-direction: column !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1200;
        background: #e9ecef;
        padding: 6px 10px;
        gap: 4px;
        box-sizing: border-box;
    }

    /* Верхняя строка: статистика + фильтр */
    .mobile-order-bar .order-stats-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        flex-wrap: nowrap;
    }

    /* Статистика (слева) – более компактная */
    .mobile-order-bar .order-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 8px;
        font-size: 12px;
        font-weight: bold;
        color: #333;
        flex: 1 1 auto;
        min-width: 0;
    }
    .mobile-order-bar .order-stats .stat-item {
        display: flex;
        align-items: center;
        gap: 2px;
        background: #fff;
        padding: 1px 6px;
        border-radius: 10px;
        border: 1px solid #ddd;
        white-space: nowrap;
        font-size: 12px;
    }
    .mobile-order-bar .order-stats .stat-item .icon {
        font-size: 13px;
    }
    .mobile-order-bar .order-stats .stat-item .value {
        font-weight: bold;
    }

    /* ---------- Фильтр (справа) ---------- */
    .mobile-order-bar .order-filter {
        flex: 0 0 auto;
        position: relative;
        margin-left: auto;
    }

    /* Кнопка-триггер: белая, чёрный текст, треугольник вверх */
    .filter-toggle-btn {
        background: #fff !important;
        border: 1px solid #ddd;
        border-radius: 20px;
        padding: 4px 14px;
        font-size: 13px;
        font-weight: bold;
        color: #333 !important;
        cursor: pointer;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 6px;
        height: 32px;
        transition: background 0.2s;
        box-shadow: none;
    }
    .filter-toggle-btn:hover {
        background: #f5f5f5 !important;
    }
    .filter-toggle-btn .filter-arrow {
        font-size: 12px;
        display: inline-block;
        transition: transform 0.2s;
        color: #333;
    }
    .filter-toggle-btn.active .filter-arrow {
        transform: rotate(180deg);
    }

    /* Выпадающий список: появляется снизу вверх, по умолчанию скрыт */
    .filter-dropdown {
        display: none;
        position: absolute;
        right: 0;
        bottom: calc(100% + 4px);
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 10px;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
        padding: 8px 12px;
        min-width: 180px;
        max-width: 220px;
        max-height: 200px;
        overflow-y: auto;
        z-index: 1300;
    }
    .filter-dropdown .filter-options {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .filter-dropdown .filter-option {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        cursor: pointer;
        padding: 3px 6px;
        border-radius: 4px;
        color: #333;
    }
    .filter-dropdown .filter-option:hover {
        background: #f0f0f0;
    }
    .filter-dropdown .filter-option input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
        margin: 0;
        flex-shrink: 0;
        accent-color: #007cba;
    }
    .filter-dropdown .filter-all {
        border-bottom: 1px solid #eee;
        padding-bottom: 4px;
        margin-bottom: 4px;
        font-weight: bold;
    }

    /* Открытое состояние фильтра */
    .filter-dropdown.open {
        display: block !important;
    }

    /* Нижняя строка: кнопки */
    .mobile-order-bar .order-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .mobile-order-bar .order-actions .reset-btn-custom {
        flex: 0 0 30% !important;
        background: var(--danger);
        color: #fff;
        border: none;
        padding: 8px 0;
        border-radius: 4px;
        font-weight: bold;
        opacity: 0.5;
        cursor: pointer;
        font-size: 13px;
        text-align: center;
        height: 36px;
    }
    .mobile-order-bar .order-actions .checkout-button {
        flex: 0 0 70% !important;
        background: var(--success);
        color: #fff;
        border: none;
        padding: 8px 0;
        border-radius: 4px;
        font-weight: bold;
        opacity: 0.5;
        cursor: pointer;
        font-size: 13px;
        text-align: center;
        height: 36px;
    }
    .mobile-order-bar .order-actions .reset-btn-custom:enabled,
    .mobile-order-bar .order-actions .checkout-button:enabled {
        opacity: 1;
    }
}

/* ============================================================
 *  ГЛОБАЛЬНОЕ ПРАВИЛО ДЛЯ СКРЫТИЯ КАРТОЧЕК ПРИ ФИЛЬТРАЦИИ
 *  ============================================================ */
.product-row.hidden {
    display: none !important;
}


/* ---------- Усиленное правило для открытого фильтра (переопределяет любые inline-стили) ---------- */
#filter-dropdown.open {
display: block !important;
}
