/* ═══════════════════════════════════════════════════════════════════════════
   🎨 ESS ULTIMATE SIDEBAR - Two-Tier Smart Sidebar with Glass Morphism
   ═══════════════════════════════════════════════════════════════════════════
   
   المميزات:
   ✅ عمود أيقونات دائم (70px)
   ✅ لوحة نص تظهر عند hover (200px)
   ✅ Glass morphism effect
   ✅ أيقونات ملونة gradient
   ✅ animations ناعمة جداً
   ✅ توفير مساحة كبيرة للمحتوى
   
   ═══════════════════════════════════════════════════════════════════════════ */

/* ════════════════ MAIN SIDEBAR STRUCTURE ════════════════ */

#sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    height: 100vh !important;
    width: 270px !important;  /* ✅ عرض كامل دائماً */
    background: linear-gradient(180deg, 
        rgba(102, 126, 234, 0.95) 0%,
        rgba(118, 75, 162, 0.95) 100%) !important;
    backdrop-filter: blur(20px) !important;  /* ✅ Glass effect */
    -webkit-backdrop-filter: blur(20px) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 
        -4px 0 30px rgba(0, 0, 0, 0.3),
        inset 1px 0 0 rgba(255, 255, 255, 0.1) !important;
    overflow-y: auto !important;  /* ✅ تفعيل scroll */
    overflow-x: hidden !important;
    z-index: 10000 !important;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* ✅ Sidebar Collapsed State */
#sidebar.collapsed {
    width: 70px !important;
}

#sidebar.collapsed .sidebar-text {
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
}

#sidebar.collapsed .section-title {
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* ✅ padding للـ nav */
#sidebar .nav {
    padding-bottom: 80px !important;  /* ✅ مساحة في الأسفل */
    padding-top: 10px !important;
}

/* ════════════════ SIDEBAR HEADER ════════════════ */

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent,
        rgba(255, 255, 255, 0.5),
        transparent);
}

.sidebar-header img {
    max-width: 120px !important;
    max-height: 50px !important;
    transition: all 0.3s ease;
}

/* ════════════════ NAV ITEMS - الأيقونات ════════════════ */

#sidebar .nav-item {
    position: relative;
    margin: 4px 0;
}

#sidebar .nav-link {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 14px 15px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    white-space: nowrap;
    border-radius: 0 !important;
    margin: 0 !important;
}

/* ✅ الأيقونة */
#sidebar .nav-link i {
    min-width: 30px !important;
    text-align: center !important;
    font-size: 20px !important;
    margin-left: 12px !important;
    transition: all 0.3s ease !important;
    position: relative;
    z-index: 2;
    /* ✅ لون واضح ومرئي */
    color: #FFD700 !important;  /* ✅ ذهبي واضح */
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ✅ تأثير gradient عند hover */
#sidebar .nav-link:hover i {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transform: scale(1.15);
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.7));
}

/* ✅ النص - دائماً مرئي */
#sidebar .sidebar-text {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
    flex: 1;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 500;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ════════════════ HOVER EFFECTS ════════════════ */

#sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

#sidebar .nav-link:hover i {
    transform: scale(1.15) !important;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}

/* ════════════════ ACTIVE LINK STYLING ════════════════ */

#sidebar .nav-link.active {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.25) 0%,
        rgba(255, 255, 255, 0.15) 100%) !important;
    border-right: 4px solid #FFD700 !important;
}

#sidebar .nav-link.active i {
    color: #FF6B6B !important;  /* ✅ أحمر للـ active */
    text-shadow: 0 0 15px rgba(255, 107, 107, 0.8);
    transform: scale(1.2) !important;
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8));
}

#sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 80%;
    background: linear-gradient(180deg, #FFD700, #FF6B6B);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    border-radius: 4px 0 0 4px;
}

#sidebar .nav-link.active .sidebar-text {
    color: #FFD700 !important;
    font-weight: 600 !important;
}

/* ════════════════ DROPDOWN / SUBMENU ════════════════ */

#sidebar .dropdown-toggle::after {
    display: none !important;  /* ✅ إخفاء السهم الافتراضي */
}

/* ✅ السهم المخصص */
#sidebar .dropdown-toggle {
    position: relative;
}

