/* ─────────────────────────────────────────────
    CATEGORY PAGE — Mobile First
───────────────────────────────────────────── */
*, *::before, *::after {
    font-family: vazir;
}

.cat-page {
    /* این صفحه هدر فیکس نداره */
    --cat-header-h: 0px;
    /* ارتفاع نوار پایین mobile-nav خودت (80px طبق کدت) — فقط تو موبایل هست */
    --cat-bottom-nav-h: 80px;
    --cat-bg: #eef0f4;
    --cat-card-bg: #ffffff;
    --cat-text: #1f2430;
    --cat-text-light: #8a91a3;
    --cat-accent: #4f6ef7;
    --cat-accent-2: #7b8ffc;
    --cat-accent-soft: #eaeeff;
    --cat-border: #e3e6ee;
    --cat-sidebar-w: 88px;

    /* این بخش دقیقاً بین هدر و نوار پایین سایتت فیکس میشه، صفحه دیگه
       اسکرول نمی‌خوره و فقط هرکدوم از دو ستون داخلش اسکرول جدا داره */
    position: fixed;
    top: var(--cat-header-h);
    bottom: var(--cat-bottom-nav-h);
    right: 0;
    left: 0;
    z-index: 10;
    display: flex;
    align-items: stretch;
    direction: rtl;
    overflow: hidden;
    background-color: var(--cat-bg);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(79, 110, 247, 0.09) 1px, transparent 0),
        radial-gradient(ellipse 700px 400px at 100% 0%, rgba(79, 110, 247, 0.07), transparent 60%),
        radial-gradient(ellipse 600px 400px at 0% 100%, rgba(123, 143, 252, 0.06), transparent 60%);
    background-size: 20px 20px, 100% 100%, 100% 100%;
}

/* ─────────────────────────────────────────────
    SIDEBAR (راست) — دسته‌بندی‌های اصلی — فیکس
───────────────────────────────────────────── */
.cat-page-sidebar {
    /* والد (.cat-page) الان فیکسه، پس این فقط کافیه ارتفاع کامل بگیره
       و اسکرول داخلی خودش رو داشته باشه — دیگه نیازی به sticky/fixed نیست */
    flex: 0 0 var(--cat-sidebar-w);
    width: var(--cat-sidebar-w);
    height: 100%;

    background: var(--cat-card-bg);
    border-left: 1px solid var(--cat-border);
    box-shadow: -4px 0 16px rgba(20, 25, 50, 0.04);

    padding: 12px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cat-page-sidebar::-webkit-scrollbar { display: none; }

.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    padding: 10px 4px;
    margin: 3px 6px;
    border-radius: 14px;
    cursor: pointer;
    color: var(--cat-text);
    transition: background .2s ease, color .2s ease, transform .15s ease;
    text-decoration: none;
}

.cat-item-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--cat-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 18px;
    padding: 5px;
    transition: background .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
}
.cat-item-icon .cat-visual-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cat-item-label {
    font-size: 11px;
    line-height: 1.3;
    font-weight: 500;
    word-break: break-word;
    transition: color .2s ease;
    text-decoration: none;
}

.cat-item:hover {
    background: var(--cat-accent-soft);
    transform: translateY(-1px);
}
.cat-item:hover .cat-item-icon {
    transform: scale(1.08);
}

.cat-item.active {
    background: var(--cat-accent-soft);
    color: var(--cat-accent);
}
.cat-item.active .cat-item-icon {
    background: linear-gradient(135deg, var(--cat-accent), var(--cat-accent-2));
    color: #fff;
    box-shadow: 0 6px 14px rgba(79, 110, 247, 0.35);
}
.cat-item.active .cat-item-label {
    font-weight: 700;
}
.cat-item.pulse .cat-item-icon {
    animation: catIconPulse .45s ease;
}
.cat-item:active {
    transform: scale(0.95);
}

@keyframes catIconPulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* ─────────────────────────────────────────────
    CONTENT (چپ) — زیردسته‌ها
───────────────────────────────────────────── */
.cat-page-content {
    flex: 1;
    min-width: 0;
    height: 100%;

    direction: rtl; /* صریحاً rtl تا مرورگر اسکرول‌بار رو سمت چپ بذاره */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    padding: 16px 12px 32px;
}

.cat-page-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.cat-page-content-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--cat-text);
    margin: 0;
    position: relative;
    padding-right: 12px;
}
.cat-page-content-title::before {
    content: "";
    position: absolute;
    right: 0;
    top: 2px;
    bottom: 2px;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--cat-accent), var(--cat-accent-2));
}

.cat-page-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.cat-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-decoration: none;
    color: var(--cat-text);
    background: var(--cat-card-bg);
    border: 1px solid var(--cat-border);
    border-radius: 18px;
    padding: 16px 8px 13px;
    text-align: center;
    position: relative;
    overflow: hidden;

    opacity: 0;
    animation: catFadeInUp .45s cubic-bezier(.22,.86,.4,1) forwards;

    transition: transform .25s cubic-bezier(.22,.86,.4,1), box-shadow .25s ease, border-color .25s ease;
}

