/* Mobile-First Enhancements for Avedson Storefront */

:root {
    --primary-blue: #0046be;
    --dark-blue: #001e73;
    --accent-yellow: #ffce00;
    --accent-yellow-dark: #fab528;
}

/* Base Mobile Styles */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-Friendly Buttons */
.btn,
button,
a.btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Improved Mobile Navigation */
#navigation {
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

#navigation.scrolled {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.carousel-indicators [data-bs-target]{
    width: 10px;
    min-height: 7px !important;
    border-radius: 30%;
    background-color: var( --accent-yellow) !important;
}

.carousel-indicators {
    justify-content: end !important;
}
/* Mobile Header Improvements - Extended to tablets */
@media (max-width: 1023.98px) {
    #top-header {
        display: none !important;
    }
    
    #header {
        padding: 0.75rem 0;
    }
    
    #header .logo img {
        max-height: 40px;
    }
    
    /* Mobile Search */
    #header .search {
        margin-top: 0.5rem;
    }
    
    #header .search input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Mobile Cart/Wishlist Icons */
    .header-cta {
        font-size: 1.25rem;
    }
    
    .header-cta .qty {
        width: 18px;
        height: 18px;
        font-size: 10px;
        line-height: 18px;
    }
}

/* Card Enhancements */
.card,
.product-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:active,
.product-item:active {
    transform: scale(0.98);
}

/* Better Touch Feedback */
.btn-primary:active {
    background-color: var(--dark-blue);
}

.btn-warning:active {
    background-color: var(--accent-yellow-dark);
}

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

/* Hide Scrollbar but Keep Functionality */
.overflow-auto::-webkit-scrollbar,
.category-scroll::-webkit-scrollbar {
    display: none;
}

.overflow-auto,
.category-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Carousel Mobile/Tablet Optimizations */
@media (max-width: 1023.98px) {
    #heroCarousel {
        height: 350px !important;
    }
    
    .carousel-indicators {
        margin-bottom: 0.5rem;
    }
    
    .carousel-indicators button {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }
}

/* Product Grid Mobile Optimizations */
@media (max-width: 575.98px) {
    .product-card {
        margin-bottom: 0.75rem;
    }
    
    .product-item .card-body {
        padding: 0.75rem !important;
    }
    
    .product-item h6 {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .product-item .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.5rem;
    }
}

/* Form Input Mobile/Tablet Improvements */
@media (max-width: 1023.98px) {
    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Toast Notifications Mobile/Tablet */
@media (max-width: 1023.98px) {
    #toastContainer {
        left: 1rem;
        right: 1rem;
        top: 1rem;
    }
    
    .toast {
        max-width: 100%;
    }
}

/* Footer Mobile/Tablet */
@media (max-width: 1023.98px) {
    #footer .footer {
        text-align: center;
        margin-bottom: 1.5rem;
    }
    
    #footer .footer ul {
        padding-left: 0;
    }
}

/* Category Pills Mobile/Tablet */
@media (max-width: 1023.98px) {
    .category-item {
        scroll-snap-align: start;
    }
    
    .d-flex.overflow-auto {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
}

/* Flash Sale Banner Mobile/Tablet */
@media (max-width: 1023.98px) {
    .flash-sale-banner h3 {
        font-size: 1rem;
    }
    
    .flash-sale-banner p {
        font-size: 0.875rem;
    }
}

/* List View Mobile/Tablet Adjustments */
@media (max-width: 1023.98px) {
    .products-list-view .product-item {
        flex-direction: row !important;
    }
    
    .products-list-view .product-item > a {
        width: 80px !important;
        flex-shrink: 0;
    }
    
    .products-list-view .card-body {
        padding: 0.75rem !important;
    }
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-blue);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

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

/* Pull to Refresh Visual Feedback */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* Safe Area Insets for Notched Devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    #header,
    #navigation
    {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }
    
    /* Bottom Navigation Safe Area - Extended to tablets */
    @media (max-width: 1023.98px) {
        .d-md-none.position-fixed.bottom-0,
        .d-lg-none.position-fixed.bottom-0 {
            padding-bottom: max(4px, env(safe-area-inset-bottom)) !important;
        }
        
        body {
            padding-bottom: max(64px, calc(64px + env(safe-area-inset-bottom))) !important;
        }
    }
}

/* Skeleton Loading for Images */
.product-img-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible for Keyboard Navigation */
*:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* Landscape Mobile Optimizations */
@media (max-width: 767.98px) and (orientation: landscape) {
    #heroCarousel {
        height: 350px !important;
    }
    
    .flash-sale-banner {
        padding: 1rem !important;
    }
}

/* Sticky Add to Cart on Product Pages - Extended to tablets */
@media (max-width: 1023.98px) {
    .sticky-cart-mobile {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 999;
    }
}

/* Better Image Loading */
img {
    max-width: 100%;
    height: auto;
}

img[loading="lazy"] {
    background: #f0f0f0;
}

/* Improved Bottom Sheet / Modal for Mobile/Tablet */
@media (max-width: 1023.98px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border: none;
        border-radius: 0;
    }
    
    .modal-fullscreen-md-down,
    .modal-fullscreen-lg-down {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }
}
