/* =====================================================================
   MealWeek Navigation Styles
   Version: 1.1.0

   Modern adaptive navigation following Choosy-inspired design patterns.
   - Bottom Tab Bar for Mobile (Thumb Zone optimized)
   - Top Navigation Bar for Desktop
   ===================================================================== */


/* =====================================================================
   0. CSS VARIABLES FOR NAVIGATION
   ===================================================================== */

:root {
    /* Bottom navigation height - used consistently across all calculations */
    --mw-bottom-nav-height: 64px;
    /* Extra padding buffer for content above bottom nav */
    --mw-bottom-nav-content-buffer: 24px;
}


/* =====================================================================
   1. BOTTOM TAB BAR (Mobile)
   ===================================================================== */

.mw-bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mw-bottom-nav-height);
    background: var(--mw-color-surface);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: var(--mw-z-fixed);
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid var(--mw-color-border-light);
}

/* Dark mode */
.mud-theme-dark .mw-bottom-tab-bar {
    background: var(--mw-color-surface);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.24);
    border-top-color: var(--mw-color-border);
}

/* Tab Item */
.mw-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 64px;
    max-width: 96px;
    height: 100%;
    padding: var(--mw-spacing-1) var(--mw-spacing-2);
    color: var(--mw-color-text-secondary);
    text-decoration: none;
    transition: color var(--mw-transition-fast), transform var(--mw-transition-fast);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.mw-tab-item:hover {
    color: var(--mw-color-primary);
}

.mw-tab-item.active {
    color: var(--mw-color-primary);
}

/* Icon wrapper for potential indicator */
.mw-tab-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 32px;
    border-radius: 16px;
    transition: background-color var(--mw-transition-default);
}

.mw-tab-item.active .mw-tab-icon-wrapper {
    background-color: var(--mw-color-primary-pale);
}

.mud-theme-dark .mw-tab-item.active .mw-tab-icon-wrapper {
    background-color: rgba(38, 166, 154, 0.16);
}

/* Tab Icon */
.mw-tab-icon {
    font-size: 24px !important;
    transition: transform var(--mw-transition-fast);
}

.mw-tab-item.active .mw-tab-icon {
    color: var(--mw-color-primary) !important;
}

/* Tab Label */
.mw-tab-label {
    font-size: 11px;
    font-weight: var(--mw-font-weight-medium);
    margin-top: 2px;
    letter-spacing: 0.2px;
    transition: font-weight var(--mw-transition-fast);
}

.mw-tab-item.active .mw-tab-label {
    font-weight: var(--mw-font-weight-semibold);
}

/* Active indicator animation */
.mw-tab-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background-color: var(--mw-color-primary);
    border-radius: 0 0 3px 3px;
}

/* Hide bottom nav on desktop */
@media (min-width: 992px) {
    .mw-bottom-tab-bar {
        display: none;
    }
}


/* =====================================================================
   2. TOP NAVIGATION BAR (Desktop)
   ===================================================================== */

.mw-top-nav-bar {
    background: var(--mw-color-primary) !important;
    padding: 0 var(--mw-spacing-5);
}

.mud-theme-dark .mw-top-nav-bar {
    background: var(--mw-color-surface) !important;
    border-bottom: 1px solid var(--mw-color-border);
}

/* Brand/Logo */
.mw-nav-brand {
    display: flex;
    align-items: center;
}

.mw-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.mw-nav-logo {
    height: 32px;
    width: auto;
}

/* Navigation Links Container */
.mw-nav-links {
    display: flex;
    align-items: center;
    gap: var(--mw-spacing-1);
    height: 100%;
}

/* Individual Nav Link */
.mw-nav-link {
    display: flex;
    align-items: center;
    gap: var(--mw-spacing-2);
    padding: var(--mw-spacing-2) var(--mw-spacing-3);
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: var(--mw-font-size-body);
    font-weight: var(--mw-font-weight-medium);
    border-radius: var(--mw-radius-md);
    transition: background-color var(--mw-transition-fast), color var(--mw-transition-fast);
    white-space: nowrap;
}

.mw-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
}

.mw-nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    font-weight: var(--mw-font-weight-semibold);
}

.mw-nav-link-icon {
    color: inherit !important;
}

/* Dark mode nav links */
.mud-theme-dark .mw-nav-link {
    color: var(--mw-color-text-secondary);
}

.mud-theme-dark .mw-nav-link:hover {
    background-color: var(--mw-color-hover);
    color: var(--mw-color-text-primary);
}

.mud-theme-dark .mw-nav-link.active {
    background-color: var(--mw-color-selected);
    color: var(--mw-color-primary);
}

/* Nav Actions (right side) */
.mw-nav-actions {
    display: flex;
    align-items: center;
    gap: var(--mw-spacing-2);
}

