/* --- شروع استایل‌های سایدبار --- */
.header-sidebar {
    height: 100vh;
    width: 0;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1050;
    background-color: #f8f9fa;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width 0.3s ease-in-out;
    box-shadow: -3px 0 15px rgba(0,0,0,0.2);
    padding-top: 20px;
    /* ✅ display: none; از اینجا حذف شده تا Bootstrap بتواند آن را در دسکتاپ کنترل کند */
}

/* -------------------------------------------------------------------------- */
/* ✅ قوانین عمومی: این قوانین در تمام اندازه‌های صفحه اعمال می‌شوند */
/* -------------------------------------------------------------------------- */

/* کنترل اسکرول و موقعیت در حالت باز */
body.header-sidebar-open {
    overflow: hidden; /* جلوگیری از اسکرول صفحه زیر سایدبار */
    position: relative;
}

/* Backdrop: مات‌کننده صفحه در حالت باز (در تمام اندازه‌ها) */
body.header-sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* -------------------------------------------------------------------------- */
/* ✅ قوانین مدیای موبایل (عرض سایدبار در موبایل) */
/* -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    /* .header-sidebar { display: block; } ❌ حذف شد */

    .header-sidebar.show {
        width: 280px;
    }
}

/* -------------------------------------------------------------------------- */
/* ✅ قوانین مدیای دسکتاپ (فعال‌سازی سایدبار و عرض در دسکتاپ) */
/* -------------------------------------------------------------------------- */

@media (min-width: 992px) {
    /* ✅ این قانون به کلاس .show اجازه می‌دهد تا سایدبار را نمایش دهد */
    .header-sidebar.show {
        display: block !important;
        /* عرض دلخواه سایدبار در حالت باز در دسکتاپ */
        width: 280px !important;
    }

    /* ✅ این قانون برای حل تداخل با navbar-expand-lg ضروری است */
    .navbar-expand-lg .navbar-collapse {
        display: none !important;
    }

    /* ❌ قوانین body.header-sidebar-open و body.header-sidebar-open::after حذف شدند */
}

/* -------------------------------------------------------------------------- */
/* --- استایل‌های داخلی سایدبار (بدون تغییر) --- */
/* -------------------------------------------------------------------------- */

.header-sidebar .sidebar-content {
    padding: 1rem;
    direction: rtl;
    text-align: right;
}

.header-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.header-sidebar .sidebar-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 0;
}
.header-sidebar .nav-link-custom {
    color: #333;
    font-weight: bold;
    font-size: 1rem;
}
.header-sidebar .close-sidebar-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #555;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.header-sidebar .close-sidebar-btn:hover {
    color: #dc3545;
}

/* --- استایل‌های آیتم‌های منو و خطوط جداکننده --- */
.header-sidebar .navbar-nav .nav-item {
    margin-bottom: 5px;
    position: relative;
    padding-bottom: 5px;
}

.header-sidebar .navbar-nav .nav-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 1rem;
    height: 1px;
    background-color: #e0e0e0;
}

.header-sidebar .navbar-nav .dropdown-menu .dropdown-item {
    border-bottom: none !important;
    padding-bottom: 0.5rem;
}

.header-sidebar .navbar-nav .nav-item .btn.nav-link::after {
    display: none;
}

/* --- استایل‌های فلش دراپ‌داون --- */
.header-sidebar .navbar-nav .dropdown-toggle::after {
    display: none !important;
}

.header-sidebar .navbar-nav .dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 0.8rem 1rem;
    color: #333;
    font-weight: 500;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.header-sidebar .navbar-nav .dropdown-toggle:hover {
    background-color: #e9ecef;
    color: #007bff;
}

.header-sidebar .navbar-nav .dropdown-toggle .dropdown-arrow {
    transition: transform 0.3s ease-in-out;
    margin-left: 0.5rem;
    font-size: 0.8em;
    color: #888;
    display: inline-block;
    order: 1;
}

.header-sidebar .navbar-nav .dropdown-toggle .dropdown-arrow.rotate-arrow {
    transform: rotate(180deg) !important;
}

.header-sidebar .dropdown-menu {
    position: static !important;
    float: none !important;
    width: auto !important;
    margin-top: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
    padding-left: 1rem;
}

.header-sidebar .dropdown-menu .dropdown-item {
    padding: 0.5rem 1rem;
    color: #555;
    font-weight: normal;
}

.header-sidebar .dropdown-menu .dropdown-item:hover {
    background-color: #e2e6ea;
}

.header-sidebar .btn.nav-link {
    width: fit-content;
    margin: 10px auto;
    text-align: center;
    display: block;
}

/* --- مهم: CSS نهایی برای فیلتر کردن آیتم‌ها --- */
body.header-sidebar-open .hide-on-custom-view {
    display: none !important;
}