/* ============================================================================
   PWA MOBILE ENHANCEMENTS
   Complete mobile optimization for seamless phone/desktop experience
   ============================================================================ */

/* ── CSS Variables for Mobile ────────────────────────────────────────── */
:root {
    --mobile-touch-target: 48px;  /* Minimum touch target per Apple HIG */
    --mobile-padding: 1rem;
    --mobile-font-base: 16px;     /* Prevent iOS zoom on inputs */
    --mobile-font-small: 14px;
    --mobile-font-large: 18px;
    --mobile-safe-bottom: env(safe-area-inset-bottom);
}

/* ── Base Mobile Styles ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    body, html {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Base font size for mobile readability */
    body {
        font-size: var(--mobile-font-base);
    }

    /* Increase app container padding for comfortable touch */
    .app-container {
        padding: 0.75rem;
        padding-bottom: calc(80px + var(--mobile-safe-bottom));
    }

    /* Make page content full width on mobile */
    #page-content {
        max-width: 100%;
        padding: 0;
    }
}

/* ── Fitness Timetable Mobile Optimizations ─────────────────────────── */
@media (max-width: 768px) {
    /* Timetable container */
    #timetable-container {
        margin: 0 -0.5rem;
        padding: 0;
    }

    /* Make table scrollable on very small screens */
    .timetable-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Book buttons - ensure touch targets are large enough */
    .book-class-btn {
        min-height: 44px !important;
        min-width: 70px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Sticky table header on mobile */
    #timetable-container thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Row tap feedback */
    .class-row:active {
        background: rgba(200,160,60, 0.15) !important;
    }
}

/* Very small screens (iPhone SE, small Android) */
@media (max-width: 375px) {
    .book-class-btn {
        min-width: 60px !important;
        font-size: 0.65rem !important;
        padding: 0.5rem 0.625rem !important;
    }

    /* Reduce padding on very small screens */
    #timetable-container td,
    #timetable-container th {
        padding: 0.625rem 0.375rem !important;
    }
}

/* ── Enhanced Bottom Navigation ─────────────────────────────────────── */
@media (max-width: 768px) {
    .bottom-nav {
        height: auto;
        min-height: calc(60px + var(--mobile-safe-bottom));
        padding: 0.5rem 0;
        padding-bottom: calc(0.5rem + var(--mobile-safe-bottom));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }

    .nav-item {
        min-height: var(--mobile-touch-target);
        min-width: var(--mobile-touch-target);
        padding: 0.5rem 0.25rem;
        gap: 4px;
    }

    .nav-item svg {
        width: 24px;
        height: 24px;
    }

    .nav-label {
        font-size: 0.625rem;
        font-weight: 600;
    }
}

/* ── Header Mobile Optimization ────────────────────────────────────── */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem;
        min-height: 56px;
    }

    .logo-text {
        font-size: 1.35rem;
    }

    .logo-mark {
        width: 36px;
        height: 36px;
        font-size: 1.35rem;
    }

    /* Make header actions touch-friendly */
    .header-actions {
        gap: 0.75rem;
    }

    .header-icon-btn {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        padding: 12px;
    }

    .profile-avatar {
        width: 40px;
        height: 40px;
    }
}

/* ── Modal Full-Screen Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal-header {
        padding: 1rem 1.25rem;
        min-height: 56px;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal-close {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        font-size: 1.75rem;
    }

    .modal-body {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Food modal specific */
    .food-modal-content {
        max-height: 100vh;
        height: 100vh;
    }
}

/* ── Forms and Inputs Mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
    /* Prevent iOS zoom on focus */
    input, textarea, select {
        font-size: var(--mobile-font-base) !important;
    }

    /* Touch-friendly input fields */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    textarea,
    select {
        min-height: var(--mobile-touch-target);
        padding: 0.75rem 1rem;
        font-size: var(--mobile-font-base);
    }

    /* Touch-friendly buttons */
    button, .btn, .page-header-btn {
        min-height: var(--mobile-touch-target);
        padding: 0.75rem 1.25rem;
        font-size: var(--mobile-font-base);
    }

    /* Smaller buttons still need minimum touch target */
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 1rem;
    }
}

/* ── Cards and Grid Mobile Layout ──────────────────────────────────── */
@media (max-width: 768px) {
    /* Make all grids single column on mobile */
    .summary-grid,
    .nut-meals-grid,
    .dashboard-grid,
    .pathway-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Card padding reduction for mobile */
    .summary-card,
    .dashboard-card {
        padding: 1.25rem;
    }

    /* Nutrition meal columns full width */
    .nut-meal-col {
        min-width: 100%;
    }
}

