/* Bottom Navigation Menu - Mobile App Style */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    min-height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Hide scrollbar on webkit browsers */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.bottom-nav::-webkit-scrollbar {
    display: none; /* Webkit browsers */
}

/* Container for nav items with flex-nowrap to prevent wrapping */
.bottom-nav-container {
    display: flex;
    align-items: center;
    min-width: 100%;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0 8px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    padding: 8px 12px;
    border-radius: 8px;
    min-width: 70px;
    max-width: 90px;
    min-height: 60px; /* Ensure 44px+ touch target */
    position: relative;
    flex-shrink: 0; /* Prevent items from shrinking when scrolling */
    white-space: nowrap;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    justify-content: center;
    touch-action: manipulation; /* Improve touch response */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

.bottom-nav-item:hover {
    text-decoration: none;
    color: #276ef1;
    background: rgba(39, 110, 241, 0.1);
}

.bottom-nav-item.active {
    color: #276ef1;
    background: rgba(39, 110, 241, 0.1);
}

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

.bottom-nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Show on all screen sizes but adjust styling for desktop */
@media (min-width: 768px) {
    .bottom-nav,
    #bottomNav,
    nav.bottom-nav,
    .bottom-nav.guest-nav {
        /* Keep visible but make it more desktop-friendly */
        display: flex !important;
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        width: auto !important;
        max-width: 600px !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15) !important;
        padding: 12px 20px !important;
        background: #ffffff !important;
        border: 1px solid #e0e0e0 !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 9999 !important;
    }
    
    .bottom-nav-container {
        justify-content: center !important;
        gap: 8px !important;
    }
    
    .bottom-nav-item {
        min-width: 80px !important;
        max-width: 100px !important;
        padding: 12px 16px !important;
    }
}

/* Ensure body has bottom padding to account for fixed bottom nav */
body {
    padding-bottom: 80px;
}

@media (min-width: 768px) {
    body {
        padding-bottom: 120px; /* Increased padding for desktop floating nav */
    }
}

/* Hide mobile hamburger menu when bottom nav is present */
@media (max-width: 767px) {
    .mobile-menu-btn {
        display: none !important;
    }
    
    .drawer-menu,
    .drawer-overlay {
        display: none !important;
    }
}

/* Guest user bottom nav - different items */
.bottom-nav.guest-nav .bottom-nav-item[data-auth="user"] {
    display: none;
}

/* Authenticated user bottom nav */
.bottom-nav.user-nav .bottom-nav-item[data-auth="guest"] {
    display: none;
}

/* Special styling for logout button */
.bottom-nav-item.logout-item {
    color: #dc3545;
}

.bottom-nav-item.logout-item:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

/* More menu styling */
.bottom-nav-item.more-item {
    position: relative;
}

.more-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    display: none;
    overflow: hidden;
    margin-bottom: 8px;
}

.more-menu.show {
    display: block;
}

.more-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.more-menu-item:last-child {
    border-bottom: none;
}

.more-menu-item:hover {
    background: #f8f9fa;
    text-decoration: none;
    color: #276ef1;
}

.more-menu-item i {
    margin-right: 12px;
    width: 16px;
    font-size: 14px;
}

.more-menu-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Notification badge */
.bottom-nav-item .notification-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    background: #dc3545;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 1.2;
}

/* Animation for active state */
.bottom-nav-item {
    transform: scale(1);
    transition: transform 0.2s ease, color 0.3s ease, background 0.3s ease;
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

/* Safe area support for devices with notches */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* Scroll indicators */
.bottom-nav::before,
.bottom-nav::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.bottom-nav::before {
    left: 0;
    background: linear-gradient(to right, rgba(255,255,255,0.9), rgba(255,255,255,0));
    opacity: 0;
}

.bottom-nav::after {
    right: 0;
    background: linear-gradient(to left, rgba(255,255,255,0.9), rgba(255,255,255,0));
    opacity: 0;
}

.bottom-nav.can-scroll-left::before {
    opacity: 1;
}

.bottom-nav.can-scroll-right::after {
    opacity: 1;
}

/* Enhanced touch scrolling for mobile */
.bottom-nav {
    -webkit-overflow-scrolling: touch;
}

/* Fade edges when scrollable */
.bottom-nav.scrollable {
    mask: linear-gradient(to right, 
        transparent 0px, 
        black 20px, 
        black calc(100% - 20px), 
        transparent 100%);
    -webkit-mask: linear-gradient(to right, 
        transparent 0px, 
        black 20px, 
        black calc(100% - 20px), 
        transparent 100%);
}

/* Show all items without masking when not scrollable */
.bottom-nav:not(.scrollable) {
    mask: none;
    -webkit-mask: none;
}

/* Improved spacing for smaller screens */
@media (max-width: 360px) {
    .bottom-nav-container {
        gap: 2px;
        padding: 0 4px;
    }
    
    .bottom-nav-item {
        min-width: 55px; /* Maintain adequate touch target */
        max-width: 75px;
        min-height: 56px; /* Maintain 44px+ minimum */
        padding: 6px 8px;
    }
    
    .bottom-nav-label {
        font-size: 10px;
    }
}

/* Enhanced touch targets for larger phones */
@media (min-width: 375px) and (max-width: 480px) {
    .bottom-nav-item {
        min-width: 75px;
        max-width: 95px;
        min-height: 64px;
        padding: 10px 14px;
    }
}

/* Tablet improvements */
@media (min-width: 481px) and (max-width: 767px) {
    .bottom-nav-item {
        min-width: 80px;
        max-width: 100px;
        min-height: 68px;
        padding: 12px 16px;
    }
}