/* User Menu Button */
.mw-user-menu-btn {
    text-transform: none !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

.mw-user-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.mud-theme-dark .mw-user-menu-btn {
    color: var(--mw-color-text-primary) !important;
}

.mud-theme-dark .mw-user-menu-btn:hover {
    background-color: var(--mw-color-hover) !important;
}

.mw-user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Login Button */
.mw-login-btn {
    font-weight: var(--mw-font-weight-semibold) !important;
}


/* =====================================================================
   3. MOBILE APP BAR
   ===================================================================== */

.mw-mobile-appbar {
    background: var(--mw-color-primary) !important;
}

.mud-theme-dark .mw-mobile-appbar {
    background: var(--mw-color-surface) !important;
    border-bottom: 1px solid var(--mw-color-border);
}


/* =====================================================================
   4. CONTENT AREA ADJUSTMENTS
   ===================================================================== */

/* Content padding for bottom navigation */
.mw-has-bottom-nav {
    /* Calculate: nav height + buffer + safe area for notch/home indicator */
    padding-bottom: calc(var(--mw-bottom-nav-height) + var(--mw-bottom-nav-content-buffer) + env(safe-area-inset-bottom, 0)) !important;
}

@media (min-width: 992px) {
    .mw-has-bottom-nav {
        /* Desktop: No bottom nav, normal padding */
        padding-bottom: var(--mw-spacing-4) !important;
    }
}


/* =====================================================================
   5. SCROLL-TO-TOP BUTTON (Mobile Optimized)
   WI #881: Updated z-index and positioning to avoid FAB conflicts
   ===================================================================== */

/* Override MudScrollToTop positioning for mobile with bottom nav */
.mw-scroll-to-top .mud-fab {
    /* Ensure good touch target size */
    min-width: 48px;
    min-height: 48px;
}

/* Mobile: Position above bottom navigation - LEFT side to avoid FAB conflict */
@media (max-width: 991.98px) {
    .mw-scroll-to-top {
        /* Position above bottom nav with safe area consideration */
        bottom: calc(var(--mw-bottom-nav-height) + var(--mw-bottom-nav-content-buffer) + env(safe-area-inset-bottom, 0)) !important;
        /* Position on LEFT side to avoid overlap with page FABs */
        left: 16px !important;
        right: auto !important;
        z-index: var(--mw-z-scroll-to-top, 1000) !important;
    }
}

/* Desktop: Normal positioning (right side, no FAB conflict) */
@media (min-width: 992px) {
    .mw-scroll-to-top {
        bottom: 32px !important;
        right: 32px !important;
        left: auto !important;
        z-index: var(--mw-z-scroll-to-top, 1000) !important;
    }
}


/* =====================================================================
   6. RESPONSIVE ADJUSTMENTS
   ===================================================================== */

/* Tablet: Adjust spacing */
@media (min-width: 768px) and (max-width: 991.98px) {
    .mw-nav-link span {
        display: none;
    }

    .mw-nav-link {
        padding: var(--mw-spacing-2);
    }

    .mw-nav-link-icon {
        font-size: 24px !important;
    }
}

/* Standard mobile phones (375px - 575px) - Most common sizes */
@media (min-width: 375px) and (max-width: 575.98px) {
    .mw-tab-item {
        min-width: 60px;
        max-width: 80px;
    }

    .mw-tab-label {
        font-size: 11px;
    }

    .mw-tab-icon-wrapper {
        width: 44px;
        height: 30px;
    }
}

/* Small screens: Compact bottom tabs (< 375px) */
@media (max-width: 374.98px) {
    .mw-tab-item {
        min-width: 52px;
        padding: var(--mw-spacing-1) 2px;
    }

    .mw-tab-label {
        font-size: 9px;
    }

    .mw-tab-icon-wrapper {
        width: 36px;
        height: 26px;
    }

    .mw-tab-icon {
        font-size: 20px !important;
    }
}

/* Extra small screens: Very compact (< 320px) */
@media (max-width: 319.98px) {
    .mw-tab-item {
        min-width: 48px;
    }

    .mw-tab-label {
        display: none;
    }

    .mw-bottom-tab-bar {
        height: 56px;
    }
}


/* =====================================================================
   7. ACCESSIBILITY
   ===================================================================== */

/* Focus states for keyboard navigation */
.mw-tab-item:focus-visible,
.mw-nav-link:focus-visible {
    outline: 2px solid var(--mw-color-secondary);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .mw-tab-item,
    .mw-tab-icon,
    .mw-tab-icon-wrapper,
    .mw-nav-link {
        transition: none;
    }
}


/* =====================================================================
   8. ANIMATIONS
   ===================================================================== */

/* Subtle press effect for touch devices */
@media (hover: none) and (pointer: coarse) {
    .mw-tab-item:active {
        transform: scale(0.95);
    }

    .mw-tab-item:active .mw-tab-icon {
        transform: scale(0.9);
    }
}