/* ── Dashboard Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .db-quick-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .db-log-btn {
        width: 100%;
        min-height: 56px;
        font-size: 0.9rem;
    }

    .db-stat-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .db-stat-card {
        padding: 1rem;
    }

    .db-stat-value {
        font-size: 1.75rem;
    }
}

/* ── Nutrition Page Mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .nutrition-page {
        padding: 0;
    }

    .page-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .page-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .nut-header-search {
        flex: 1;
    }

    .nut-dash-overview {
        flex-direction: column;
        gap: 1rem;
    }

    .nut-dash-cal {
        width: 100%;
    }

    .nut-water-btn2 {
        width: 100%;
        justify-content: space-between;
    }

    /* Make add buttons larger for touch */
    .nut-add-btn {
        width: var(--mobile-touch-target);
        height: var(--mobile-touch-target);
        font-size: 1.5rem;
    }

    /* Meal items more spacious */
    .nut-meal-item {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .nut-item-del {
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
    }
}

/* ── Workout/Training Page Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
    .my-programme-card {
        padding: 1.25rem;
    }

    .prog-start-btn,
    .begin-session-btn {
        min-height: 56px;
        font-size: 1rem;
        padding: 1rem 1.5rem;
    }

    .prog-card {
        padding: 1.25rem;
    }

    .pathway-panel {
        padding: 1.25rem;
    }
}

/* ── Community/Channel Page Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
    .community-container {
        flex-direction: column;
    }

    .channels-sidebar {
        width: 100%;
        max-width: 100%;
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .channel-content {
        width: 100%;
        margin-left: 0;
    }

    /* Make channel list horizontal scroll on mobile */
    .channels-list {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .channel-item {
        flex-shrink: 0;
        min-width: 120px;
    }

    /* Message input more spacious */
    .message-input-wrapper {
        padding: 1rem;
        gap: 0.75rem;
    }

    .message-input {
        min-height: 44px;
        font-size: var(--mobile-font-base);
    }

    .message-send-btn {
        width: 44px;
        height: 44px;
    }
}

/* ── Profile Page Mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .profile-avatar-large {
        margin: 0 auto;
    }

    .profile-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .profile-btn {
        width: 100%;
        justify-content: center;
    }

    .profile-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

/* ── Admin Pages Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 1rem;
    }

    .admin-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-tab {
        flex-shrink: 0;
        min-width: 120px;
    }

    /* Tables become card-based on mobile */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px; /* Ensure table doesn't collapse too much */
    }
}

/* ── Touch Feedback ────────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    /* Add touch feedback for all interactive elements */
    button:active,
    .btn:active,
    .nav-item:active,
    .channel-item:active {
        transform: scale(0.97);
        opacity: 0.8;
    }

    /* Remove hover states on touch devices */
    button:hover,
    .btn:hover,
    .nav-item:hover {
        transform: none;
        opacity: 1;
    }
}

/* ── Landscape Mobile (Phones Rotated) ─────────────────────────────── */
@media (max-width: 896px) and (orientation: landscape) {
    .bottom-nav {
        display: none; /* Hide bottom nav in landscape to save space */
    }

    .app-container {
        padding-bottom: 1rem;
    }

    /* Show desktop nav in landscape */
    .app-nav {
        display: flex !important;
    }
}

/* ── Tablet Optimization (769px - 1024px) ──────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .app-container {
        max-width: 100%;
        padding: 1.5rem;
    }

    /* 2-column grids on tablet */
    .summary-grid,
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hide bottom nav on tablet */
    .bottom-nav {
        display: none !important;
    }
}

