﻿/* ═══════════════════════════════════════════════════
   99-FORCE-FIX — قفل کردن مشکلات CSS
   ═══════════════════════════════════════════════════ */

/* ═══ ۱. Custom Select — منو فقط با کلیک باز شود ═══ */
.custom-select .cs-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select.open .cs-menu {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ═══ ۲. فیلترهای دو ردیفی — گرید ۴ ستونه ═══ */
.filters.two-rows {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 12px !important;
    align-items: end !important;
}

    .filters.two-rows .form-group {
        margin: 0 !important;
    }

    .filters.two-rows .pf-customer-group {
        grid-column: span 2 !important;
    }

@media (max-width: 900px) {
    .filters.two-rows {
        grid-template-columns: repeat(2, 1fr) !important;
    }

        .filters.two-rows .pf-customer-group {
            grid-column: span 2 !important;
        }
}

@media (max-width: 600px) {
    .filters.two-rows {
        grid-template-columns: 1fr !important;
    }

        .filters.two-rows .pf-customer-group {
            grid-column: span 1 !important;
        }
}

.filter-card.collapsed .filter-body {
    display: none !important;
}
/* ═══════════════════════════════════════════════════
   ⭐ FORCE FIX — dropdown فیلترها رو کلپ نکن
   ═══════════════════════════════════════════════════ */

/* هر کارت فیلتری — همه‌ی زیرمجموعه‌هاش باید visible باشن */
.filter-card,
.filter-card .card-title,
.filter-card .filter-body,
.filter-card .filters,
.filter-card .form-group,
.filter-card .pf-customer-group {
    overflow: visible !important;
}

/* کارت‌های عمومی وقتی داخلشون filter هست */
.card:has(.filter-card),
.card:has(.filters) {
    overflow: visible !important;
}

/* ⭐ Custom Select dropdown — بالای همه چیز */
.custom-select.open .cs-menu,
.cs-menu {
    z-index: 9999 !important;
}

/* ⭐ پیشنهادات طرف حساب — بالای همه چیز */
.pf-suggestions {
    z-index: 9999 !important;
}

/* ═══════════════════════════════════════════════════════
   🎯 SIDEBAR LAYOUT — v2 (محافظه‌کارانه)
   ├─ فقط ساختار Flex می‌کنه
   ├─ به ظاهر آیتم‌ها کاری نداره
   └─ فقط ناحیه‌ی nav اسکرول می‌خوره
   ═══════════════════════════════════════════════════════ */

/* 1) خود سایدبار ← Flex Column */
#appSidebar {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important; /* fallback مرورگرهای قدیمی */
    height: 100dvh !important; /* موبایل — نوار آدرس */
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}

    /* 2) هدر (لوگو) ← ثابت بالا */
    #appSidebar > .sidebar-header {
        flex: 0 0 auto !important;
    }

    /* 3) ناوبری (منوها) ← این فقط اسکرول می‌خوره */
    #appSidebar > #appNav,
    #appSidebar > nav.nav {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important; /* ⭐ کلید fix در Flex */
    }

        /* اسکرول‌بار باریک و شفاف (فقط مرورگرهای مدرن) */
        #appSidebar > #appNav::-webkit-scrollbar,
        #appSidebar > nav.nav::-webkit-scrollbar {
            width: 6px;
        }

        #appSidebar > #appNav::-webkit-scrollbar-thumb,
        #appSidebar > nav.nav::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.18);
            border-radius: 3px;
        }

            #appSidebar > #appNav::-webkit-scrollbar-thumb:hover,
            #appSidebar > nav.nav::-webkit-scrollbar-thumb:hover {
                background: rgba(255,255,255,0.3);
            }

    /* 4) هر چیزی بعد از nav (کارت مدیر + دکمه خروج) ← ثابت پایین */
    #appSidebar > *:not(.sidebar-header):not(#appNav):not(nav.nav) {
        flex: 0 0 auto !important;
    }

/* ═══════════════════════════════════════════════════════
   موبایل: ارتفاع با dvh (نوار آدرس سافاری/کروم)
   ═══════════════════════════════════════════════════════ */
@supports (height: 100dvh) {
    #appSidebar {
        height: 100dvh !important;
        max-height: 100dvh !important;
    }
}

/* ═══════════════════════════════════════════════════════
   ⭐ Collapsible Card — کارت جمع‌شو
   ═══════════════════════════════════════════════════════ */

.collapsible-card .card-title {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 32px; /* جای فلش */
    transition: background 0.15s;
    border-radius: 6px;
}

    .collapsible-card .card-title:hover {
        background: #F9FAFB;
    }

/* فلش گوشه‌ی چپ */
.collapsible-card .collapse-arrow {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    font-size: 11px;
    color: #6B7280;
    transition: transform 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: #F3F4F6;
}

.collapsible-card .card-title:hover .collapse-arrow {
    background: #EEF2FF;
    color: #4F46E5;
}

/* وقتی جمع شده — فلش چرخیده */
.collapsible-card.collapsed .collapse-arrow {
    transform: translateY(-50%) rotate(-90deg);
}

/* بدنه‌ی کارت */
.collapsible-card .card-body {
    transition: max-height 0.28s ease, opacity 0.2s ease, margin 0.2s ease;
    overflow: hidden;
    max-height: 5000px; /* یه مقدار بزرگ */
    opacity: 1;
}

/* وقتی جمع شده */
.collapsible-card.collapsed .card-body {
    max-height: 0 !important;
    opacity: 0;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ═══════════════════════════════════════════════════════
   ⭐ Ledger Actions Bar — دکمه تهیه گزارش جدا از کارت
   ═══════════════════════════════════════════════════════ */

.ledger-actions-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin: 12px 0 16px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

    .ledger-actions-bar .btn {
        min-width: 180px;
        font-weight: 600;
    }

/* ═══ موبایل ═══ */
@media (max-width: 768px) {
    .ledger-actions-bar {
        position: sticky;
        bottom: 12px;
        z-index: 50;
        margin: 8px 0 12px;
        padding: 10px 12px;
        border-color: #C7D2FE;
        box-shadow: 0 6px 20px rgba(79, 70, 229, 0.18);
    }

        .ledger-actions-bar .btn {
            width: 100%;
            min-width: 0;
            padding: 12px;
            font-size: 14px;
        }
}