/* ===== درخت گروه‌بندی سایدبار صفحه‌ی لیست (category-tree.js) =====
   فقط در CategoryPage لود می‌شود. با Logical Properties نوشته شده تا هم RTL و هم LTR (dir روی <html>) درست کار کند. */

.kw-ct[hidden] {
    display: none;
}

/* site.css روی هر .filtercard یک فلش «بازشو» می‌گذارد؛ این باکس جمع‌شدنی نیست و فلش گمراه‌کننده است */
.kw-ct .filtercard::after {
    display: none;
}

.kw-ct-body {
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 8px 10px;
}

/* داخل کشوی موبایل، خودِ کشو اسکرول دارد */
.kw-ct-sheet {
    max-height: none;
    overflow: visible;
    padding: 4px 12px 16px;
}

.kw-ct-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

    /* خط‌چین اتصال فرزندان به والد (مثل درخت سایت قدیمی) */
    .kw-ct-list .kw-ct-list {
        margin-inline-start: 10px;
        padding-inline-start: 8px;
        border-inline-start: 1px dashed #cfcfcf;
    }

.kw-ct-item:not(.is-open) > .kw-ct-list {
    display: none;
}

.kw-ct-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
}

.kw-ct-toggle,
.kw-ct-toggle-space {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
}

.kw-ct-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #777;
    cursor: pointer;
}

    /* فلش: دو لبه‌ی یک مربع که ۴۵ درجه می‌چرخد. بسته = رو به سمت خواندن (در RTL چپ)، باز = رو به پایین */
    .kw-ct-toggle::before {
        content: "";
        width: 6px;
        height: 6px;
        border-inline-end: 2px solid currentColor;
        border-block-end: 2px solid currentColor;
        transform: rotate(-45deg);
        transition: transform .15s;
    }

[dir="rtl"] .kw-ct-toggle::before {
    transform: rotate(45deg);
}

.kw-ct-item.is-open > .kw-ct-row > .kw-ct-toggle::before {
    transform: rotate(45deg);
}

[dir="rtl"] .kw-ct-item.is-open > .kw-ct-row > .kw-ct-toggle::before {
    transform: rotate(-45deg);
}

.kw-ct-toggle:hover {
    color: var(--bs-primary, #198754);
}

.kw-ct-link {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--color800, #333);
    text-decoration: none;
    overflow-wrap: anywhere;
}

a.kw-ct-link:hover {
    color: var(--bs-primary, #198754);
}

.kw-ct-item.is-current > .kw-ct-row > .kw-ct-link {
    color: var(--bs-primary, #198754);
    font-weight: 600;
}

.kw-ct-count {
    flex: 0 0 auto;
    font-size: 12px;
    color: #888;
}

/* اهداف لمسی بزرگ‌تر در کشوی موبایل */
.kw-ct-sheet .kw-ct-row {
    min-height: 40px;
}

.kw-ct-sheet .kw-ct-link {
    font-size: 14px;
}

.kw-ct-sheet .kw-ct-toggle,
.kw-ct-sheet .kw-ct-toggle-space {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
}
