/**
 * Alpine Mobile Footer Menu - Namespaced Bottom Navigation
 * Completely isolated from theme conflicts
 * Cross-browser compatible with fallbacks
 * 
 * @package Alpine_Mobile_Footer_Menu
 * @since 1.0.0
 */

/* CSS Reset for cross-browser compatibility */
* {
    box-sizing: border-box;
}

/* Fallback for browsers that don't support CSS custom properties */
:root {
    --alpine-mobile-footer-menu-bg-color: #305e00;
    --alpine-mobile-footer-menu-text-color: #ffffff;
    --alpine-mobile-footer-menu-font-size: 12px;
    --alpine-mobile-footer-menu-height: 60px;
    --alpine-mobile-footer-menu-opacity: 1;
    --alpine-mobile-footer-menu-z-index: 999;
    --alpine-mobile-footer-menu-text-transform: none;
    --alpine-mobile-footer-menu-hover-color: #007AFF;
}

/* Body bottom padding to prevent content from being hidden behind fixed menu */
body {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;
    -moz-box-sizing: border-box !important;
    -ms-box-sizing: border-box !important;
}

/* Ensure body padding is applied with maximum specificity */
html body {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Additional safety for themes that might override body padding */
body.alpine-mobile-footer-menu-active {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Maximum specificity to override theme styles */
html body.alpine-mobile-footer-menu-active {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Force body padding when menu is present - highest specificity */
html body:has(#alpine-mobile-footer-menu-wrapper) {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Override WordPress theme body padding with maximum specificity */
html body[class*="wp-theme"] {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Additional override for Flatsome theme */
html body.wp-theme-flatsome {
    padding-bottom: 60px !important;
    /* Fallback for older browsers */
    padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
}

/* Fallback for browsers that don't support :has() */
html body #alpine-mobile-footer-menu-wrapper~* {
    /* This will be overridden by the body padding, but ensures content is visible */
}

/* Alpine Mobile Footer Menu - Completely isolated wrapper */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    /* Z-index with fallback */
    z-index: 999 !important;
    /* Fallback for older browsers */
    z-index: var(--alpine-mobile-footer-menu-z-index, 999) !important;

    /* Background with multiple fallbacks */
    background-color: #305e00 !important;
    /* Fallback for older browsers */
    background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    background: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    /* Fallback for Safari */
    -webkit-background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    /* Safari specific */
    -moz-background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    /* Firefox */
    -ms-background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    /* IE/Edge */

    /* Border and shadow with vendor prefixes */
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    -webkit-box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    /* Safari/Chrome */
    -moz-box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    /* Firefox */

    /* Flexbox with fallbacks */
    display: -webkit-box !important;
    /* Safari 6-8 */
    display: -webkit-flex !important;
    /* Safari 9+ */
    display: -moz-box !important;
    /* Firefox 19-27 */
    display: -ms-flexbox !important;
    /* IE 10 */
    display: flex !important;
    /* Modern browsers */

    /* Flexbox properties with vendor prefixes */
    -webkit-box-pack: justify !important;
    /* Safari 6-8 */
    -webkit-justify-content: space-around !important;
    /* Safari 9+ */
    -moz-box-pack: justify !important;
    /* Firefox 19-27 */
    -ms-flex-pack: justify !important;
    /* IE 10 */
    justify-content: space-around !important;
    /* Modern browsers */

    -webkit-box-align: center !important;
    /* Safari 6-8 */
    -webkit-align-items: center !important;
    /* Safari 9+ */
    -moz-box-align: center !important;
    /* Firefox 19-27 */
    -ms-flex-align: center !important;
    /* IE 10 */
    align-items: center !important;
    /* Modern browsers */
    /* Sizing with fallbacks */
    padding: 8px 0 !important;
    height: 60px !important;
    /* Fallback for older browsers */
    height: var(--alpine-mobile-footer-menu-height, 60px) !important;
    min-height: 60px !important;
    /* Fallback for older browsers */
    min-height: var(--alpine-mobile-footer-menu-height, 60px) !important;
    width: 100% !important;

    /* Visibility and opacity with fallbacks */
    visibility: visible !important;
    opacity: 1 !important;
    /* Fallback for older browsers */
    opacity: var(--alpine-mobile-footer-menu-opacity, 1) !important;

    /* Typography with fallbacks */
    margin: 0 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    /* Fallback */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;

    /* Hardware acceleration and performance with vendor prefixes */
    -webkit-backface-visibility: hidden !important;
    -webkit-transform: translateZ(0) !important;
    -moz-transform: translateZ(0) !important;
    -ms-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    will-change: background-color !important;

    /* Additional cross-browser fixes */
    -webkit-tap-highlight-color: transparent !important;
    /* Remove tap highlight on mobile */
    -webkit-touch-callout: none !important;
    /* Disable callout on iOS */
    -webkit-user-select: none !important;
    /* Disable text selection */
    -moz-user-select: none !important;
    /* Firefox */
    -ms-user-select: none !important;
    /* IE/Edge */
    user-select: none !important;
    /* Modern browsers */
}

/* Alpine Mobile Footer Menu - Force show on all screen sizes */
@media (min-width: 769px) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Alpine Mobile Footer Menu - Navigation links */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    color: var(--alpine-mobile-footer-menu-text-color, #ffffff) !important;
    /* Font size moved to label */
    font-weight: 500 !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
    min-width: 60px !important;
    text-align: center !important;
    position: relative !important;
    background: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em !important;
}

/* Icon styling */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-icon {
    display: block !important;
    margin-bottom: 4px !important;
    font-size: 20px !important;
    line-height: 1 !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-icon-image {
    width: 20px !important;
    height: 20px !important;
    margin-bottom: 4px !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-icon-svg {
    width: 20px !important;
    height: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 4px !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-icon-svg svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
    stroke: currentColor !important;
    color: inherit !important;
}

/* Label styling */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-label {
    font-size: var(--alpine-mobile-footer-menu-font-size, 12px) !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    text-transform: var(--alpine-mobile-footer-menu-text-transform, none) !important;
    color: var(--alpine-mobile-footer-menu-text-color, #ffffff) !important;
    -webkit-text-fill-color: var(--alpine-mobile-footer-menu-text-color, #ffffff) !important;
    /* Safari text color fix */
}

/* Alpine Mobile Footer Menu - Active state */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-active {
    color: var(--alpine-mobile-footer-menu-hover-color) !important;
    background-color: rgba(0, 122, 255, 0.1) !important;
}

/* Alpine Mobile Footer Menu - Hover state */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover {
    /* Text color using custom properties */
    color: var(--alpine-mobile-footer-menu-hover-color) !important;
    -webkit-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    /* Safari hover text fix */
    -moz-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    /* Firefox */
    -ms-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    /* IE/Edge */

    /* Background with multiple fallbacks */
    background-color: rgba(0, 122, 255, 0.05) !important;
    /* Fallback for older browsers */
    background: rgba(0, 122, 255, 0.05) !important;
    /* Safari background fallback */
    -webkit-background-color: rgba(0, 122, 255, 0.05) !important;
    /* Safari specific */
    -moz-background-color: rgba(0, 122, 255, 0.05) !important;
    /* Firefox */
    -ms-background-color: rgba(0, 122, 255, 0.05) !important;
    /* IE/Edge */

    /* Transform with vendor prefixes */
    -webkit-transform: translateY(-1px) !important;
    /* Safari/Chrome */
    -moz-transform: translateY(-1px) !important;
    /* Firefox */
    -ms-transform: translateY(-1px) !important;
    /* IE/Edge */
    transform: translateY(-1px) !important;
    /* Modern browsers */

    /* Transition for smooth animation */
    -webkit-transition: all 0.2s ease !important;
    /* Safari/Chrome */
    -moz-transition: all 0.2s ease !important;
    /* Firefox */
    -ms-transition: all 0.2s ease !important;
    /* IE/Edge */
    transition: all 0.2s ease !important;
    /* Modern browsers */
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover .alpine-mobile-footer-menu-label {
    color: var(--alpine-mobile-footer-menu-hover-color) !important;
    -webkit-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    -moz-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    -ms-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover .alpine-mobile-footer-menu-icon-svg {
    color: var(--alpine-mobile-footer-menu-hover-color) !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover .alpine-mobile-footer-menu-icon-svg svg {
    fill: var(--alpine-mobile-footer-menu-hover-color) !important;
    stroke: var(--alpine-mobile-footer-menu-hover-color) !important;
    color: var(--alpine-mobile-footer-menu-hover-color) !important;
}

/* Alpine Mobile Footer Menu - Active indicator */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-active::before {
    content: '' !important;
    position: absolute !important;
    top: -8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 4px !important;
    height: 4px !important;
    background-color: var(--alpine-mobile-footer-menu-hover-color) !important;
    border-radius: 50% !important;
}

/* Safari Mobile Color Rendering Fix */
@supports (-webkit-touch-callout: none) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
        background: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
        -webkit-background-color: var(--alpine-mobile-footer-menu-bg-color, #305e00) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-label {
        color: var(--alpine-mobile-footer-menu-text-color, #ffffff) !important;
        -webkit-text-fill-color: var(--alpine-mobile-footer-menu-text-color, #ffffff) !important;
    }
}

/* Alpine Mobile Footer Menu - Responsive adjustments */
@media (max-width: 480px) {

    /* Adjust body padding for smaller screens */
    body {
        padding-bottom: 60px !important;
        /* Fallback for older browsers */
        padding-bottom: var(--alpine-mobile-footer-menu-height, 60px) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        padding: 6px 0 !important;
        height: var(--alpine-mobile-footer-menu-height, 60px) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        font-size: 11px !important;
        padding: 6px 8px !important;
        min-width: 50px !important;
    }
}

@media (max-width: 360px) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        font-size: 10px !important;
        padding: 5px 6px !important;
        min-width: 45px !important;
    }
}

/* Alpine Mobile Footer Menu - Dark mode support */
@media (prefers-color-scheme: dark) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        background-color: #1c1c1e !important;
        border-top-color: #38383a !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        color: #8e8e93 !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-active {
        color: #0a84ff !important;
        background-color: rgba(10, 132, 255, 0.1) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover {
        color: var(--alpine-mobile-footer-menu-hover-color) !important;
        -webkit-text-fill-color: var(--alpine-mobile-footer-menu-hover-color) !important;
        background-color: rgba(0, 122, 255, 0.05) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-active::before {
        background-color: #0a84ff !important;
    }
}

/* Internet Explorer and Edge Legacy Support */
@media screen and (-ms-high-contrast: active),
(-ms-high-contrast: none) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        display: -ms-flexbox !important;
        -ms-flex-pack: justify !important;
        -ms-flex-align: center !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        display: -ms-flexbox !important;
        -ms-flex-direction: column !important;
        -ms-flex-align: center !important;
        -ms-flex-pack: center !important;
    }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        -moz-box-sizing: border-box !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        -moz-box-sizing: border-box !important;
    }
}

/* Chrome/WebKit specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
}

/* Print styles - hide menu when printing */
@media print {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        display: none !important;
    }
}

/* Touch states for mobile devices */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-touch {
    -webkit-transform: scale(0.95) !important;
    -moz-transform: scale(0.95) !important;
    -ms-transform: scale(0.95) !important;
    transform: scale(0.95) !important;
    opacity: 0.8 !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container,
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link,
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover {
        -webkit-transition: none !important;
        -moz-transition: none !important;
        -ms-transition: none !important;
        transition: none !important;
        -webkit-transform: none !important;
        -moz-transform: none !important;
        -ms-transform: none !important;
        transform: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        border-top: 2px solid !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link {
        border: 1px solid transparent !important;
    }

    body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link:hover {
        border-color: currentColor !important;
    }
}

/* Scroll behavior animations */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container.alpine-mobile-footer-menu-scroll-enabled {
    transition: transform 0.3s ease-in-out !important;
}

body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container.alpine-mobile-footer-menu-hidden {
    transform: translateY(100%) !important;
}

/* Click animation */
body #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container .alpine-mobile-footer-menu-link.alpine-mobile-footer-menu-clicked {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* Mobile-only display control via CSS media queries */
/* When mobile-only is enabled, hide on desktop screens */
@media screen and (min-width: 769px) {
    body.mobile-footer-menu-mobile-only #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* When mobile-only is enabled, show on mobile screens */
@media screen and (max-width: 768px) {
    body.mobile-footer-menu-mobile-only #alpine-mobile-footer-menu-wrapper.alpine-mobile-footer-menu-container {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}