/* ============================================
   USER DROPDOWN MENU - PREMIUM STYLING
   ============================================ */

/* MOBILE: Break out of stacking context so panel can appear above everything */
@media (max-width: 768px) {

    /* Ensure navbar doesn't create limiting stacking context */
    .navbar-main,
    .navbar-collapse,
    .navbar-actions,
    .user-dropdown {
        transform: none !important;
        isolation: auto !important;
    }

    /* When user panel is open, ensure no stacking context limits it */
    body.user-panel-open .navbar-main {
        z-index: auto !important;
    }

    body.user-panel-open .navbar-collapse {
        z-index: auto !important;
    }
}

/* User Icon Button */
.user-icon-btn {
    position: relative;
    transition: all 0.3s ease;
}

.user-icon-btn:hover {
    transform: scale(1.1);
}

.user-icon-btn .bi-person-circle {
    font-size: 24px;
}

/* Dropdown Menu */
.user-dropdown-menu {
    min-width: 260px !important;
    border-radius: 16px !important;
    border: 1px solid rgba(201, 162, 39, 0.2) !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(20px);
    padding: 10px !important;
    margin-top: 12px !important;
    animation: dropdownSlideIn 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
}

/* Dark Mode Dropdown - support both selectors */
[data-bs-theme="dark"] .user-dropdown-menu,
[data-theme="dark"] .user-dropdown-menu {
    background: rgba(33, 19, 12, 0.98) !important;
    border-color: rgba(201, 162, 39, 0.3) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Premium Dropdown Item */
.dropdown-item.premium-item {
    padding: 12px 16px !important;
    border-radius: 10px !important;
    margin-bottom: 4px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    transition: all 0.2s ease !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
    color: #2c1810 !important;
    /* Dark brown for light mode */
    background: transparent !important;
}

/* Dark Mode Dropdown Item - support both selectors */
[data-bs-theme="dark"] .dropdown-item.premium-item,
[data-theme="dark"] .dropdown-item.premium-item {
    color: #e8e8e8 !important;
    /* Light gray for dark mode */
}

.dropdown-item.premium-item:hover {
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.15), rgba(201, 162, 39, 0.1)) !important;
    transform: translateX(-3px) !important;
    box-shadow: 0 2px 8px rgba(201, 162, 39, 0.2);
    color: #c9a227 !important;
    /* Gold on hover */
}

[data-bs-theme="dark"] .dropdown-item.premium-item:hover,
[data-theme="dark"] .dropdown-item.premium-item:hover {
    color: #c9a227 !important;
    /* Gold on hover */
}

