/* Mobile Bottom Navigation Styles */
.mobile-bottom-nav {
    display: none; /* Hidden by default, shown only on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

.mobile-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    max-width: 100vw;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6b7280;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 4px;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-width: 50px;
    min-height: 50px;
    background: none;
    border: none;
    cursor: pointer;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
    color: #d97706;
    background-color: #fef3c7;
    text-decoration: none;
}

.mobile-nav-item.active {
    color: #d97706;
    background-color: #fef3c7;
}

.mobile-nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

.mobile-nav-item:hover i,
.mobile-nav-item:focus i {
    transform: scale(1.1);
}

.mobile-nav-item span {
    font-size: 10px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

/* Mobile Menu Toggle Button Specific Styles */
.mobile-nav-item.mobile-menu-toggle {
    background: none;
    border: none;
    padding: 6px 4px;
}

.mobile-nav-item.mobile-menu-toggle:hover {
    background-color: #fef3c7;
}

/* Show mobile navigation only on mobile devices */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
    }

    /* Add bottom padding to body to prevent content from being hidden behind the navigation */
    body {
        padding-bottom: 70px;
    }

    /* Adjust container to account for mobile nav */
    .container {
        margin-bottom: 70px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .mobile-nav-item {
        min-width: 45px;
        min-height: 45px;
        padding: 4px 2px;
    }

    .mobile-nav-item i {
        font-size: 18px;
    }

    .mobile-nav-item span {
        font-size: 9px;
    }
}

/* Clean up header navigation for mobile when bottom nav is visible */
@media (max-width: 768px) {
    /* Hide redundant header navigation buttons on mobile */
    .header-actions .mobile-menu-toggle {
        display: none; /* Hidden on mobile - use bottom nav menu instead */
    }

    /* Hide FSP Hub button on mobile - redundant with bottom nav home button */
    .header-actions a[href="index.html"] {
        display: none;
    }

    /* Optionally hide Return Home button too if it's redundant */
    .header-actions a[href="https://foresightproperty.com.au"] {
        display: none;
    }

    /* Clean up header actions container */
    .header-actions {
        display: none; /* Hide entire header actions section on mobile */
    }

    /* Adjust navigation sidebar for mobile bottom nav */
    #sidebarNavigation, #navigation-sidebar {
        bottom: 70px; /* Account for bottom navigation height */
    }

    /* Ensure overlay appears correctly with mobile navigation */
    #navOverlay {
        z-index: 250; /* Below sidebar (300) but above content, consistent with main CSS */
    }

    /* Adjust sidebar to not cover mobile navigation */
    .sidebar-open #sidebarNavigation {
        bottom: 70px;
    }
}

/* ===== HOME VALUE INDICES MOBILE FIXES ===== */
@media (max-width: 768px) {
    /* Fix chart header layout on mobile */
    .chart-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .chart-title-controls {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        width: 100% !important;
        justify-content: flex-start !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-gap: 0.5rem !important;
    }

    /* Fix chart controls layout on mobile */
    .chart-controls {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    /* Make control groups full width on mobile */
    .chart-controls > div {
        width: 100% !important;
        justify-content: space-between !important;
    }

    /* Adjust select dropdowns for mobile */
    .chart-controls .select-dropdown {
        flex: 1 !important;
        max-width: 200px !important;
        min-width: 120px !important;
    }

    /* Enhanced mobile button styling for Show All Cities and Show Events */
    .chart-title-controls button {
        font-size: 0.85rem !important;
        padding: 0.5rem 0.75rem !important;
        white-space: nowrap !important;
        width: 100% !important;
        text-align: center !important;
        border-radius: 0.5rem !important;
        font-weight: 500 !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Increase chart height on mobile for better visibility */
    .chart-container {
        height: 480px !important;
    }
}

@media (max-width: 480px) {
    /* Extra small screens adjustments */
    .chart-header h2 {
        font-size: 1.2rem !important;
        margin: 0 !important;
    }

    .chart-controls label {
        font-size: 0.85rem !important;
        margin-right: 0.25rem !important;
    }

    .chart-controls .select-dropdown {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    .chart-title-controls button {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.6rem !important;
        min-height: 40px !important;
    }

    /* Maintain good chart height on very small screens */
    .chart-container {
        height: 380px !important;
    }
}

/* Active page highlighting */
body[data-page="suburb-selection"] .mobile-nav-item[data-page="suburb-selection"],
body[data-page="calculator"] .mobile-nav-item[data-page="calculator"],
body[data-page="home"] .mobile-nav-item[data-page="home"],
body[data-page="market"] .mobile-nav-item[data-page="market"] {
    color: #d97706;
    background-color: #fef3c7;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: #1f2937;
        border-top-color: #374151;
    }

    .mobile-nav-item {
        color: #9ca3af;
    }

    .mobile-nav-item:hover,
    .mobile-nav-item:focus,
    .mobile-nav-item.active {
        color: #f59e0b;
        background-color: #1f2937;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .mobile-nav-item,
    .mobile-nav-item i {
        transition: none;
    }
}

/* Focus styles for keyboard navigation */
.mobile-nav-item:focus {
    outline: 2px solid #d97706;
    outline-offset: 2px;
}

/* Touch target improvements */
@media (pointer: coarse) {
    .mobile-nav-item {
        min-height: 48px;
        min-width: 48px;
    }
}