/* /public/css/category.css */

/* =========================
   1. VARIABLES & CONFIG
   ========================= */
.cat-sidebar {
    /* Colors */
    --tree-bg-hover: #f3f4f6;
    --tree-bg-active: #111827;
    --tree-text-main: #111827;
    --tree-text-muted: #6b7280;
    --tree-text-active: #ffffff;
    --tree-line-color: #cbd5e1;

    
    /* Dimensions */
    --tree-indent: 18px; 
    --tree-line-w: 2px;  
    --item-height: 40px; 
    
    /* Layout */
    position: sticky;
    top: 12px;
    align-self: start;
    width: 100%;
    font-family: inherit;
}

/* =========================
   2. TYPOGRAPHY & HEADER
   ========================= */
.cat-sidebar .cat-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--tree-text-main);
    margin-bottom: 12px;
    padding-inline-start: 4px;
}

.cat-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* =========================
   3. TREE ITEMS (Shared Styles)
   ========================= */
.cat-sidebar .cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: var(--item-height);
    color: var(--tree-text-main);
    user-select: none;
    position: relative;
    z-index: 5;
}

/* --- Hover & Active States (Fixed) --- */

/* هاور فقط برای آیتم‌هایی که فعال نیستند */
.cat-sidebar .cat-row:not(.cat-active):hover {
    background-color: var(--tree-bg-hover);
    color: var(--tree-text-main);
}

/* استایل آیتم فعال (انتخاب شده) */
.cat-sidebar .cat-row.cat-active {
    background-color: var(--tree-bg-active);
    color: var(--tree-text-active) !important;
    font-weight: 600;
}

/* هاور روی آیتم فعال */
.cat-sidebar .cat-row.cat-active:hover {
    background-color: #0b1220; 
    color: #fff !important;
}

/* حذف نشانگر پیش‌فرض details */
.cat-sidebar summary.cat-row::-webkit-details-marker { display: none; }
.cat-sidebar summary.cat-row { list-style: none; }

/* =========================
   4. DEPTH & HIERARCHY
   ========================= */

/* سطح ۰ (ریشه) */
.depth-0 > li > details > summary,
.depth-0 > li > a.cat-leaf {
    font-size: 15px;
    font-weight: 700;
}

/* سطح ۱ (زیرمجموعه اول) */
.depth-1 > li > details > summary,
.depth-1 > li > a.cat-leaf {
    font-size: 14px;
    font-weight: 500;
}

/* سطح ۲ به بعد */
.cat-list:not(.depth-0):not(.depth-1) .cat-row {
    font-size: 13px;
    font-weight: 400;
    color: var(--tree-text-muted);
}

/* لینک "همه آگهی‌های..." */
.cat-sidebar a.cat-link-all {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--tree-text-muted);
    padding: 6px 10px;
    margin: 2px 0 4px calc(var(--tree-indent) + 4px);
    border-radius: 6px;
    text-decoration: none;
}
.cat-sidebar a.cat-link-all:hover:not(.cat-active) {
    background-color: rgba(0,0,0,0.02);
    color: var(--tree-text-main);
}

/* =========================
   5. ARROW ICONS
   ========================= */
.cat-sidebar summary.cat-row::after {
    content: "";
    width: 6px;
    height: 6px;
    border: 2px solid currentColor;
    border-top: 0;
    border-inline-start: 0;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    opacity: 0.6;
    margin-inline-start: 8px;
}

.cat-sidebar details[open] > summary.cat-row::after {
    transform: rotate(225deg);
}

/* =========================
   6. TREE LINES & BACKGROUNDS (Recursive)
   ========================= */

/* کانتینر زیرمجموعه‌ها با پس‌زمینه لایه‌ای */
.cat-sidebar .cat-list:not(.depth-0) {
    background-color: rgba(0, 0, 0, 0.035); /* خاکستری ملایم لایه‌ای */
    border-radius: 8px;
    margin-top: 4px;
    margin-bottom: 6px;
    padding-top: 4px;
    padding-bottom: 4px;
    margin-inline-start: 10px;
    padding-inline-start: var(--tree-indent);
    border-inline-start: var(--tree-line-w) solid var(--tree-line-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* خطوط راهنما */
.cat-sidebar .cat-list:not(.depth-0) > li {
    position: relative;
}

/* خط افقی اتصال */
.cat-sidebar .cat-list:not(.depth-0) > li::before {
    content: "";
    position: absolute;
    top: calc(var(--item-height) / 2);
    inset-inline-start: calc(-1 * var(--tree-indent));
    width: var(--tree-indent);
    height: var(--tree-line-w);
    background: var(--tree-line-color);
    z-index: 1;
}

/* دایره روی خط عمودی */
.cat-sidebar .cat-list:not(.depth-0) > li::after {
    content: "";
    position: absolute;
    top: calc(var(--item-height) / 2 - 3px);
    inset-inline-start: -4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--tree-line-color);
    z-index: 2;
}

/* تغییر رنگ دایره برای آیتم فعال */
.cat-sidebar .cat-list:not(.depth-0) > li:has(> .cat-active)::after,
.cat-sidebar .cat-list:not(.depth-0) > li:has(> details[open] > summary.cat-active)::after {
    background: var(--tree-bg-active);
    border-color: var(--tree-bg-active);
}

/* =========================
   7. RESPONSIVE
   ========================= */
@media (max-width: 980px) {
    .cat-sidebar {
        position: static;
        margin-bottom: 30px;
    }
}