/* ── Safe Area Insets (iPhone Notch, etc.) ─────────────────────────── */
@supports (padding: max(0px)) {
    .app-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    .app-container {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
}

/* ── Accessibility Enhancements ────────────────────────────────────── */
@media (max-width: 768px) {
    /* Increase focus indicators for keyboard navigation */
    button:focus-visible,
    a:focus-visible,
    input:focus-visible {
        outline: 3px solid var(--crimson);
        outline-offset: 2px;
    }

    /* Ensure text is readable */
    p, li, span {
        line-height: 1.6;
    }

    /* Prevent text from being too small */
    small {
        font-size: 0.875rem;
        min-font-size: 12px;
    }
}

/* ── Loading States Mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .loading-overlay {
        backdrop-filter: blur(4px);
    }

    .loading-spinner {
        width: 48px;
        height: 48px;
    }
}

/* ── Toasts and Notifications Mobile ───────────────────────────────── */
@media (max-width: 768px) {
    .toast {
        width: 100%;
        max-width: 400px;
        /* Position + centering are owned by .toast-container (a centered, fixed
           flex column). The toast is a STATIC flex child, so it must NOT be
           re-positioned with left/transform/bottom here — doing so shifts it
           half its width off-screen (the "notification bleeding out" bug). */
    }
}

/* ── REHAB Section Mobile Enhancements ─────────────────────────────── */
@media (max-width: 768px) {
    /* Programme detail modal full screen */
    .prog-detail-modal {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .prog-detail-modal .modal-body {
        max-height: calc(100vh - 140px); /* Account for header + actions */
    }

    /* Programme overview stats single column on small screens */
    .prog-detail-meta {
        grid-template-columns: 1fr 1fr; /* 2 columns on mobile */
        gap: 0.625rem;
    }

    /* Phase week headers touch-friendly */
    .prog-detail-week-header {
        padding: 0.75rem 1rem;
        min-height: var(--mobile-touch-target);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .prog-detail-week-header:active {
        background: rgba(255,255,255,0.08);
    }

    /* Phase content readable font sizes */
    .prog-detail-phase-content {
        padding: 1rem;
    }

    .prog-detail-phase-content li {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }

    /* Exercise list items more spacious */
    .prog-detail-exercise {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .prog-detail-ex-name {
        font-size: 0.95rem;
    }

    .prog-detail-ex-meta {
        font-size: 0.85rem;
    }

    /* Section headers readable */
    .prog-detail-phase-content > div > div:first-child {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Action buttons full width on mobile */
    .prog-detail-actions {
        padding: 1rem;
    }

    .prog-detail-actions .qa-save-btn {
        width: 100%;
        min-height: 56px;
        font-size: 1rem;
    }
}

/* ── REHAB Cards Mobile (480px for very small phones) ──────────────── */
@media (max-width: 480px) {
    /* Programme cards single column on very small screens */
    .prog-card-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stats grid single column */
    .prog-detail-meta {
        grid-template-columns: 1fr;
    }

    /* Reduce padding on phase content for small screens */
    .prog-detail-phase-content {
        padding: 0.75rem;
    }

    /* Smaller badges and counts */
    .prog-detail-phase-content span[style*="font-size: 0.75rem"] {
        font-size: 0.7rem !important;
    }
}

/* ============================================================================
   iOS SPECIFIC OPTIMIZATIONS (iPhone, iPad)
   ============================================================================ */

/* iOS notch/home indicator safe areas */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .app-container {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, calc(80px + env(safe-area-inset-bottom)));
    }

    .bottom-nav {
        padding-bottom: max(0.5rem, calc(0.5rem + env(safe-area-inset-bottom)));
    }

    /* Prevent content from going under iOS status bar */
    .page-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Prevent iOS from zooming on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }

    /* Remove iOS tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Smooth scrolling for iOS */
    .app-container,
    #page-content,
    .timetable-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    /* Fix iOS button appearance */
    button {
        -webkit-appearance: none;
        appearance: none;
    }

    /* Prevent text selection on buttons for iOS */
    button, .nav-item, .book-class-btn {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ============================================================================
   ANDROID SPECIFIC OPTIMIZATIONS
   ============================================================================ */

/* Android Chrome address bar height compensation */
@media screen and (max-width: 768px) {
    .app-container {
        min-height: calc(100vh - 56px); /* Chrome address bar height */
        min-height: calc(100dvh - 56px); /* Dynamic viewport height */
    }
}

/* Android Material Design ripple effect simulation */
@media (max-width: 768px) {
    .book-class-btn:active,
    .nav-item:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ============================================================================
   PULL-TO-REFRESH SUPPORT
   ============================================================================ */

/* Disable browser's default pull-to-refresh */
body {
    overscroll-behavior-y: contain;
}

/* Custom pull-to-refresh indicator */
.ptr-element {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, top 0.2s;
}

.ptr-element.ptr-refresh {
    opacity: 1;
    top: 20px;
}

/* Loading spinner for pull-to-refresh */
.ptr-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(200,160,60, 0.2);
    border-top-color: #c8a03c;
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   LANDSCAPE MODE OPTIMIZATIONS
   ============================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .app-container {
        padding-top: 0.5rem;
        padding-bottom: calc(60px + var(--mobile-safe-bottom));
    }

    /* Make bottom nav more compact in landscape */
    .bottom-nav {
        min-height: calc(50px + var(--mobile-safe-bottom));
        padding: 0.25rem 0;
    }

    /* Compact timetable rows in landscape */
    #timetable-container td,
    #timetable-container th {
        padding: 0.5rem 0.375rem !important;
    }
}

/* ============================================================================
   HIGH DPI / RETINA DISPLAY OPTIMIZATIONS
   ============================================================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders for retina displays */
    .book-class-btn,
    .nav-item,
    #timetable-container {
        border-width: 0.5px;
    }

    /* Crisper text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}


/* ============================================================================
   8-TAB MOBILE NAVIGATION FIX
   Allows horizontal scrolling for all tabs to fit on mobile screens
   ============================================================================ */

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
        gap: 0.5rem;
        min-height: calc(60px + env(safe-area-inset-bottom));
        background: var(--pioneer-navy, #0f1419);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Hide scrollbar but keep functionality */
    .bottom-nav::-webkit-scrollbar {
        display: none;
    }

    .bottom-nav {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .nav-item {
        flex: 0 0 auto;
        min-width: 72px;
        max-width: 90px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0.5rem 0.75rem;
        scroll-snap-align: start;
        transition: all 0.2s ease;
    }

    .nav-item.active {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 12px;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .nav-label {
        font-size: 0.625rem;
        font-weight: 600;
        white-space: nowrap;
        text-align: center;
    }

    /* Community badge positioning */
    .nav-community-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        background: #FF3B30;
        color: white;
        font-size: 0.6rem;
        padding: 2px 5px;
        border-radius: 10px;
        min-width: 16px;
        text-align: center;
        font-weight: 700;
    }
}

/* Horizontal scroll indicator (optional - shows there are more tabs) */
@media (max-width: 768px) {
    .bottom-nav::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to left, rgba(15, 20, 25, 0.95), transparent);
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.3s;
    }

    /* Hide gradient when scrolled to end */
    .bottom-nav.scrolled-end::after {
        opacity: 0;
    }


/* ============================================================================
   MOBILE BOTTOM NAVIGATION - CONSOLIDATED (8 TABS)
   This rule must come LAST to override all previous .bottom-nav styles
   ============================================================================ */

@media (max-width: 768px) {
    .bottom-nav {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex !important;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom)) !important;
        gap: 0.5rem;
        min-height: calc(60px + env(safe-area-inset-bottom)) !important;
        background: var(--pioneer-navy, #0f1419) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 100;
    }

    /* Hide scrollbar but keep functionality */
    .bottom-nav::-webkit-scrollbar {
        display: none;
    }

    .bottom-nav {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .nav-item {
        flex: 0 0 auto !important;
        min-width: 72px !important;
        max-width: 90px;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0.5rem 0.75rem !important;
        scroll-snap-align: start;
        transition: all 0.2s ease;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.7);
    }

    .nav-item.active {
        background: rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px;
        color: white;
    }

    .nav-item svg {
        width: 22px !important;
        height: 22px !important;
        flex-shrink: 0;
    }

    .nav-label {
        font-size: 0.625rem !important;
        font-weight: 600 !important;
        white-space: nowrap;
        text-align: center;
    }

    /* Community badge positioning */
    .nav-community-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        background: #FF3B30;
        color: white;
        font-size: 0.6rem;
        padding: 2px 5px;
        border-radius: 10px;
        min-width: 16px;
        text-align: center;
        font-weight: 700;
    }
}



