/* User Dropdown Mobile Responsive Fixes */

/* Ensure dropdown is accessible on all screen sizes */
.user-dropdown-mobile {
    position: fixed !important;
    top: 60px !important;
    right: 10px !important;
    left: auto !important;
    transform: none !important;
    max-height: calc(100vh - 80px) !important;
    overflow-y: auto !important;
    z-index: 1050 !important;
    min-width: 200px !important;
    max-width: 280px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3) !important;
    display: block !important;
    visibility: visible !important;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .user-dropdown-mobile {
        top: 55px !important;
        right: 5px !important;
        max-height: calc(100vh - 70px) !important;
        min-width: 180px !important;
        max-width: calc(100vw - 20px) !important;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    .user-dropdown-mobile {
        top: 50px !important;
        right: 10px !important;
        left: 10px !important;
        min-width: auto !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 60px) !important;
    }
}

/* Ensure dropdown items are easily tappable on mobile */
@media (max-width: 768px) {
    .user-dropdown-mobile .dropdown-item {
        padding: 12px 16px !important;
        font-size: 16px !important;
        line-height: 1.5 !important;
    }
    
    .user-dropdown-mobile .dropdown-item i {
        width: 20px !important;
        text-align: center !important;
    }
}

/* Ensure dropdown is visible above other elements */
.navbar .dropdown-menu {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    background-color: #1a1d29 !important;
}

/* Improve touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .user-dropdown-mobile .dropdown-item {
        padding: 14px 18px !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* Fix for very small screens and short viewports */
@media (max-height: 600px) {
    .user-dropdown-mobile {
        top: 40px !important;
        max-height: calc(100vh - 50px) !important;
    }
}

/* Extra short screens */
@media (max-height: 480px) {
    .user-dropdown-mobile {
        top: 35px !important;
        max-height: calc(100vh - 45px) !important;
    }
}

/* Ensure logout button is always visible */
.user-dropdown-mobile .dropdown-item:last-child {
    margin-bottom: 0 !important;
    border-bottom: none !important;
}

/* Smooth scroll for long dropdown lists */
.user-dropdown-mobile {
    scroll-behavior: smooth !important;
}

/* Force dropdown to show when Bootstrap dropdown is active */
.dropdown-menu.show.user-dropdown-mobile {
    position: fixed !important;
    top: 60px !important;
    right: 10px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    z-index: 1050 !important;
    background-color: #1a1d29 !important;
    border: 1px solid #374151 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3) !important;
}

/* Prevent dropdown from closing too quickly */
.user-dropdown-mobile {
    pointer-events: auto !important;
}

.user-dropdown-mobile:hover {
    display: block !important;
    visibility: visible !important;
}

/* Keep dropdown open when hovering over it */
.dropdown:hover .dropdown-menu.user-dropdown-mobile {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Smooth transitions for dropdown */
.user-dropdown-mobile {
    transition: opacity 0.15s ease, visibility 0.15s ease !important;
}

/* Make dropdown more stable for clicking */
.user-dropdown-mobile:hover {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Add padding to dropdown container for easier hovering */
.user-dropdown-mobile::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    z-index: -1;
}

/* Larger click area for dropdown items */
.user-dropdown-mobile .dropdown-item {
    padding: 12px 20px !important;
    line-height: 1.5 !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
}

/* Ensure dropdown stays visible during interaction */
.user-dropdown-mobile.show {
    animation: fadeIn 0.15s ease-in-out !important;
}

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

/* Emergency logout button - always visible */
.emergency-logout {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1060 !important;
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 12px 20px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3) !important;
    display: block !important;
    text-decoration: none !important;
}

.emergency-logout:hover {
    background: #c82333 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4) !important;
    color: white !important;
    text-decoration: none !important;
}

/* Show emergency logout on mobile when dropdown might be problematic */
@media (max-width: 768px) {
    .emergency-logout {
        display: block !important;
    }
}

/* Always show emergency logout for Professional users having issues */
.emergency-logout {
    display: block !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 1060 !important;
}

/* Enhanced dropdown stability */
.dropdown-toggle::after {
    transition: transform 0.3s ease !important;
}

.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg) !important;
}

/* Ensure dropdown items are clickable */
.user-dropdown-mobile .dropdown-item {
    pointer-events: auto !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.user-dropdown-mobile .dropdown-item:hover {
    background-color: #374151 !important;
    color: #ffffff !important;
}