/* Mobile Dropdown Fix for MysteryRun */

/* Solution 1: Force dropdown to bottom of screen on mobile */
@media (max-width: 768px) {
    .dropdown .dropdown-menu {
        position: absolute !important;
        top: auto !important;           /* ← Below button instead of bottom: 20px */
        bottom: auto !important;
        left: auto !important;
        right: auto !important;            /* ← Align to right edge of button */
        width: auto !important;
        transform: none !important;
        border-radius: 12px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 1050;
        max-height: 60vh;
        overflow-y: auto;
        margin: 0;
    }

    /* Add backdrop when dropdown is open */
    .dropdown.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 1040;
        animation: fadeIn 0.2s ease-out;
    }

    /* Smooth dropdown animation */
    .dropdown-menu {
        animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    /* Make dropdown items more touch-friendly */
    .dropdown-item {
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 8px;
        margin: 2px 8px;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        background-color: #f8f9fa;
        transform: none;
    }

    .dropdown-item:active {
        background-color: #e9ecef;
    }

    /* Divider styling */
    .dropdown-divider {
        margin: 8px 0;
    }
}

/* Alternative Solution 2: Auto-positioning dropdown (works on all screen sizes) */
.dropdown-auto-position .dropdown-menu {
    position: absolute;
}

/* Force dropup when needed */
.dropdown-force-up .dropdown-menu {
    top: auto !important;
    bottom: 100% !important;
    margin-bottom: 2px;
    margin-top: 0;
}

/* Solution 3: Enhanced mobile-first approach */
@media (max-width: 576px) {
    /* Even more mobile-friendly for very small screens */
    .dropdown .dropdown-menu {
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        border-radius: 16px;
        padding: 8px;
    }

    .dropdown-item {
        padding: 14px 16px;
        font-size: 16px;
        border-radius: 12px;
        margin: 2px 4px;
    }

    /* Add visual feedback */
    .dropdown-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Ensure proper stacking */
.navbar {
    z-index: 1030;
}

.dropdown-menu {
    z-index: 1050;
}

/* Handle landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .dropdown .dropdown-menu {
        max-height: 40vh;
        bottom: 10px !important;
    }
}

/* Accessibility improvements */
.dropdown-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Dark mode support (if you plan to add it later) */
@media (prefers-color-scheme: dark) {
    .dropdown.show::before {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Handle very long usernames */
@media (max-width: 768px) {
    .dropdown .btn {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}