#sidebar .dropdown-toggle i:last-of-type {
    position: absolute;
    left: 10px;
    font-size: 12px !important;
    opacity: 0;
    transition: all 0.3s ease;
}

#sidebar:hover .dropdown-toggle i:last-of-type {
    opacity: 1;
}

/* ✅ Submenu Styling */
#sidebar .submenu {
    background: rgba(0, 0, 0, 0.2) !important;
    border-left: 2px solid rgba(255, 215, 0, 0.3);
    margin: 0 !important;
    padding: 5px 0 !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar .submenu.show {
    max-height: 1000px;
}

#sidebar .dropdown-item {
    padding: 10px 10px 10px 35px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#sidebar .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    padding-right: 15px !important;
    color: #FFD700 !important;
}

#sidebar .dropdown-item i {
    width: auto !important;
    min-width: 20px !important;
    font-size: 14px !important;
    margin-left: 8px;
    color: rgba(255, 215, 0, 0.8) !important;  /* ✅ ذهبي واضح */
    text-shadow: none;
}

#sidebar .dropdown-item.active {
    background: rgba(255, 215, 0, 0.2) !important;
    border-right: 3px solid #FFD700;
    color: #FFD700 !important;
}

/* ════════════════ SECTION TITLES ════════════════ */

#sidebar .section-title {
    padding: 12px 15px 8px 15px !important;
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 1 !important;
    height: auto !important;
}

#sidebar .section-title span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

/* ════════════════ SCROLLBAR STYLING ════════════════ */

#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.4);
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.6);
}

/* Firefox */
#sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.4) rgba(0, 0, 0, 0.2);
}

/* ════════════════ BADGES (Notifications) ════════════════ */

#sidebar .badge {
    position: absolute !important;
    top: 8px !important;
    left: 45px !important;
    font-size: 9px !important;
    padding: 3px 5px !important;
    background: linear-gradient(135deg, #FF6B6B, #FF8E53) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.5) !important;
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

#sidebar .nav-link:hover .badge {
    transform: scale(1);
}

/* ════════════════ CONTENT AREA ADJUSTMENT ════════════════ */

/* ✅ قاعدة عامة للـ body */
body {
    margin: 0 !important;
    padding: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden !important;
}

/* ✅ الـ wrapper - الحاوي الرئيسي */
.wrapper,
.d-flex.wrapper,
body > .d-flex {
    margin-right: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    transition: none !important;
}

/* ✅ الـ page-content (حاوي الـ navbar والمحتوى) */
#content,
.page-content,
#content.page-content {
    margin-right: 270px !important;  /* ✅ دفع المحتوى بمقدار عرض القائمة */
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: calc(100% - 270px) !important;
    padding: 0 !important;
    margin-top: 0 !important;
}

/* ✅ الـ navbar نفسه */
.modern-navbar-unified,
nav.navbar,
.navbar {
    margin: 0 !important;
    padding: 0.75rem 0 !important;
}

/* ✅ عندما تُطوى القائمة */
body.sidebar-collapsed #content,
body.sidebar-collapsed .page-content,
body.sidebar-collapsed #content.page-content {
    margin-right: 70px !important;
    width: calc(100% - 70px) !important;
}

/* ✅ المحتوى الداخلي */
.main-content,
main,
body > div.container-fluid,
body > main,
.content-wrapper,
#main-content {
    margin-right: 0 !important;
    transition: none !important;
    padding-right: 20px !important;
    width: 100% !important;
}

/* ✅ الـ Footer */
footer,
.footer-dynamic,
footer.footer-dynamic {
    margin-right: 270px !important;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: calc(100% - 270px) !important;
}

/* ✅ Footer عند طي القائمة */
body.sidebar-collapsed footer,
body.sidebar-collapsed .footer-dynamic,
body.sidebar-collapsed footer.footer-dynamic {
    margin-right: 70px !important;
    width: calc(100% - 70px) !important;
}

/* ✅ للصفحات التي تستخدم container */
.container,
.container-fluid {
    margin-right: auto !important;
    margin-left: auto !important;
    max-width: 100% !important;
}

/* ════════════════ MOBILE RESPONSIVE ════════════════ */

