/* ============================================================
   CATALOG.CSS — стили страницы каталога
   ============================================================ */

/* ============================================================
   ОСНОВНАЯ СЕТКА
   ============================================================ */
.catalog-page-wrap {
    padding: 30px 0;
    background: #f8fafc;
}
.catalog-page-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}
.breadcrumb {
    font-size: 14px;
    color: #888;
    margin-bottom: 20px;
}
.breadcrumb a {
    color: #0077ff;
    text-decoration: none;
}
.breadcrumb .sep {
    margin: 0 8px;
    color: #ccc;
}

.catalog-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
}

/* ============================================================
   САЙДБАР ФИЛЬТРОВ
   ============================================================ */
.filter-panel {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    flex: 0 0 280px;
    box-sizing: border-box;
}
.filter-panel-inner {
    background: #fff;
    border-radius: 12px;
    padding: 20px 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    box-sizing: border-box;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}
.filter-panel-inner::-webkit-scrollbar { width: 6px; }
.filter-panel-inner::-webkit-scrollbar-track { background: #f0f4fa; border-radius: 3px; }
.filter-panel-inner::-webkit-scrollbar-thumb { background: #c0d4f0; border-radius: 3px; }
.filter-panel-inner::-webkit-scrollbar-thumb:hover { background: #a0b8e0; }

.filter-title {
    font-size: 16px;
    color: #003366;
    margin: 0 0 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-count {
    background: #e8f0fe;
    color: #0077ff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

/* Блоки фильтров (Бренд, Цена, Сортировка) */
.filter-block {
    margin-bottom: 14px;
    border-bottom: 1px solid #eef4fa;
    padding-bottom: 12px;
}
.filter-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
    font-size: 14px;
    font-weight: 600;
    color: #1e2a3a;
}
.filter-block-header:hover { color: #0077ff; }
.filter-block-header i {
    color: #8897b4;
    font-size: 12px;
    transition: transform 0.2s;
}
.filter-block.collapsed .filter-block-header i { transform: rotate(-90deg); }
.filter-block-body { padding: 6px 0 4px; }
.filter-block.collapsed .filter-block-body { display: none; }

/* ============================================================
   КЛЮЧИ ФИЛЬТРОВ
   ============================================================ */
.filter-keys-section { margin-top: 4px; }

.filter-key {
    margin-bottom: 2px;
    border-bottom: 1px solid #f5f9fd;
}
.filter-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 9px 0;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
    color: #1e2a3a;
}
.filter-key-header:hover { color: #0077ff; }
.filter-key-icon {
    color: #8897b4;
    font-size: 11px;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.filter-key.collapsed .filter-key-icon { transform: rotate(-90deg); }
.filter-key-body { padding: 6px 0 8px; }
.filter-key.collapsed .filter-key-body { display: none; }

.filter-key-name {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-key-name small {
    color: #8897b4;
    font-weight: 400;
}
.filter-key-badge {
    color: #0077ff;
    font-size: 14px;
    line-height: 1;
    margin-left: 4px;
}

/* Чекбоксы */
.filter-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 13px;
    color: #4a6f8a;
    border-radius: 6px;
    transition: background 0.2s;
    margin-left: -8px;
}
.filter-checkbox:hover {
    background: #f0f7ff;
    color: #003366;
}
.filter-checkbox.is-checked {
    background: #e8f0fe;
    color: #003366;
    font-weight: 600;
}
.filter-checkbox.is-checked .cb-count {
    color: #0077ff;
    font-weight: 700;
}
.filter-checkbox input[type="checkbox"] {
    margin-top: 2px;
    accent-color: #0077ff;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}
.filter-checkbox span {
    flex: 1;
    line-height: 1.4;
    word-break: break-word;
}
.cb-count {
    color: #8897b4;
    font-size: 11px;
    margin-left: 4px;
}

.filter-value-hidden { display: none !important; }

.filter-show-all-values,
.filter-show-all-keys {
    display: inline-block;
    color: #0077ff;
    font-size: 12px;
    text-decoration: none;
    padding: 4px 0;
    cursor: pointer;
    font-weight: 600;
}
.filter-show-all-values:hover,
.filter-show-all-keys:hover { text-decoration: underline; }

.filter-show-all-keys {
    display: block;
    padding: 10px 0;
    text-align: center;
    background: #f8fcff;
    border-radius: 8px;
    margin: 8px 0;
    width: 100%;
    border: none;
}

.filter-empty {
    color: #8897b4;
    font-size: 12px;
    padding: 6px 0;
    font-style: italic;
}

/* Range-фильтры */
.filter-range {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
}
.filter-range input {
    width: 50%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}
.filter-range input:focus {
    outline: none;
    border-color: #0077ff;
}
.filter-range span { color: #999; }
.filter-range-hint {
    font-size: 11px;
    color: #8897b4;
}

/* Селекты */
.filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    box-sizing: border-box;
    cursor: pointer;
}
.filter-select:focus {
    outline: none;
    border-color: #0077ff;
}

/* Цена */
.price-range {
    display: flex;
    gap: 10px;
    align-items: center;
}
.price-range input {
    width: 50%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}
.price-hint {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Sticky-кнопки внизу */
.filter-actions-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 12px 0;
    border-top: 1px solid #eef4fa;
    margin: 12px -20px 0;
    padding-left: 20px;
    padding-right: 20px;
    box-shadow: 0 -4px 12px rgba(0,51,102,0.06);
    z-index: 10;
}
.filter-btn {
    width: 100%;
    padding: 11px;
    background: #0077ff;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}
.filter-btn:hover { background: #005bb5; }
.filter-btn:disabled { background: #a0b8e0; cursor: wait; }
.apply-count {
    background: rgba(255,255,255,0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}
.filter-reset {
    display: block;
    text-align: center;
    margin-top: 8px;
    color: #e94f4f;
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
}
.filter-reset:hover { text-decoration: underline; }

/* ============================================================
   ЗОНА ТОВАРОВ
   ============================================================ */
.products-area {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    position: relative;
}

/* Спиннер загрузки */
.products-loading {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(248,250,252,0.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}
.products-area.loading .products-loading { display: flex; }
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0ecff;
    border-top-color: #0077ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    margin-top: 14px;
    color: #003366;
    font-weight: 600;
    font-size: 14px;
}

/* Заголовок */
.products-header { margin-bottom: 15px; }
.products-header h1 {
    font-size: 28px;
    color: #003366;
    margin: 0 0 5px;
}
.products-header p {
    color: #666;
    margin: 0;
}
.products-header .count {
    color: #999;
    font-size: 14px;
}

/* ============================================================
   СЕТКА ТОВАРОВ
   ============================================================ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.product-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
    border: 1px solid #f0f4f8;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
}
.product-card:hover {
    box-shadow: 0 8px 30px rgba(0,51,102,0.15);
    transform: translateY(-4px);
    border-color: #0077ff;
}

/* Бейджи */
.product-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
}
.badge-new  { background: #27ae60; }
.badge-hit  { background: #f39c12; }
.badge-sale { background: #e94f4f; }

/* Кнопки избранного/сравнения */
.product-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: white;
    color: #999;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-btn:hover { transform: scale(1.1); }
.action-btn.active-fav {
    background: #0077ff;
    border-color: #0077ff;
    color: white;
}
.action-btn.active-compare {
    background: #ff6b00;
    border-color: #ff6b00;
    color: white;
}

/* Карточка */
.product-link {
    text-decoration: none;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.product-image {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    flex-shrink: 0;
}
.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.product-brand {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.product-name {
    font-weight: 600;
    color: #1e2a3a;
    margin-bottom: 6px;
    font-size: 15px;
    line-height: 1.4;
    height: 42px;
    overflow: hidden;
}
.product-model {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}
.product-price {
    font-size: 22px;
    font-weight: 700;
    color: #003366;
    margin-top: auto;
}
.product-price .old-price {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
    margin-left: 8px;
}

/* Кнопка В корзину */
.cart-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
}
.cart-btn.in-stock { background: #0077ff; }
.cart-btn.in-stock:hover { background: #005bb5; }
.cart-btn.out-of-stock { background: #f39c12; cursor: not-allowed; }
.cart-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   ПАГИНАЦИЯ
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
}
.page-link {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #1e2a3a;
    transition: all 0.3s;
}
.page-link:hover { background: #f0f4f8; }
.page-link.active {
    background: #0077ff;
    color: white;
    border-color: #0077ff;
}
.page-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================
   ПУСТОЕ СОСТОЯНИЕ
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 0;
    color: #999;
}
.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 20px;
}
.empty-state h3 {
    color: #666;
    font-size: 20px;
    margin-bottom: 8px;
}

/* ============================================================
   КАТЕГОРИИ (главная каталога)
   ============================================================ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.category-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
    border: 2px solid transparent;
    text-decoration: none;
    display: block;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,51,102,0.15);
    border-color: #0077ff;
}
.category-image {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.category-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.category-name {
    font-weight: 600;
    color: #1e2a3a;
    font-size: 16px;
}
.category-link {
    color: #999;
    font-size: 13px;
    margin-top: 8px;
}

/* Подкатегории */
.subcategory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.subcategory-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
    border: 2px solid transparent;
    text-decoration: none;
    display: block;
}
.subcategory-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,51,102,0.15);
    border-color: #0077ff;
}
.subcategory-image {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.subcategory-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.subcategory-name {
    font-weight: 600;
    color: #1e2a3a;
    font-size: 16px;
}
.subcategory-link {
    color: #999;
    font-size: 13px;
    margin-top: 8px;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 1200px) {
    .product-grid,
    .category-grid,
    .subcategory-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 992px) {
    .catalog-layout { flex-direction: column; }
    .filter-panel {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex: 0 0 auto;
    }
    .filter-panel-inner {
        position: static;
        max-height: none;
        overflow: visible;
    }
    .product-grid,
    .category-grid,
    .subcategory-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .page-title { font-size: 22px; }
}
@media (max-width: 600px) {
    .product-grid,
    .category-grid,
    .subcategory-grid { grid-template-columns: 1fr; }
    .product-image { height: 180px; }
    .products-header h1 { font-size: 22px; }
    .breadcrumb { font-size: 12px; }
}
@media (max-width: 480px) {
    .category-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .subcategory-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .category-card, .subcategory-card { padding: 14px 10px; }
    .category-image, .subcategory-image { height: 90px; }
    .category-name, .subcategory-name { font-size: 13px; }
}