/* ============================================
   MOBILE NAVIGATION ENHANCEMENTS
   ============================================
   Menu overlay, bottom navigation, swipe gestures
   ============================================ */

/* ============================================
   MENU OVERLAY/BACKDROP
   ============================================ */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Enhanced mobile menu positioning */
@media (max-width: 767px) {
    #left-nav {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        z-index: 99 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }
    
    #left-nav.active {
        transform: translateX(0) !important;
        display: block !important;
    }
    
    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Ensure main content doesn't overlap */
    #main-content {
        margin-left: 0 !important;
    }
}

/* ============================================
   BOTTOM NAVIGATION BAR
   ============================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    /* Support for devices with home indicator */
}

@media (max-width: 767px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    /* Add padding to main content to prevent overlap */
    #main-content {
        padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }
}

.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-decoration: none;
    color: #6c757d;
    transition: all 0.2s ease;
    min-height: 56px;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-bottom-nav-item:active {
    transform: scale(0.95);
    background-color: rgba(0, 123, 255, 0.1);
}

.mobile-bottom-nav-item.active {
    color: #007bff;
}

.mobile-bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: #007bff;
    border-radius: 0 0 3px 3px;
}

.mobile-bottom-nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.mobile-bottom-nav-item:active .mobile-bottom-nav-icon {
    transform: scale(0.9);
}

.mobile-bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.mobile-bottom-nav-item.active .mobile-bottom-nav-label {
    font-weight: 600;
}

/* Hide bottom nav on desktop */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
    }
    
    #main-content {
        padding-bottom: 20px !important;
    }
}

/* Ensure mobile-browser class shows bottom nav (override media query) */
.mobile-browser .mobile-bottom-nav {
    display: flex !important;
}

/* ============================================
   PROFILE/LOGOUT BUTTON IN MOBILE HEADER
   ============================================ */
.mobile-header-profile-btn {
    background: transparent;
    border: none;
    color: #1A73E8;
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
    text-decoration: none;
    flex-shrink: 0;
    margin-left: auto;
}
.mobile-header-profile-btn:hover {
    background: rgba(26, 115, 232, 0.1);
    transform: scale(1.1);
}
.mobile-header-profile-btn:active {
    transform: scale(0.95);
}

/* ============================================
   SWIPE GESTURE INDICATORS
   ============================================ */
.swipe-indicator {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60px;
    background: rgba(0, 123, 255, 0.3);
    border-radius: 0 4px 4px 0;
    z-index: 97;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.swipe-indicator.visible {
    opacity: 1;
}

@media (min-width: 768px) {
    .swipe-indicator {
        display: none;
    }
}

/* ============================================
   SAFE AREA SUPPORT (Notched Devices)
   ============================================ */
@supports (padding: max(0px)) {
    .mobile-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
    
    .mobile-bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    #main-content {
        padding-top: max(20px, calc(env(safe-area-inset-top) + 20px));
        padding-bottom: max(70px, calc(70px + env(safe-area-inset-bottom)));
    }
}

/* ============================================
   MENU ANIMATION ENHANCEMENTS
   ============================================ */
#left-nav {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.mobile-menu-overlay {
    will-change: opacity;
}

/* ============================================
   TOUCH FEEDBACK
   ============================================ */
.mobile-bottom-nav-item,
.mobile-header-menu-btn {
    -webkit-tap-highlight-color: rgba(0, 123, 255, 0.1);
    user-select: none;
    -webkit-user-select: none;
}

/* Ripple effect on tap */
.mobile-bottom-nav-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: none;
}

.mobile-bottom-nav-item:active::after {
    width: 100px;
    height: 100px;
}