@media (max-width: 992px) {
    #sidebar {
        width: 270px !important;
        transform: translateX(100%) !important;
        backdrop-filter: blur(30px) !important;
    }
    
    #sidebar.show {
        transform: translateX(0) !important;
    }
    
    /* ✅ إلغاء الـ margin للـ mobile */
    .main-content,
    main,
    body > div.container-fluid,
    body > main,
    #content,
    .page-content,
    footer,
    .footer-dynamic {
        margin-right: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    #sidebar {
        width: 270px !important;
        right: -270px !important;
        transition: right 0.3s ease !important;
    }
    
    #sidebar.show {
        right: 0 !important;
    }
    
    /* ✅ إلغاء الـ margin للـ mobile */
    #content,
    .page-content,
    footer,
    .footer-dynamic {
        margin-right: 0 !important;
        width: 100% !important;
    }
}

/* ════════════════ TOOLTIP STYLE ════════════════ */

#sidebar .nav-link[title]:not(:hover) .sidebar-text {
    display: none;
}

/* ════════════════ SPECIAL EFFECTS ════════════════ */

/* ✅ Glow effect على الأيقونات المهمة */
#sidebar .nav-link[asp-page*="Dashboard"] i,
#sidebar .nav-link[asp-page*="SystemOwner"] i {
    animation: gentleGlow 3s ease-in-out infinite;
}

@keyframes gentleGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.7));
    }
}

/* ✅ Submenu header styling */
.submenu-header {
    padding: 8px 15px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.5) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    margin-bottom: 5px !important;
}

/* ✅ Divider في Submenu */
.dropdown-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    margin: 5px 0 !important;
    opacity: 0.5;
}

/* ════════════════ PERFORMANCE OPTIMIZATION ════════════════ */

#sidebar,
#sidebar * {
    will-change: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#sidebar .nav-link,
#sidebar .sidebar-text {
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ════════════════ MOBILE MENU BUTTON & OVERLAY ════════════════ */

/* زر القائمة المحمول */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 10001;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95), rgba(118, 75, 162, 0.95));
    color: #FFD700;
    border: 2px solid rgba(255, 215, 0, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 30px rgba(255, 215, 0, 0.6);
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.95), rgba(102, 126, 234, 0.95));
}

.mobile-menu-toggle i {
    line-height: 1;
    color: #FFD700;
}

/* Sidebar Overlay - الخلفية الشفافة */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(5px);
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ════════════════ MOBILE RESPONSIVE (768px and below) ════════════════ */

@media (max-width: 768px) {
    /* ✅ إظهار زر القائمة والـ Overlay */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .sidebar-overlay {
        display: block;
    }
    
    /* ✅ Sidebar مخفي افتراضياً */
    #sidebar {
        position: fixed !important;
        top: 0 !important;
        right: -280px !important;  /* مخفي خارج الشاشة */
        width: 270px !important;
        max-width: 80vw;
        height: 100vh !important;
        transform: none !important;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 10000 !important;
        box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5) !important;
    }
    
    /* ✅ إظهار Sidebar عند الضغط */
    #sidebar.show {
        right: 0 !important;
    }
    
    /* ✅ المحتوى يأخذ كامل العرض */
    #content,
    .page-content,
    #content.page-content,
    .main-content,
    main,
    footer,
    .footer-dynamic {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
    }
    
    /* ✅ Navbar في الموبايل */
    .modern-navbar-unified,
    nav.navbar,
    .navbar {
        margin-top: 60px !important;  /* مساحة لزر القائمة */
        width: 100% !important;
    }
    
    /* ✅ إغلاق القائمة عند الضغط على رابط */
    #sidebar .nav-link {
        padding: 12px 15px !important;
    }
}

/* ════════════════ SMALL MOBILE (480px and below) ════════════════ */

@media (max-width: 480px) {
    #sidebar {
        width: 250px !important;
        right: -260px !important;
    }
    
    .mobile-menu-toggle {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    #sidebar .nav-link {
        padding: 10px 12px !important;
        font-size: 14px !important;
    }
    
    #sidebar .nav-link i {
        font-size: 18px !important;
    }
    
    #sidebar .sidebar-text {
        font-size: 14px !important;
    }
}
