/* ===================================
   MOBILE-FIRST OPTIMIZATIONS
   LuxeStore Mobile Experience
   =================================== */

/* ===================================
   1. MOBILE-FIRST BASE STYLES
   =================================== */

/* Mobile-first approach - start with mobile styles */
@media (max-width: 768px) {
    
    /* Enhanced Touch Targets */
    button,
    a,
    input[type="button"],
    input[type="submit"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }

    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    /* Smooth scrolling with momentum */
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }

    /* Disable tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* ===================================
       2. MOBILE NAVIGATION
       =================================== */

    .header {
        padding: 0.5rem 0;
    }

    .navbar {
        padding: 0.75rem 0;
    }

    .nav-brand .logo {
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .nav-brand .logo i {
        font-size: 1.3rem;
    }

    .nav-brand {
        flex: 0 0 auto;
        max-width: 50%;
        overflow: hidden;
    }

    .nav-actions {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        flex-shrink: 0;
        position: relative;
        z-index: 100;
    }

    .nav-actions button {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Mobile Menu */
    .nav-menu {
        display: flex !important;
        position: fixed;
        top: 60px;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: calc(100vh - 60px);
        background: var(--white-color, #fff);
        flex-direction: column;
        padding: 1.5rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        transition: left 0.3s ease;
        z-index: 1060;
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-item {
        padding: 1rem 0;
        border-bottom: 1px solid var(--neutral-200);
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-link {
        font-size: 1.125rem;
        display: block;
        padding: 0.5rem 0;
    }

    /* Mobile Menu Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 85%;  /* Start after menu (menu is 85% wide) */
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1045;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease, left 0.3s ease;
        pointer-events: none;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        left: 85%;  /* Ensure it stays to the right of menu */
    }
    
    /* For devices where menu hits max-width of 320px */
    @media (min-width: 377px) {
        .mobile-menu-overlay {
            left: 320px;  /* Start after menu max-width */
        }
        
        .mobile-menu-overlay.active {
            left: 320px;
        }
    }

    /* ===================================
       3. MOBILE HERO SECTION
       =================================== */

    .hero {
        min-height: 70vh;
        padding: 0;
        margin-top: 60px;
    }

    .hero-content {
        align-items: flex-start;
        padding-top: 1.5rem;
        min-height: 70vh;
    }

    .hero-content .container {
        padding-top: 0;
    }

    .hero-title {
        font-size: 1.85rem;
        line-height: 1.2;
        margin-bottom: 0.75rem;
        padding-top: 0;
        margin-top: 0;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.25rem;
    }

    .btn-large {
        padding: 0.875rem 1.75rem;
        font-size: 0.95rem;
        width: 100%;
        max-width: 280px;
    }

    /* ===================================
       4. MOBILE PRODUCT GRID
       =================================== */

    .products-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Two columns for slightly larger mobile screens */
    @media (min-width: 480px) {
        .products-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 1rem;
        }
    }

    .product-card {
        margin-bottom: 0;
    }

    .product-image {
        aspect-ratio: 1 / 1;
    }

    .product-info {
        padding: 1rem;
    }

    .product-name {
        font-size: 1rem;
        line-height: 1.3;
        margin: 0.5rem 0;
    }

    .product-category {
        font-size: 0.75rem;
    }

    .product-price {
        margin: 0.75rem 0;
    }

    .price-current {
        font-size: 1.25rem;
    }

    .add-to-cart-btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.875rem;
    }

    /* Product Actions - Always visible on mobile */
    .product-actions {
        opacity: 1;
        transform: translateX(0);
        top: 0.75rem;
        right: 0.75rem;
    }

    .product-action-btn {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    /* ===================================
       5. MOBILE CATEGORIES
       =================================== */

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    @media (min-width: 480px) {
        .categories-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    .category-card {
        min-height: 200px;
    }

    .category-content h3 {
        font-size: 1.25rem;
    }

    /* ===================================
       6. MOBILE CART SIDEBAR
       =================================== */

    .cart-sidebar {
        width: 100%;
        max-width: 100%;
    }

    .cart-header {
        padding: 1.25rem 1rem;
    }

    .cart-header h2 {
        font-size: 1.25rem;
    }

    .cart-items {
        padding: 1rem;
        max-height: calc(100vh - 250px);
    }

    .cart-item {
        padding: 1rem;
        gap: 1rem;
    }

    .cart-item-image {
        width: 70px;
        height: 70px;
    }

    .cart-item-name {
        font-size: 0.875rem;
    }

    .cart-item-price {
        font-size: 1rem;
    }

    .cart-footer {
        padding: 1.25rem 1rem;
    }

    .cart-total {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }

    .btn-block {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    /* ===================================
       7. MOBILE PRODUCT MODAL
       =================================== */

    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        max-height: calc(100vh - 60px);
    }

    .product-detail {
        flex-direction: column;
    }

    .product-gallery {
        width: 100%;
        margin-bottom: 1.5rem;
    }

    .main-image {
        height: 300px;
    }

    .thumbnail-images {
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

    .thumbnail {
        width: 60px;
        height: 60px;
    }

    .product-detail-info {
        width: 100%;
    }

    .product-detail-info h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .product-description {
        font-size: 0.875rem;
        line-height: 1.6;
    }

    .product-options {
        margin: 1.5rem 0;
    }

    .size-options,
    .color-options {
        gap: 0.5rem;
    }

    .size-option {
        min-width: 44px;
        height: 44px;
        font-size: 0.875rem;
    }

    .color-option {
        width: 44px;
        height: 44px;
    }

    .product-detail-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .product-detail-actions .btn {
        width: 100%;
    }

    /* ===================================
       8. MOBILE SEARCH
       =================================== */

    .search-overlay {
        padding: 1rem;
    }

    .search-container {
        max-width: 100%;
    }

    .search-input {
        font-size: 1rem;
        padding: 1rem 3rem 1rem 1rem;
    }

    .search-close {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    /* ===================================
       9. MOBILE FILTER SIDEBAR
       =================================== */

    .shop-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        border-radius: 0;
        background: white;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .filter-sidebar.active {
        left: 0;
    }

    .filter-close-btn {
        display: block;
    }

    .filter-sidebar-content {
        max-height: calc(100vh - 80px);
    }

    .products-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    #toggleFiltersBtn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: auto;
        padding: 0.75rem 1.5rem;
    }

    .products-grid.list-view .product-card {
        grid-template-columns: 120px 1fr;
        gap: 1rem;
    }

    .products-grid.list-view .product-image {
        height: 150px;
    }

    .active-filters {
        padding: 0 0.5rem;
        margin-top: 0.5rem;
    }

    .filter-chip {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    /* ===================================
       10. MOBILE FORMS
       =================================== */

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
        border-radius: 8px;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-form input {
        width: 100%;
    }

    .newsletter-form button {
        width: 100%;
    }

    /* ===================================
       11. MOBILE FOOTER
       =================================== */

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-section {
        text-align: center;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }

    .footer-section ul {
        margin-bottom: 1rem;
    }

    .footer-section li {
        margin-bottom: 0.75rem;
    }

    .social-links {
        justify-content: center;
        gap: 1.5rem;
    }

    .social-links a {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    .footer-bottom {
        padding: 1.5rem 0;
        padding-bottom: 5rem;
        font-size: 0.875rem;
    }

    /* Ensure admin link is visible above mobile nav */
    .admin-link {
        display: block !important;
        margin-bottom: 1rem;
    }

    /* ===================================
       12. MOBILE SECTIONS
       =================================== */

    .section-header {
        text-align: center;
        margin-bottom: 2rem;
    }

    .section-title {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }

    .section-subtitle {
        font-size: 1rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    @media (min-width: 480px) {
        .features-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    .feature-card {
        padding: 1.5rem;
        text-align: center;
    }

    .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin: 0 auto 1rem;
    }

    .feature-card h3 {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .feature-card p {
        font-size: 0.875rem;
    }

    /* ===================================
       13. MOBILE PROMO BANNER
       =================================== */

    .promo-banner {
        min-height: 50vh;
        padding: 3rem 0;
    }

    .promo-title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .promo-subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    /* ===================================
       14. MOBILE UTILITIES
       =================================== */

    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Mobile spacing */
    .mobile-mt-1 { margin-top: 0.5rem; }
    .mobile-mt-2 { margin-top: 1rem; }
    .mobile-mt-3 { margin-top: 1.5rem; }
    .mobile-mt-4 { margin-top: 2rem; }

    .mobile-mb-1 { margin-bottom: 0.5rem; }
    .mobile-mb-2 { margin-bottom: 1rem; }
    .mobile-mb-3 { margin-bottom: 1.5rem; }
    .mobile-mb-4 { margin-bottom: 2rem; }

    .mobile-p-1 { padding: 0.5rem; }
    .mobile-p-2 { padding: 1rem; }
    .mobile-p-3 { padding: 1.5rem; }
    .mobile-p-4 { padding: 2rem; }

    /* Mobile text alignment */
    .mobile-text-center { text-align: center; }
    .mobile-text-left { text-align: left; }
    .mobile-text-right { text-align: right; }

    /* ===================================
       15. MOBILE PERFORMANCE
       =================================== */

    /* Reduce animations on mobile for performance */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* Optimize images */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    /* ===================================
       16. MOBILE SWIPE INDICATORS
       =================================== */

    .swipe-indicator {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem;
        color: var(--neutral-600);
        font-size: 0.875rem;
    }

    .swipe-indicator i {
        animation: swipe 2s infinite;
    }

    @keyframes swipe {
        0%, 100% {
            transform: translateX(0);
        }
        50% {
            transform: translateX(10px);
        }
    }

    /* ===================================
       17. MOBILE SAFE AREAS (iOS)
       =================================== */

    /* Support for iPhone notch and home indicator */
    @supports (padding: max(0px)) {
        .header {
            padding-top: max(0.5rem, env(safe-area-inset-top));
        }

        .mobile-bottom-nav {
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        }

        .sticky-add-to-cart {
            bottom: max(70px, calc(70px + env(safe-area-inset-bottom)));
        }
    }

    /* ===================================
       18. MOBILE LOADING STATES
       =================================== */

    .mobile-skeleton {
        background: linear-gradient(
            90deg,
            var(--neutral-200) 25%,
            var(--neutral-100) 50%,
            var(--neutral-200) 75%
        );
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }

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

    .mobile-skeleton-card {
        height: 350px;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    /* ===================================
       19. MOBILE PULL TO REFRESH
       =================================== */

    .pull-to-refresh {
        position: fixed;
        top: 60px;
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        background: var(--neutral-100);
        padding: 1rem 2rem;
        border-radius: 50px;
        box-shadow: var(--shadow-lg);
        display: flex;
        align-items: center;
        gap: 0.75rem;
        transition: transform var(--transition-base);
        z-index: var(--z-fixed);
    }

    .pull-to-refresh.active {
        transform: translateX(-50%) translateY(10px);
    }

    .pull-to-refresh-spinner {
        width: 20px;
        height: 20px;
        border: 2px solid var(--neutral-300);
        border-top-color: var(--accent-rose-gold);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

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

    /* ===================================
       20. MOBILE ACCESSIBILITY
       =================================== */

    /* Larger tap targets for accessibility */
    .a11y-large-target {
        min-width: 48px;
        min-height: 48px;
    }

    /* Focus indicators for keyboard navigation */
    *:focus-visible {
        outline: 3px solid var(--accent-rose-gold);
        outline-offset: 2px;
    }

    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -100px;
        left: 0;
        background: var(--accent-rose-gold);
        color: var(--neutral-100);
        padding: 1rem 2rem;
        z-index: 9999;
        transition: top var(--transition-fast);
    }

    .skip-to-content:focus {
        top: 0;
    }
}

/* ===================================
   TABLET OPTIMIZATIONS (481px - 768px)
   =================================== */

@media (min-width: 481px) and (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .hero-title {
        font-size: 3rem;
    }

    .section-title {
        font-size: 2.5rem;
    }
}

/* ===================================
   LANDSCAPE MOBILE OPTIMIZATIONS
   =================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    .cart-sidebar {
        max-height: 100vh;
    }

    .nav-menu {
        max-height: calc(100vh - 60px);
    }
}

/* ===================================
   DESKTOP OVERRIDES (769px+)
   =================================== */

@media (min-width: 769px) {
    .mobile-bottom-nav,
    .sticky-add-to-cart,
    .show-mobile {
        display: none !important;
    }

    .hide-mobile {
        display: block !important;
    }

    .nav-menu {
        display: flex !important;
    }

    .mobile-menu-btn {
        display: none;
    }
}
