/* FILE: static/css/sidebar-glass.css */
/* ═══════════════════════════════════════════════════════════
   SIDEBAR — Fix موبایل + Glassmorphism
   این فایل روی mobile-responsive.css و style.css override می‌زنه
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   ۱) ساختار Flex — Fix اصلی
   مشکل: بدون min-height:0، محتوای nav می‌زنه بیرون و footer هل می‌شه پایین
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;   /* اسکرول فقط توی nav */
}

.sidebar-nav {
    flex: 1 1 auto !important;
    min-height: 0 !important;      /* 🔑 کلید fix */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sidebar-footer {
    flex-shrink: 0 !important;     /* 🔑 کلید fix */
    flex-grow: 0 !important;
    position: relative;
    z-index: 2;
}

/* ═══════════════════════════════════════════════════════════
   ۲) Glassmorphism — دسکتاپ
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(11, 18, 32, 0.96) 100%
    ) !important;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: -20px 0 60px rgba(2, 8, 23, 0.25) !important;
}

/* هاله‌های نرم پس‌زمینه */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% -10%, rgba(99, 102, 241, 0.18), transparent 45%),
        radial-gradient(circle at 20% 110%, rgba(59, 130, 246, 0.12), transparent 45%);
    pointer-events: none;
    z-index: 0;
}

/* فوتر شیشه‌ای دسکتاپ */
.sidebar-footer {
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0.4) 0%,
        rgba(11, 18, 32, 0.92) 30%,
        rgba(11, 18, 32, 0.98) 100%
    ) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* ═══════════════════════════════════════════════════════════
   ۳) MOBILE — فول‌اسکرین + z-index درست
   مشکل قبلی: z-index ها تصادم داشتن → bottom-nav روی footer می‌افتاد
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: min(300px, 86vw) !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        z-index: 1060 !important;   /* بالاتر از bottom-nav (1050) */
        transform: translateX(100%);
        visibility: hidden;
        opacity: 0;
        transition:
            transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
            opacity 0.24s ease,
            visibility 0.32s ease;
        background: linear-gradient(
            180deg,
            rgba(15, 23, 42, 0.92) 0%,
            rgba(11, 18, 32, 0.97) 100%
        ) !important;
        backdrop-filter: blur(30px) saturate(180%);
        -webkit-backdrop-filter: blur(30px) saturate(180%);
    }

    .sidebar.sidebar-open {
        transform: translateX(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .sidebar-header,
    .sidebar-status {
        flex-shrink: 0 !important;
    }

    .sidebar-nav {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding-bottom: 8px;
    }

    /* 🔑 فوتر موبایل — همیشه دیده می‌شه، هیچ‌وقت فشرده نمی‌شه */
    .sidebar-footer {
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        padding: 12px 14px !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        background: linear-gradient(
            180deg,
            rgba(15, 23, 42, 0.6) 0%,
            rgba(11, 18, 32, 0.99) 100%
        ) !important;
    }

    /* backdrop — z-index 1055 (بین sidebar و bottom-nav) */
    .sidebar-backdrop {
        z-index: 1055 !important;
        background: rgba(2, 8, 23, 0.55) !important;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    /* وقتی سایدبار بازه، bottom-nav مخفی بشه */
    body.sidebar-open .bottom-nav {
        transform: translateY(120%);
        opacity: 0;
        pointer-events: none;
    }
    .bottom-nav {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    body.sidebar-open {
        overflow: hidden !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   ۴) دکمه‌های فوتر — شیشه‌ای مدرن
   ═══════════════════════════════════════════════════════════ */
.sidebar-footer .sidebar-logout,
.sidebar-footer .sidebar-notification-link {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 11px !important;
    transition: all 0.2s ease;
}

.sidebar-footer .sidebar-logout:hover,
.sidebar-footer .sidebar-notification-link:hover {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
    transform: translateY(-1px);
}

.sidebar-footer .sidebar-logout:last-of-type {
    margin-top: 4px;
}

/* آواتار کاربر — گرد و شیشه‌ای */
.sidebar-avatar {
    border-radius: 50% !important;
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35) !important;
}

/* ═══════════════════════════════════════════════════════════
   ۵) اسکرول‌بار نازک شیشه‌ای
   ═══════════════════════════════════════════════════════════ */
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ═══════════════════════════════════════════════════════════
   ۶) موبایل‌های کم‌ارتفاع (مثل گوشی‌های قدیمی) — فشرده‌تر
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) and (max-height: 600px) {
    .sidebar-header {
        min-height: 68px !important;
        padding: 12px 16px 8px !important;
    }
    .sidebar-status {
        padding: 6px 16px 3px !important;
        font-size: 10px !important;
    }
    .sidebar-footer {
        padding: 8px 12px !important;
    }
    .sidebar-logout {
        height: 34px !important;
        font-size: 10.5px !important;
    }
    .sidebar-user {
        padding: 5px 3px 6px !important;
    }
}