/* Icon Container */
.item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* Icon Color Variants */
.admin-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.orders-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.wishlist-icon {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.track-icon {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.points-icon {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
}

.logout-icon {
    background: linear-gradient(135deg, #ff6b6b 0%, #c92a2a 100%);
    color: white;
}

.dropdown-item.premium-item:hover .item-icon {
    transform: rotate(5deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Points Badge */
.points-badge {
    background: linear-gradient(135deg, var(--gold), #d4a84b) !important;
    color: var(--espresso) !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(201, 162, 39, 0.3);
    min-width: 40px;
    text-align: center;
}

/* Divider */
.user-dropdown-menu .dropdown-divider {
    margin: 8px 0 !important;
    border-color: rgba(201, 162, 39, 0.2) !important;
}

/* Logout Item Special Style */
.logout-item:hover {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(201, 42, 42, 0.1)) !important;
}

/* ============================================
   MOBILE - SLIDE-IN SIDE PANEL
   ============================================ */

/* Backdrop overlay for mobile - only shown when panel is open */
.user-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    /* Just below panel */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Only show backdrop on mobile */
@media (max-width: 768px) {
    .user-panel-backdrop.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

/* Hide announcement bar when user panel is open */
body.user-panel-open .announcement-bar {
    z-index: 1 !important;
}

@media (max-width: 768px) {

    /* Transform dropdown into slide-in panel */
    .user-dropdown-menu {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: 280px !important;
        max-width: 85vw !important;
        min-width: unset !important;
        height: 100vh !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        padding-top: 70px !important;
        /* Space for close button */
        border-radius: 20px 0 0 20px !important;
        border: none !important;
        border-left: 1px solid rgba(201, 162, 39, 0.3) !important;
        background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f0f1a 100%) !important;
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5) !important;
        z-index: 999999 !important;
        /* Super high z-index */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 80px !important;
        /* Fixed: Use right position for smooth slide instead of transform */
        display: block !important;
        visibility: hidden !important;
        opacity: 0 !important;
        right: -100% !important;
        transform: none !important;
        transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.35s ease,
            visibility 0.35s ease !important;
    }

    .user-dropdown-menu.show {
        visibility: visible !important;
        opacity: 1 !important;
        right: 0 !important;
    }

    /* Hide the li wrapper for close button so it doesn't affect layout */
    .user-dropdown-menu>li:first-child {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        display: block !important;
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* Mobile close button styling - position fixed relative to panel */
    .mobile-panel-close {
        position: absolute !important;
        top: 12px !important;
        left: 12px !important;
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-radius: 12px !important;
        color: rgba(255, 255, 255, 0.9) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        z-index: 1000 !important;
        transition: all 0.3s ease !important;
        font-size: 1.2rem !important;
    }

    .mobile-panel-close:hover,
    .mobile-panel-close:active {
        background: rgba(201, 162, 39, 0.3) !important;
        color: #c9a227 !important;
        transform: scale(1.1) !important;
    }

    /* ============================================
       NOTIFICATION DROPDOWN - MOBILE FIX
       ============================================ */
    .notification-menu,
    .notification-dropdown .dropdown-menu {
        position: fixed !important;
        top: 70px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
        max-height: 70vh !important;
        z-index: 999999 !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
    }
}

/* Panel Header */
.user-dropdown-menu::before {
    content: 'حسابي';
    display: block;
    padding: 25px 20px 20px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #c9a227;
    border-bottom: 1px solid rgba(201, 162, 39, 0.2);
    margin-bottom: 10px;
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.1), transparent);
}

/* Menu items container */
.user-dropdown-menu>* {
    opacity: 0;
    transform: translateX(20px);
}

.user-dropdown-menu.show>* {
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease;
}

/* Stagger animation for items */
.user-dropdown-menu.show>*:nth-child(1) {
    transition-delay: 0.1s;
}

.user-dropdown-menu.show>*:nth-child(2) {
    transition-delay: 0.15s;
}

.user-dropdown-menu.show>*:nth-child(3) {
    transition-delay: 0.2s;
}

.user-dropdown-menu.show>*:nth-child(4) {
    transition-delay: 0.25s;
}

.user-dropdown-menu.show>*:nth-child(5) {
    transition-delay: 0.3s;
}

.user-dropdown-menu.show>*:nth-child(6) {
    transition-delay: 0.35s;
}

.user-dropdown-menu.show>*:nth-child(7) {
    transition-delay: 0.4s;
}

.user-dropdown-menu.show>*:nth-child(8) {
    transition-delay: 0.45s;
}

/* ====================================================================================
   MOBILE PANEL - PREMIUM ITEMS STYLING
   These styles are ONLY for mobile panel (dark background)
   ==================================================================================== */
@media (max-width: 768px) {
    /* Premium items in panel */
    .dropdown-item.premium-item {
        padding: 16px 20px !important;
        margin: 4px 10px !important;
        border-radius: 12px !important;
        font-size: 1rem !important;
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.03) !important;
        border: 1px solid transparent !important;
    }

    .dropdown-item.premium-item:hover,
    .dropdown-item.premium-item:active {
        background: linear-gradient(135deg, rgba(201, 162, 39, 0.2), rgba(201, 162, 39, 0.1)) !important;
        border-color: rgba(201, 162, 39, 0.3) !important;
        transform: translateX(-5px) !important;
    }

    /* Icons in panel */
    .item-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
        border-radius: 12px;
    }

    /* Dividers */
    .user-dropdown-menu .dropdown-divider {
        margin: 15px 20px !important;
        border-color: rgba(201, 162, 39, 0.15) !important;
    }

    /* Points badge in panel */
    .points-badge {
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
    }

    /* Logout item special styling */
    .logout-item {
        margin-top: auto !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding-top: 15px !important;
    }
}

/* Close button area - removed since we have real button now */
.user-dropdown-menu::after {
    display: none !important;
}

/* Extra small screens */
@media (max-width: 576px) {
    .user-dropdown-menu {
        width: 260px !important;
    }

    .dropdown-item.premium-item {
        padding: 14px 16px !important;
        margin: 3px 8px !important;
    }

    .item-icon {
        width: 40px;
        height: 40px;
    }
}