.cat-grid-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(79,110,247,0.10), transparent 65%);
    opacity: 0;
    transition: opacity .25s ease;
}

.cat-grid-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(79, 110, 247, 0.14);
    border-color: var(--cat-accent);
}
.cat-grid-item:hover::after { opacity: 1; }
.cat-grid-item:hover .cat-grid-icon {
    transform: scale(1.1) rotate(-4deg);
}
.cat-grid-item:active {
    transform: translateY(-1px) scale(0.98);
}

@keyframes catFadeInUp {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cat-grid-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--cat-bg), #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 24px;
    padding: 7px;
    box-shadow: inset 0 0 0 1px rgba(79,110,247,0.08);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.cat-grid-icon .cat-visual-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cat-grid-label {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
}

.cat-grid-count {
    font-size: 10.5px;
    color: var(--cat-text-light);
}

/* حالت خالی: وقتی دسته انتخاب‌شده زیردسته ندارد */
.cat-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 10px;
    color: var(--cat-text-light);
    font-size: 13px;
    opacity: 0;
    animation: catFadeInUp .4s ease forwards;
}
.cat-empty-icon {
    font-size: 34px;
    margin-bottom: 10px;
}

/* ─────────────────────────────────────────────
    خیلی کوچک  (< 320px) → یک ستون
    این کوئری عمداً پایین‌تره تا رو همه رول‌ها اولویت داشته باشه
───────────────────────────────────────────── */
@media (max-width: 449px) {
    .cat-page-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 319px) {
    .cat-page-grid {
        grid-template-columns: repeat(1, 1fr);
    }
    .cat-grid-item {
        flex-direction: row;
        justify-content: flex-start;
        text-align: right;
        padding: 10px 14px;
    }
    .cat-grid-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        flex: none;
    }
    .cat-grid-label { font-size: 13px; }
}

/* ─────────────────────────────────────────────
    TABLET  (≥ 480px)
───────────────────────────────────────────── */
@media (min-width: 480px) {
    .cat-page-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

/* از این عرض به بعد mobile-nav (نوار پایین) دیگه نمایش داده نمیشه،
   پس فضایی هم براش کنار نمی‌ذاریم */
@media (min-width: 769px) {
    .cat-page {
        --cat-bottom-nav-h: 0px;
    }
}

/* ─────────────────────────────────────────────
    TABLET LARGE  (≥ 768px)
───────────────────────────────────────────── */
@media (min-width: 768px) {
    .cat-page {
        --cat-sidebar-w: 200px;
    }
    .cat-page-sidebar {
        padding: 20px 10px;
    }
    .cat-item {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 14px;
        margin: 4px 0;
    }
    .cat-item-label {
        font-size: 13px;
        text-align: right;
    }
    .cat-page-content {
        padding: 24px 24px 40px;
    }
    .cat-page-content-title {
        font-size: 17px;
    }
    .cat-page-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
    }
    .cat-grid-icon {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }
    .cat-grid-label {
        font-size: 13px;
    }
}

/* ─────────────────────────────────────────────
    DESKTOP  (≥ 1024px)
───────────────────────────────────────────── */
@media (min-width: 1024px) {
    .cat-page {
        --cat-sidebar-w: 240px;
        width: 100%;
        max-width: 1180px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    .cat-page-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ─────────────────────────────────────────────
    SIDEBAR WRAPPER (راست) — نگه‌دارنده‌ی دکمه بازگشت + لیست
───────────────────────────────────────────── */
.cat-page-sidebar-wrap {
    flex: 0 0 var(--cat-sidebar-w);
    width: var(--cat-sidebar-w);
    height: 100%;

    display: flex;
    flex-direction: column;

    background: var(--cat-card-bg);
    border-left: 1px solid var(--cat-border);
    box-shadow: -4px 0 16px rgba(20, 25, 50, 0.04);
}

/* دکمه‌ی بازگشت — ثابت، بالای سایدبار، اسکرول نمی‌خوره */
.cat-back-btn {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    width: 100%;
    border: none;
    border-bottom: 1px solid var(--cat-border);
    background: var(--cat-accent-soft);
    color: var(--cat-accent);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;

    padding: 10px 4px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-width: 0;
    transition: max-height .25s ease, opacity .2s ease, padding .25s ease;
}

.cat-back-btn.show {
    max-height: 60px;
    opacity: 1;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom-width: 1px;
}

.cat-back-btn:hover {
    background: #dfe5ff;
}
.cat-back-btn:active {
    transform: scale(0.97);
}
.cat-back-btn svg {
    /* فلش الان به چپ اشاره می‌کنه که برای RTL یعنی "برگشت به عقب" درسته */
    flex: none;
}

/* لیست دسته‌ها — همون استایل قبلی، فقط دیگه خودش فیکس نیست
   (والدش یعنی .cat-page-sidebar-wrap فیکسه) و ارتفاعش رو از باقیمانده می‌گیره */
.cat-page-sidebar {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;

    padding: 12px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cat-page-sidebar::-webkit-scrollbar { display: none; }