/**
 * Mobile Bottom Navigation Bar & Sticky Add to Cart
 * Custom mobile enhancements for Radios theme
 */

/* ===================================
   Mobile Header Bar (Top)
   =================================== */
body {
    padding-top: 0px !important;
}
.mobile-header-bar {
    display: none; /* Hidden by default, shown on mobile */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #111111;
    z-index: 1000;
    padding: 12px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-header-bar__container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    max-width: 100%;
}

.mobile-header-bar__left,
.mobile-header-bar__right {
    flex: 0 0 50px;
    display: flex;
    align-items: center;
}

.mobile-header-bar__left {
    justify-content: flex-start;
}

.mobile-header-bar__right {
    justify-content: flex-end;
}

.mobile-header-bar__center {
    flex: 1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mobile-header-bar__center img,
.mobile-header-bar__center .mobile-inverted-logo {
    max-height: 40px;
    width: auto;
    display: block;
}

.mobile-header-bar__center a {
    display: inline-block;
    line-height: 1;
}

.mobile-hamburger a {
    color: #ffffff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-hamburger a:hover {
    color: var(--color-primary, #FF8717);
}

.mobile-login-btn {
    color: #ffffff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-login-btn:hover {
    color: var(--color-primary, #FF8717);
}

/* Show mobile header bar on mobile */
@media only screen and (max-width: 991px) {
    .mobile-header-bar {
        display: block;
    }

    /* Add padding to body for fixed header */
    body {
        padding-top: 64px;
    }

    /* Adjust for sticky add to cart + bottom nav + top header */
    body.single-product {
        padding-top: 64px;
        padding-bottom: 140px;
    }
}

/* ===================================
   Mobile Bottom Navigation Bar
   =================================== */

.mobile-bottom-nav {
    display: none; /* Hidden by default, shown on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    padding: 8px 0;
    border-top: 1px solid #E5E5E5;
}

.mobile-bottom-nav__item {
    flex: 1;
    text-align: center;
}

.mobile-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-bottom-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #121416;
    font-size: 11px;
    padding: 5px 10px;
    position: relative;
    transition: all 0.3s ease;
}

.mobile-bottom-nav__link:hover,
.mobile-bottom-nav__link:focus {
    color: var(--color-primary, #FF8717);
    text-decoration: none;
}

.mobile-bottom-nav__link i {
    font-size: 20px;
    margin-bottom: 4px;
    display: block;
}

.mobile-bottom-nav__link span {
    font-size: 10px;
    font-weight: 500;
    display: block;
}

.mobile-bottom-nav__badge {
    position: absolute;
    top: 0;
    right: 8px;
    background: var(--color-primary, #FF8717);
    color: #ffffff;
    font-size: 9px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Active state */
.mobile-bottom-nav__link.active {
    color: var(--color-primary, #FF8717);
}

/* ===================================
   Mobile Sticky Add to Cart Bar
   =================================== */

.mobile-sticky-add-to-cart {
    display: none; /* Hidden by default, shown on mobile */
    position: fixed;
    bottom: 70px; /* Above bottom nav */
    left: 0;
    right: 0;
    width: 100%;
    background: #ffffff;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.15);
    z-index: 998;
    padding: 12px 15px;
    border-top: 1px solid #E5E5E5;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.mobile-sticky-add-to-cart.show {
    transform: translateY(0);
}

.mobile-sticky-add-to-cart__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    max-width: 100%;
}

.mobile-sticky-add-to-cart__price {
    flex: 0 0 auto;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary, #FF8717);
}

.mobile-sticky-add-to-cart__price .price {
    font-size: 18px;
    font-weight: 700;
}

.mobile-sticky-add-to-cart__price del {
    opacity: 0.6;
    font-size: 14px;
    margin-right: 5px;
}

.mobile-sticky-add-to-cart__price ins {
    text-decoration: none;
}

.mobile-sticky-add-to-cart__button {
    flex: 1;
    text-align: right;
}

.mobile-add-to-cart-btn {
    background: var(--color-primary, #FF8717);
    color: #ffffff !important;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 140px;
}

.mobile-add-to-cart-btn:hover {
    background: var(--color-heading, #121416);
    color: #ffffff !important;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mobile-add-to-cart-btn i {
    font-size: 16px;
}

.mobile-add-to-cart-btn.loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: rotate 0.6s linear infinite;
    margin-right: 8px;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===================================
   Media Queries - Mobile Only
   =================================== */

@media only screen and (max-width: 991px) {
    /* Show mobile bottom nav */
    .mobile-bottom-nav {
        display: flex !important;
    }

    /* Show sticky add to cart on product pages */
    body.single-product .mobile-sticky-add-to-cart {
        display: block;
    }

    /* Add padding to body to prevent content being hidden behind fixed elements */
    body {
        padding-top: 64px;
        padding-bottom: 70px;
    }

    /* Additional padding for product pages */
    body.single-product {
        padding-top: 64px;
        padding-bottom: 140px;
    }

    /* Hide the hamburger menu in header since it's now in bottom nav */
    .header__hamburger {
        display: none !important;
    }
}

@media only screen and (max-width: 575px) {
    .mobile-bottom-nav__link {
        padding: 5px 5px;
    }

    .mobile-bottom-nav__link span {
        font-size: 9px;
    }

    .mobile-bottom-nav__link i {
        font-size: 18px;
    }

    .mobile-sticky-add-to-cart__price {
        font-size: 16px;
    }

    .mobile-add-to-cart-btn {
        padding: 10px 18px;
        font-size: 13px;
        min-width: 120px;
    }
}

/* ===================================
   Adjustments for WooCommerce Pages
   =================================== */

/* Cart page - adjust padding */
@media only screen and (max-width: 991px) {
    body.woocommerce-cart,
    body.woocommerce-checkout {
        padding-top: 64px;
        padding-bottom: 70px !important;
    }

    /* Product archive pages */
    body.post-type-archive-product,
    body.tax-product_cat {
        padding-top: 64px;
        padding-bottom: 70px !important;
    }
}

/* Ensure mobile menu doesn't conflict with bottom nav */
@media only screen and (max-width: 991px) {
    .slide-bar {
        top: 0;
        bottom: 0;
        height: 100vh;
        padding-bottom: 70px;
    }
}

/* ===================================
   Additional Enhancements
   =================================== */

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Prevent layout shift when sticky bar appears */
body.single-product .product-details-col {
    margin-bottom: 20px;
}

/* Make sure bottom nav is always on top of other elements */
.mobile-bottom-nav {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Optional: Add animation for bottom nav on page load */
@media only screen and (max-width: 991px) {
    .mobile-bottom-nav {
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* Fix for iOS Safari bottom bar overlap */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    body.single-product {
        padding-bottom: calc(140px + env(safe-area-inset-bottom));
    }
}
