/* Mobile Optimization Styles */
/* Specific optimizations for very small screens */
@media screen and (max-width: 480px) {
    header .title {
        font-size: 20px !important;
    }

    header .title.page-title, 
    .page-title {
        font-size: 24px !important;
        margin-bottom: 12px !important;
    }

    header .title::after {
        width: 40px !important;
        height: 3px !important;
    }

    .search-sort-container {
        margin-bottom: 15px !important;
        gap: 10px !important;
    }

    body:not(.clothing-page) .product-card .product-info {
        /* Preserve desktop padding structure on mobile */
        padding: 20px 15px 15px !important;
    }

    .product-meta {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .product-rating {
        font-size: 12px !important;
        margin-top: 3px !important;
    }

    /* Product image height now unified in product-cards.css (120px for all pages) */
    
    /* Keep same order and typography as desktop */
    body:not(.clothing-page) .product-name {
        order: 1 !important;
        font-size: 1rem !important;
        line-height: 1.3 !important;
        margin-top: 0 !important;
        min-height: 2.6em !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
    }
    
    .product-category {
        order: 0 !important;
        font-size: 0.8rem !important;
    }
    
    body:not(.clothing-page) .product-price {
        order: 2 !important;
        font-size: 1.2rem !important;
        margin-bottom: 15px !important;
    }
    
    .product-actions {
        order: 3 !important;
    }

    body:not(.clothing-page) .product-buttons button {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    .view-product {
        min-width: 50px !important;
    }

    body:not(.clothing-page) .product-detail-container {
        flex-direction: column !important;
    }

    body:not(.clothing-page) .product-detail-image, 
    body:not(.clothing-page) .product-detail-info {
        margin: 10px 5px !important;
    }

    .rating-count {
        font-size: 11px !important;
    }

    /* Keep grid layout on mobile: 2 columns */
    body:not(.clothing-page) .products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 15px !important;
        justify-content: initial !important;
    }

    body:not(.clothing-page) .product-card {
        /* Let the grid control sizing; keep internal flex layout */
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    body:not(.clothing-page) .product-card .product-title {
        font-size: 1rem !important;
    }

    body:not(.clothing-page) .product-card .price {
        font-size: 1.2rem !important;
    }

    .price-filter-item {
        padding: 8px 15px !important;
    }

    .price-filter-item label {
        font-size: 12px !important;
        min-width: 68px !important;
    }

    .price-filter-item input {
        width: 80px !important;
        padding: 6px 12px !important;
        font-size: 12px !important;
        border-radius: 18px !important;
    }

    .price-filter-item .number-controls {
        right: 18px !important;
    }

    .price-filter-item .number-control-btn {
        font-size: 11px !important;
        width: 18px !important;
        height: 11px !important;
    }

    /* Reorder Filter/Sort buttons for mobile + SMOOTH FIX */
    body:not(.clothing-page) .filter-sort-wrapper {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: clamp(20px, 9vw, 90px) !important;
        transition: gap 0.3s ease-in-out;
    }

    body:not(.clothing-page) .sort-container, 
    body:not(.clothing-page) .filter-container {
        width: 140px !important;
        position: relative !important;
        transition: all 0.3s ease-in-out;
    }

    body:not(.clothing-page) .sort-container {
        order: 1 !important;
    }

    body:not(.clothing-page) .filter-container {
        order: 2 !important;
        left: 60px !important;
    }

    body:not(.clothing-page) .sort-btn,
    body:not(.clothing-page) .filter-btn {
        width: 100% !important;
    }

    /* Clothing page overrides: Filter flush left + micro card tweaks */
    body.clothing-page .filter-container,
    body.clothing-page .sort-container {
        width: auto;
        left: 0;
    }

    /* Clothing page: replicate grid and card sizing without !important */
    body.clothing-page .products-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 15px;
        justify-content: initial;
    }

    body.clothing-page .product-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
        display: flex;
        flex-direction: column;
    }

    /* All product card styles are now unified in product-cards.css */
    body.home-page .top-nav .brand {
        margin-left: 4px !important;
    }
    /* Remove blue tap highlights on Home (mobile) */
    body.home-page *,
    body.home-page a,
    body.home-page button,
    body.home-page input,
    body.home-page svg,
    body.home-page .menu-toggle,
    body.home-page .mobile-menu-toggle,
    body.home-page .top-nav .brand a,
    body.home-page .mobile-nav-link,
    body.home-page .nav-cart,
    body.home-page .theme-toggle {
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
    }

    /* Remove Logout option in profile dropdown on mobile for Home & Contact */
    body.home-page .profile-dropdown .logout-button,
    body.contact-page .profile-dropdown .logout-button,
    body.home-page .nav-logout,
    body.contact-page .nav-logout {
        display: none !important;
    }
    body.home-page .brand a {
        font-size: 20px !important;
        width: 110px !important;
    }

    /* Ensure Home badges match Clothing badge sizing and spacing exactly */
    body.home-page .marketing-badge,
    body.home-page .discount-badge,
    body.home-page .new-badge {
        font-size: 0.68rem !important;
        font-weight: 600 !important;
        padding: 3px 7px !important;
        border-radius: 16px !important;
        line-height: 1 !important;
    }
    /* Position parity */
    body.home-page .marketing-badge { top: 6px !important; right: 6px !important; }
    body.home-page .discount-badge { top: 6px !important; left: 6px !important; }

    /* Match clothing page header controls behavior for mobile on Home */
    body.home-page.has-consistent-header .auth-links {
        display: none !important;
    }
    body.home-page.has-consistent-header .user-profile {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    /* Tighten icon spacing for exact visual parity */
    body.home-page .user-controls {
        gap: 5px !important;
    }

    .nav-signup span,
    header .nav-signup span,
    nav .nav-signup span,
    .auth-links .nav-signup span {
        display: none !important;
    }

    .nav-signup i,
    header .nav-signup i,
    nav .nav-signup i,
    .auth-links .nav-signup i {
        font-size: 17px !important;
        display: inline-block !important;
    }

    .theme-toggle {
        width: 40px !important;
        height: 22px !important;
        margin-right: 15px !important;
    }

    .toggle-label {
        width: 40px !important;
        height: 22px !important;
    }

    .toggle-input:checked + .toggle-label:before {
        transform: translateX(18px) !important;
    }

    .logo {
        width: 70px !important;
        height: auto !important;
    }

    body:not(.clothing-page) .brand {
        margin-left: -18px !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
    }

    body:not(.clothing-page) .brand a {
        pointer-events: none !important;
        cursor: default !important;
    }

    body:not(.clothing-page) .top-nav {
        padding-left: 5px !important;
        padding-right: 5px !important;
        overflow: visible !important;
        gap: 5px !important;
    }

    /* Clothing page equivalents without !important */
    body.clothing-page .product-detail-container {
        flex-direction: column;
    }

    body.clothing-page .product-detail-image,
    body.clothing-page .product-detail-info {
        margin: 10px 5px;
    }

    body.clothing-page .product-buttons button {
        padding: 8px 12px;
        font-size: 12px;
    }

    body.clothing-page .filter-sort-wrapper {
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        gap: clamp(20px, 9vw, 90px);
        transition: gap 0.3s ease-in-out;
    }

    body.clothing-page .sort-btn,
    body.clothing-page .filter-btn {
        width: 100%;
    }

    body.clothing-page .brand a {
        pointer-events: none;
        cursor: default;
    }

    body.clothing-page .top-nav {
        padding-left: 5px;
        padding-right: 5px;
        overflow: visible;
        gap: 5px;
    }

    .menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 30px !important;
        min-height: 30px !important;
        z-index: 9999 !important;
        position: relative !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
        margin-right: 0 !important;
        padding-right: 0 !important;
    }

    .animated-menu-icon,
    .menu-toggle .animated-menu-icon {
        display: inline-block !important;
        width: 22px !important;
        height: 22px !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
    }

    .animated-menu-icon i,
    .menu-toggle .animated-menu-icon i {
        font-size: 20px !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .user-controls {
        margin-left: auto !important;
        gap: 5px !important;
    }

    body.home-page .site-header,
    body.home-page .mobile-menu {
        display: none !important;
    }
    body.home-page .top-nav {
        display: flex !important;
    }
    body.has-consistent-header .auth-links {
        display: none !important;
    }
    body.has-consistent-header .user-profile {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    @media screen and (max-width: 345px) {
        .logo {
            width: calc(65px - ((345px - 100vw) * 0.15)) !important;
        }

        .nav-signup i,
        .nav-signin i,
        .nav-cart i {
            font-size: calc(14px + 0.8vw) !important;
        }

        .theme-toggle {
            width: calc(35px + 1.5vw) !important;
            height: calc(18px + 1vw) !important;
            margin-right: calc(10px + 1vw) !important;
        }

        .toggle-label {
            width: calc(35px + 1.5vw) !important;
            height: calc(18px + 1vw) !important;
        }

        .animated-menu-icon,
        .menu-toggle .animated-menu-icon {
            width: calc(18px + 1.2vw) !important;
            height: calc(18px + 1.2vw) !important;
        }

        .animated-menu-icon i,
        .menu-toggle .animated-menu-icon i {
            font-size: calc(16px + 1.2vw) !important;
        }
    }
}

@media screen and (max-width: 360px) {
  body.clothing-page .product-buttons button,
  body.clothing-page .product-actions .add-to-cart,
  body.clothing-page .product-actions .add-to-cart-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  body.clothing-page .wishlist-btn,
  body.clothing-page .add-to-wishlist {
    width: 34px;
    height: 34px;
  }

  body.clothing-page .wishlist-btn i,
  body.clothing-page .add-to-wishlist i {
    font-size: 0.95rem;
  }

  body.home-page .product-buttons button,
  body.home-page .product-actions .add-to-cart,
  body.home-page .product-actions .add-to-cart-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  body.home-page .wishlist-btn,
  body.home-page .add-to-wishlist {
    width: 34px !important;
    height: 34px !important;
  }

  body.home-page .wishlist-btn i,
  body.home-page .add-to-wishlist i {
    font-size: 0.95rem !important;
  }

  /* Apply same reductions across other primary pages */
  body.phones-page .product-buttons button,
  body.laptops-page .product-buttons button,
  body.accessories-page .product-buttons button,
  body.products-page .product-buttons button,
  body.contact-page .product-buttons button,
  body.settings-page .product-buttons button,
  body.phones-page .product-actions .add-to-cart,
  body.phones-page .product-actions .add-to-cart-btn,
  body.laptops-page .product-actions .add-to-cart,
  body.laptops-page .product-actions .add-to-cart-btn,
  body.accessories-page .product-actions .add-to-cart,
  body.accessories-page .product-actions .add-to-cart-btn,
  body.products-page .product-actions .add-to-cart,
  body.products-page .product-actions .add-to-cart-btn,
  body.contact-page .product-actions .add-to-cart,
  body.contact-page .product-actions .add-to-cart-btn,
  body.settings-page .product-actions .add-to-cart,
  body.settings-page .product-actions .add-to-cart-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  body.phones-page .wishlist-btn,
  body.laptops-page .wishlist-btn,
  body.accessories-page .wishlist-btn,
  body.products-page .wishlist-btn,
  body.contact-page .wishlist-btn,
  body.settings-page .wishlist-btn,
  body.phones-page .add-to-wishlist,
  body.laptops-page .add-to-wishlist,
  body.accessories-page .add-to-wishlist,
  body.products-page .add-to-wishlist,
  body.contact-page .add-to-wishlist,
  body.settings-page .add-to-wishlist {
    width: 34px !important;
    height: 34px !important;
  }

  body.phones-page .wishlist-btn i,
  body.laptops-page .wishlist-btn i,
  body.accessories-page .wishlist-btn i,
  body.products-page .wishlist-btn i,
  body.contact-page .wishlist-btn i,
  body.settings-page .wishlist-btn i,
  body.phones-page .add-to-wishlist i,
  body.laptops-page .add-to-wishlist i,
  body.accessories-page .add-to-wishlist i,
  body.products-page .add-to-wishlist i,
  body.contact-page .add-to-wishlist i,
  body.settings-page .add-to-wishlist i {
    font-size: 0.95rem !important;
  }
}

/* Ultra small screen optimizations */
    @media screen and (max-width: 375px) {

        body.home-page .site-header,
        body.home-page .mobile-menu {
            display: none !important;
        }
        body.home-page .top-nav {
            display: flex !important;
        }
        body.has-consistent-header .auth-links {
            display: none !important;
        }
        body.has-consistent-header .user-profile {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
        }

        @media screen and (max-width: 345px) {
            .logo {
                width: calc(65px - ((345px - 100vw) * 0.15)) !important;
            }

            .nav-signup i,
            .nav-signin i,
            .nav-cart i {
                font-size: calc(14px + 0.8vw) !important;
            }

            .theme-toggle {
                width: calc(35px + 1.5vw) !important;
                height: calc(18px + 1vw) !important;
                margin-right: calc(10px + 1vw) !important;
            }

            .toggle-label {
                width: calc(35px + 1.5vw) !important;
                height: calc(18px + 1vw) !important;
            }

            .animated-menu-icon,
            .menu-toggle .animated-menu-icon {
                width: calc(18px + 1.2vw) !important;
                height: calc(18px + 1.2vw) !important;
            }

            .animated-menu-icon i,
            .menu-toggle .animated-menu-icon i {
                font-size: calc(16px + 1.2vw) !important;
            }
        }
      body.home-page .marketing-badge { top: 6px !important; right: 6px !important; }
      body.home-page .discount-badge { top: 6px !important; left: 6px !important; }
    }

@media screen and (max-width: 419px) {
  body.clothing-page {
    --page-scale: clamp(0.85, calc(100vw / 419), 1);
  }

  @supports (zoom: 1) {
    body.clothing-page {
      zoom: var(--page-scale);
    }
  }

  @supports not (zoom: 1) {
    body.clothing-page .top-nav,
    body.clothing-page .container {
      transform: scale(var(--page-scale));
      transform-origin: top center;
      transition: transform 0.2s ease-in-out;
    }

    body.clothing-page .sidebar_menu {
      transform: scale(var(--page-scale));
      transform-origin: top left;
      transition: transform 0.2s ease-in-out;
    }

    body.clothing-page .product-modal .modal-content {
      transform: scale(var(--page-scale));
      transform-origin: top center;
      transition: transform 0.2s ease-in-out;
    }
  }
}
