/* ============================================================
   Honaregharn — Category pages
   Layout aligned with the main "All Products" page.
   ============================================================ */

.cat-page {
    --cream: #fdf6ec;
    --blush: #fdeee1;
    width: 100%;
    min-width: 0;
}

.cat-page *,
.cat-page *::before,
.cat-page *::after {
    box-sizing: border-box;
}

/* ---------- Breadcrumb ---------- */

.cat-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 12.5px;
    color: var(--ink-600);
}

.cat-breadcrumb a {
    color: var(--ink-600);
    text-decoration: none;
    transition: color .15s ease;
}

.cat-breadcrumb a:hover {
    color: var(--brand-500);
}

.cat-breadcrumb .current {
    color: var(--ink-900);
    font-weight: 600;
}

/* ---------- Category hero ---------- */

.cat-hero {
    position: relative;
    min-width: 0;
    overflow: hidden;
    margin-bottom: 32px;
    padding: 32px 36px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--cream) 0%, var(--blush) 100%);
}

.cat-hero::after {
    content: "";
    position: absolute;
    inset-inline-end: -70px;
    top: -80px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .32);
    pointer-events: none;
}

.cat-hero-image {
    position: relative;
    z-index: 1;
    float: right;
    width: 72px;
    height: 72px;
    margin: 0 0 14px 24px;
    border: 3px solid #fff;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
}

.cat-hero-meta {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.cat-hero-count {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--brand-600);
    font-size: 12px;
    font-weight: 700;
}

.cat-hero h1 {
    position: relative;
    z-index: 1;
    margin: 0 0 8px;
    color: var(--ink-900);
    font-size: 28px;
    line-height: 1.4;
    font-weight: 800;
}

.cat-hero-desc {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0;
    color: var(--ink-600);
    font-size: 14px;
    line-height: 1.9;
}

/* ---------- Subcategory chips ---------- */

.cat-subgrid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 32px;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 18px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--ink-900);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition:
        border-color .15s ease,
        color .15s ease,
        transform .15s ease,
        box-shadow .15s ease;
}

.cat-chip:hover {
    border-color: var(--brand-500);
    color: var(--brand-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.cat-chip .count {
    color: var(--ink-400);
    font-size: 12px;
    font-weight: 500;
}

.cat-chip.active {
    border-color: var(--brand-500);
    background: var(--brand-500);
    color: #fff;
}

.cat-chip.active .count {
    color: rgba(255, 255, 255, .75);
}

/* ============================================================
   CATEGORY PRODUCT GRID
   IMPORTANT:
   Do not use auto-fit here.
   With one product, auto-fit makes the single card fill the page.
   This follows the same 4 / 3 / 2 / 1 column behavior as the
   main products page.
   ============================================================ */

.cat-page .products-grid {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
    align-items: stretch;
    margin-bottom: 24px;
}

/* Keep a single product compact instead of stretching it. */
.cat-page .products-grid > .product-card {
    width: 100%;
    max-width: none;
    min-width: 0;
}

/* Product card stability inside category pages. */
.cat-page .product-card {
    min-width: 0;
    width: 100%;
    height: 100%;
}

/* Prevent long Persian/English product names from pushing the card. */
.cat-page .product-title {
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ---------- Pagination ---------- */

.cat-page .pagination-wrapper {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 24px;
}

/* ---------- Empty state ---------- */

.cat-page .empty-state {
    width: 100%;
    padding: 42px 24px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--ink-600);
    text-align: center;
    font-size: 14px;
}

/* ============================================================
   Category index page
   ============================================================ */

.cat-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.cat-index-card {
    display: block;
    padding: 26px 22px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--ink-900);
    text-decoration: none;
    transition:
        transform .18s ease,
        box-shadow .18s ease,
        border-color .18s ease;
}

.cat-index-card:hover {
    border-color: var(--brand-500);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.cat-index-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: 18px;
    font-weight: 700;
}

.cat-index-card-icon-img {
    object-fit: cover;
    border: 1px solid var(--ink-100);
    background: #fff;
}

.cat-index-card h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.cat-index-card p {
    margin: 0 0 10px;
    color: var(--ink-600);
    font-size: 13px;
    line-height: 1.8;
}

.cat-index-card .count {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: 11.5px;
    font-weight: 700;
}

.cat-index-card .children-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--ink-100);
    color: var(--ink-600);
    font-size: 12px;
}

/* ============================================================
   Dark theme
   ============================================================ */

[data-theme="dark"] .cat-page {
    --cream: #24242c;
    --blush: #2a2530;
}

[data-theme="dark"] .cat-hero {
    border: 1px solid var(--ink-200);
}

[data-theme="dark"] .cat-hero h1 {
    color: #fff;
}

[data-theme="dark"] .cat-hero-count {
    background: var(--ink-100);
    color: var(--brand-400);
}

[data-theme="dark"] .cat-chip {
    border-color: var(--ink-200);
    background: var(--ink-100);
    color: #fff;
}

[data-theme="dark"] .cat-chip:hover {
    border-color: var(--brand-500);
}

[data-theme="dark"] .cat-chip.active {
    border-color: var(--brand-500);
    background: var(--brand-500);
}

[data-theme="dark"] .cat-page .empty-state {
    border-color: var(--ink-200);
    background: var(--ink-100);
    color: var(--ink-400);
}

[data-theme="dark"] .cat-index-card {
    border-color: var(--ink-200);
    background: var(--ink-100);
}

[data-theme="dark"] .cat-index-card-icon {
    background: var(--ink-50);
    color: var(--brand-400);
}

/* ============================================================
   Responsive — same product sizing logic as all-products page
   ============================================================ */

@media (max-width: 1200px) {
    .cat-page .products-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .cat-page .products-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 18px;
    }
}

@media (max-width: 640px) {
    .cat-page .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .cat-hero {
        padding: 26px 20px;
    }

    .cat-hero h1 {
        font-size: 22px;
    }

    .cat-hero-image {
        width: 62px;
        height: 62px;
        margin-inline-start: 16px;
    }

    .cat-page .product-card {
        padding: 10px;
    }

    .cat-page .product-info {
        padding: 12px 8px 4px;
    }

    .cat-page .product-title {
        font-size: 13px;
    }

    .cat-page .product-price {
        font-size: 13px;
    }

    .cat-page .product-card-actions {
        gap: 6px;
        padding: 10px 8px 12px;
    }

    .cat-page .btn-add-cart {
        padding: 9px 8px;
        font-size: 12px;
    }

    .cat-page .btn-wishlist {
        padding: 9px 10px;
    }
}

@media (max-width: 420px) {
    .cat-page .products-grid {
        grid-template-columns: 1fr;
    }

    .cat-page .product-card {
        padding: 10px;
    }

    .cat-page .product-image {
        aspect-ratio: 16 / 10;
    }

    .cat-hero-image {
        float: none;
        display: block;
        margin: 0 0 14px;
    }
}