/* ============================================================================
   MOBILE BOTTOM NAVIGATION - CONSOLIDATED (8 TABS)
   This rule must come LAST to override all previous .bottom-nav styles
   ============================================================================ */

@media (max-width: 768px) {
    .bottom-nav {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex !important;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom)) !important;
        gap: 0.5rem;
        min-height: calc(60px + env(safe-area-inset-bottom)) !important;
        background: var(--pioneer-navy, #0f1419) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 100;
    }

    /* Hide scrollbar but keep functionality */
    .bottom-nav::-webkit-scrollbar {
        display: none;
    }

    .bottom-nav {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .nav-item {
        flex: 0 0 auto !important;
        min-width: 72px !important;
        max-width: 90px;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0.5rem 0.75rem !important;
        scroll-snap-align: start;
        transition: all 0.2s ease;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.7);
    }

    .nav-item.active {
        background: rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px;
        color: white;
    }

    .nav-item svg {
        width: 22px !important;
        height: 22px !important;
        flex-shrink: 0;
    }

    .nav-label {
        font-size: 0.625rem !important;
        font-weight: 600 !important;
        white-space: nowrap;
        text-align: center;
    }

    /* Community badge positioning */
    .nav-community-badge {
        position: absolute;
        top: -4px;
        right: -8px;
        background: #FF3B30;
        color: white;
        font-size: 0.6rem;
        padding: 2px 5px;
        border-radius: 10px;
        min-width: 16px;
        text-align: center;
        font-weight: 700;
    }
}

}
