/* ========================================
   Mobile Bottom Navigation Bar
   ======================================== */

/* Hide on desktop */
.mobile-bottom-nav {
    display: none;
}

/* Show on mobile/tablet */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: linear-gradient(180deg, rgba(10, 10, 18, 0.95) 0%, rgba(0, 0, 0, 0.98) 100%);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color, #333);
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: space-around;
        align-items: stretch;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s ease;
    }

    /* Hide nav when keyboard is open (JS adds this class) */
    .mobile-bottom-nav.nav-hidden {
        transform: translateY(100%);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        padding: 6px 0;
        text-decoration: none;
        color: var(--text-secondary, #a0a0a0);
        font-size: 0.65rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        gap: 3px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        position: relative;
        transition: color 0.2s ease;
        border: none;
        background: none;
        min-height: 44px;
    }

    .mobile-nav-item:active {
        opacity: 0.7;
    }

    .mobile-nav-item.active {
        color: var(--text-primary, #fff);
    }

    /* Active indicator dot */
    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--text-primary, #fff);
    }

    .mobile-nav-icon {
        font-size: 1.35rem;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }

    .mobile-nav-item.active .mobile-nav-icon {
        background: rgba(255, 255, 255, 0.08);
    }

    .mobile-nav-label {
        font-size: 0.6rem;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 64px;
    }

    /* Badge for notifications on nav items */
    .mobile-nav-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 20px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.55rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .mobile-nav-badge:empty {
        display: none;
    }

    /* Ensure body content isn't hidden behind the nav */
    body.has-mobile-nav {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    /* Adjust the beta badge position so it doesn't overlap the nav */
    body.has-mobile-nav #betaTestBadge {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Extra small — slightly smaller icons */
@media (max-width: 360px) {
    .mobile-bottom-nav {
        height: calc(54px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-nav-icon {
        font-size: 1.2rem;
        width: 24px;
        height: 24px;
    }

    .mobile-nav-label {
        font-size: 0.55rem;
    }

    body.has-mobile-nav {
        padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    }
}

/* Landscape phones — slimmer bar */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .mobile-bottom-nav {
        height: calc(44px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-nav-icon {
        font-size: 1.1rem;
        width: 22px;
        height: 22px;
    }

    .mobile-nav-label {
        display: none;
    }

    body.has-mobile-nav {
        padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px));
    }
}

/* Touch-friendly */
@media (pointer: coarse) {
    .mobile-nav-item {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mobile-bottom-nav,
    .mobile-nav-item,
    .mobile-nav-icon {
        transition: none !important;
    }
}

/* Hide the old mobile search emoji button when bottom nav is present */
@media (max-width: 768px) {
    body.has-mobile-nav .mobile-search-btn {
        display: none !important;
    }
}
