/* =============================================
   ===== CHUDOCHAT CATALOG — каталог =====
   =============================================
   Стили для:
   - главной каталога /catalog/
   - витрин /catalog/{category}/
   - статей /catalog/.../article/N/
   Работает в тёмной и светлой темах.
   ============================================= */

.ch-cat-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 60px;
    font-family: system-ui, -apple-system, sans-serif;
}

.ch-cat-back {
    display: inline-block;
    color: #5a7bff;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 20px;
}
.ch-cat-back:hover { text-decoration: underline; }
body.light .ch-cat-back { color: #046bd2; }

.ch-cat-title {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    color: #e0e0e0;
    margin: 0 0 8px 0;
}
body.light .ch-cat-title { color: #0f172a; }

.ch-cat-subtitle {
    font-size: 15px;
    line-height: 1.5;
    color: #a0a0a0;
    margin: 0 0 32px 0;
    max-width: 720px;
}
body.light .ch-cat-subtitle { color: #475569; }

/* =============================================
   ===== СЕТКА КАТЕГОРИЙ =====
   ============================================= */

.ch-cat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.ch-cat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, background 0.2s;
    min-height: 0;
}
.ch-cat-card:hover {
    border-color: #5a7bff;
    background: #24242e;
}
body.light .ch-cat-card {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .ch-cat-card:hover {
    background: #f8fafc;
    border-color: #046bd2;
}

.ch-cat-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    background: rgba(90, 123, 255, 0.12);
    overflow: hidden;
    flex-shrink: 0;
}
.ch-cat-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.light .ch-cat-icon {
    background: rgba(4, 107, 210, 0.08);
}

.ch-cat-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: #e0e0e0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.light .ch-cat-name { color: #0f172a; }

.ch-cat-count {
    font-size: 12px;
    color: #6a6a7a;
    white-space: nowrap;
    flex-shrink: 0;
}
body.light .ch-cat-count { color: #94a3b8; }

/* =============================================
   ===== ВИТРИНА (терминал с чатом) =====
   ============================================= */

.ch-cat-terminal {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}
body.light .ch-cat-terminal {
    background: #ffffff;
    border-color: #e2e8f0;
}

.ch-cat-terminal-logo {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    overflow: hidden;
    background: #2a2a32;
    flex-shrink: 0;
}
.ch-cat-terminal-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.light .ch-cat-terminal-logo { background: #f1f5f9; }

.ch-cat-terminal-body {
    flex: 1;
    min-width: 220px;
}

.ch-cat-terminal-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    color: #e0e0e0;
    margin: 0 0 12px 0;
}
body.light .ch-cat-terminal-title { color: #0f172a; }

.ch-cat-terminal-desc {
    font-size: 15px;
    line-height: 1.6;
    color: #a0a0a0;
    margin: 0 0 20px 0;
}
body.light .ch-cat-terminal-desc { color: #475569; }

.ch-cat-btn {
    display: inline-block;
    background: #5a7bff;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}
.ch-cat-btn:hover { background: #4a6adf; color: #fff; }
body.light .ch-cat-btn { background: #046bd2; }
body.light .ch-cat-btn:hover { background: #035aa8; }

/* =============================================
   ===== ТОВАРЫ НА ВИТРИНЕ =====
   ============================================= */

.ch-cat-products {
    margin-top: 40px;
    margin-bottom: 40px;
}

.ch-cat-products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ch-cat-products-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #e0e0e0;
    margin: 0;
}
body.light .ch-cat-products-header h2 { color: #0f172a; }

.ch-cat-products-search {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 380px;
}
.ch-cat-products-search input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    border-radius: 10px;
    border: 1px solid #2a2a32;
    background: #1c1c24;
    color: #e0e0e0;
    font-size: 14px;
    box-sizing: border-box;
}
.ch-cat-products-search input:focus {
    outline: none;
    border-color: #5a7bff;
}
body.light .ch-cat-products-search input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}
.ch-cat-products-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6a6a7a;
    text-decoration: none;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
}
.ch-cat-products-clear:hover {
    color: #e0e0e0;
    background: #2a2a32;
}

.ch-cat-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.ch-cat-product-card {
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}
.ch-cat-product-card:hover {
    border-color: #5a7bff;
    transform: translateY(-2px);
}
body.light .ch-cat-product-card {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .ch-cat-product-card:hover { border-color: #046bd2; }

.ch-cat-product-img {
    aspect-ratio: 1 / 1;
    background: #0f0f12;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ch-cat-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ch-cat-product-img .no-img {
    color: #3a3a4a;
    font-size: 32px;
}
body.light .ch-cat-product-img { background: #f8fafc; }

.ch-cat-product-body {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ch-cat-product-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: #e0e0e0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
body.light .ch-cat-product-name { color: #0f172a; }

.ch-cat-product-price {
    font-size: 15px;
    font-weight: 700;
    color: #4ade80;
    margin-top: auto;
}

.ch-cat-products-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 30px 0 0;
    flex-wrap: wrap;
}
.ch-cat-products-pagination a,
.ch-cat-products-pagination .current {
    padding: 8px 14px;
    border-radius: 8px;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 14px;
}
.ch-cat-products-pagination .current {
    background: #5a7bff;
    border-color: #5a7bff;
    color: #fff;
}
.ch-cat-products-pagination a:hover { border-color: #5a7bff; }
body.light .ch-cat-products-pagination a {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}
body.light .ch-cat-products-pagination .current {
    background: #046bd2;
    border-color: #046bd2;
    color: #fff;
}

/* =============================================
   ===== СТАТЬИ (анонсы) =====
   ============================================= */

.ch-cat-articles {
    margin-top: 40px;
}
.ch-cat-articles h2 {
    font-size: 22px;
    font-weight: 700;
    color: #e0e0e0;
    margin: 0 0 20px 0;
}
body.light .ch-cat-articles h2 { color: #0f172a; }

.ch-cat-articles-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ch-cat-article-card {
    display: block;
    background: #1c1c24;
    border: 1px solid #2a2a32;
    border-radius: 12px;
    padding: 20px 24px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, background 0.2s;
}
.ch-cat-article-card:hover {
    border-color: #5a7bff;
    background: #24242e;
}
body.light .ch-cat-article-card {
    background: #ffffff;
    border-color: #e2e8f0;
}
body.light .ch-cat-article-card:hover {
    background: #f8fafc;
    border-color: #046bd2;
}

.ch-cat-article-title {
    font-size: 17px;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 8px;
    line-height: 1.4;
}
body.light .ch-cat-article-title { color: #0f172a; }

.ch-cat-article-preview {
    font-size: 14px;
    color: #a0a0a0;
    line-height: 1.6;
    margin-bottom: 10px;
}
body.light .ch-cat-article-preview { color: #475569; }

.ch-cat-article-more {
    font-size: 13px;
    color: #5a7bff;
    font-weight: 600;
}
body.light .ch-cat-article-more { color: #046bd2; }

/* =============================================
   ===== ПУСТО =====
   ============================================= */
.ch-cat-empty {
    text-align: center;
    padding: 60px 20px;
    background: #1c1c24;
    border: 1px dashed #2a2a32;
    border-radius: 16px;
    color: #6a6a7a;
    font-size: 15px;
}
body.light .ch-cat-empty {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #94a3b8;
}

/* =============================================
   ===== АДАПТАЦИЯ =====
   ============================================= */

/* Ноутбуки */
@media (max-width: 1199px) {
    .ch-cat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .ch-cat-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Планшеты вертикально */
@media (max-width: 900px) {
    .ch-cat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .ch-cat-terminal {
        padding: 20px;
    }
    .ch-cat-terminal-title {
        font-size: 22px;
    }
    .ch-cat-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Мобильные */
@media (max-width: 640px) {
    .ch-cat-page {
        padding: 20px 14px 40px;
    }
    .ch-cat-title {
        font-size: 24px;
    }
    .ch-cat-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
    .ch-cat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .ch-cat-card {
        padding: 18px 12px;
        min-height: 130px;
        border-radius: 12px;
    }
    .ch-cat-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    .ch-cat-name {
        font-size: 14px;
    }
    .ch-cat-count {
        font-size: 12px;
    }
    .ch-cat-terminal {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 18px;
    }
    .ch-cat-terminal-logo {
        width: 90px;
        height: 90px;
    }
    .ch-cat-terminal-title {
        font-size: 20px;
    }
    .ch-cat-article-card {
        padding: 16px 18px;
    }
    .ch-cat-article-title {
        font-size: 15px;
    }
    .ch-cat-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ch-cat-products-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .ch-cat-products-search {
        max-width: 100%;
    }
}

/* Очень узкие */
@media (max-width: 420px) {
    .ch-cat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .ch-cat-card {
        padding: 14px 10px;
        min-height: 120px;
    }
    .ch-cat-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    .ch-cat-name {
        font-size: 13px;
    }
    .ch-cat-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .ch-cat-grid {
        grid-template-columns: 1fr;
    }
}