/* ========================================
   MOBILE RESPONSIVE ENHANCEMENTS
   For phones and tablets - preserves desktop functionality
   ======================================== */

/* Mobile-first approach - Base styles for mobile */
@media screen and (max-width: 1024px) {
    /* Ensure full width usage */
    html, body {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Container adjustments */
    .w3-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* Tablet optimizations (768px to 1024px) */
@media screen and (max-width: 1024px) and (min-width: 768px) {
    .luxury-header {
        padding: 6px 0;
    }
    
    .luxury-logo {
        font-size: 2rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 1.2rem;
    }
    
    .hero-banner h1 {
        font-size: 2.5rem;
    }
    
    .section-title {
        font-size: 2.2rem;
    }
}

/* Mobile phone optimizations (up to 768px) */
@media screen and (max-width: 768px) {
    /* Header mobile fixes - much more compact */
    .luxury-header {
        padding: 2px 0;
        min-height: 50px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .luxury-header .w3-container {
        padding: 4px 8px !important;
    }
    
    .luxury-header .w3-row {
        flex-direction: column;
        gap: 3px;
    }
    
    /* Logo adjustments - smaller and less padding */
    .luxury-logo {
        font-size: 1.4rem !important;
        text-align: center;
        padding: 3px 0;
        line-height: 1 !important;
    }
    
    /* Navigation mobile layout */
    .w3-col.m6 {
        order: 3;
        width: 100% !important;
        margin: 0 !important;
    }
    
    .w3-col.m6 nav.w3-bar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
        padding: 4px 0;
    }
    
    .w3-col.m6 nav.w3-bar .w3-bar-item {
        padding: 4px 8px !important;
        font-size: 0.8rem;
        margin: 1px;
        border-radius: 12px;
        flex: 1;
        text-align: center;
        min-width: 60px;
    }
    
    /* Search and actions mobile layout */
    .w3-col.m4 {
        order: 2;
        width: 100% !important;
        margin: 0 !important;
        justify-content: center !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    
    /* Search bar mobile improvements */
    .w3-col.m4 > div:first-child {
        flex: 1;
        min-width: 200px;
        max-width: 100%;
    }
    
    .luxury-search {
        font-size: 14px !important;
        padding: 8px 12px !important;
        height: 36px !important;
    }
    
    .luxury-search-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 14px !important;
    }
    
    /* Action icons mobile layout */
    .w3-col.m4 > div:last-child {
        display: flex;
        gap: 8px;
        align-items: center;
        justify-content: center;
    }
    
    .luxury-icon {
        font-size: 16px !important;
        padding: 6px !important;
        min-width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 18px;
        background: rgba(212, 175, 55, 0.1);
    }
    
    .luxury-badge {
        font-size: 0.5rem !important;
        min-width: 14px !important;
        height: 14px !important;
        line-height: 14px !important;
        top: -2px;
        right: -2px;
    }
    
    /* Mobile menu enhancements */
    .w3-hide-medium.w3-hide-large {
        display: none !important; /* Hide since we're showing desktop nav */
    }
    
    /* Login or Register button mobile styling */
    .w3-button-luxury.w3-small {
        padding: 6px 12px !important;
        font-size: 0.75rem !important;
        border-radius: 15px !important;
        white-space: nowrap;
        min-width: auto !important;
    }
}

/* Small mobile phones (up to 480px) */
@media screen and (max-width: 480px) {
    /* Even smaller header */
    .luxury-logo {
        font-size: 1.5rem !important;
        padding: 6px 0;
    }
    
    /* Tighter navigation */
    .w3-col.m6 nav.w3-bar .w3-bar-item {
        padding: 5px 8px !important;
        font-size: 0.8rem;
        min-width: 60px;
    }
    
    /* Search adjustments */
    .luxury-search {
        font-size: 13px !important;
        padding: 6px 10px !important;
        height: 32px !important;
    }
    
    .luxury-search-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    /* Smaller action icons */
    .luxury-icon {
        font-size: 14px !important;
        padding: 4px !important;
        min-width: 32px !important;
        height: 32px !important;
    }
    
    /* Container padding */
    .w3-container {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
}

/* Main content mobile optimizations */
@media screen and (max-width: 768px) {
    /* Adjust main content top margin for smaller header */
    .main-content {
        margin-top: 45px !important; /* Ultra-compact mobile header */
    }
    
    /* Hero banner mobile */
    .hero-banner {
        padding: 2rem 1rem !important;
        margin: 0 4px 1rem 4px;
        border-radius: 10px;
    }
    
    .hero-banner h1 {
        font-size: 1.8rem !important;
        margin-bottom: 0.8rem;
    }
    
    .hero-banner p {
        font-size: 1rem !important;
        margin-bottom: 1.5rem;
    }
    
    /* Section titles mobile */
    .section-title {
        font-size: 1.8rem !important;
        margin: 2rem 0 1rem 0 !important;
        padding: 0 8px;
    }
    
    /* Products grid mobile */
    .products-grid {
        grid-template-columns: 1fr 1fr !important; /* 2 columns on mobile */
        gap: 8px !important;
        margin: 0 4px 2rem 4px !important;
    }
    
    /* Product card mobile optimizations */
    .product-card {
        border-radius: 10px;
        overflow: hidden;
    }
    
    .product-image {
        height: 160px !important; /* Smaller images on mobile */
    }
    
    .product-info {
        padding: 0.8rem !important;
    }
    
    .product-title {
        font-size: 0.85rem !important;
        line-height: 1.3;
        margin-bottom: 0.4rem;
    }
    
    .product-price {
        margin-bottom: 0.8rem;
        gap: 0.3rem;
    }
    
    .current-price {
        font-size: 1rem !important;
    }
    
    .original-price {
        font-size: 0.85rem !important;
    }
    
    .discount-badge {
        top: 6px;
        right: 6px;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .add-to-cart {
        padding: 0.6rem !important;
        font-size: 0.85rem;
        border-radius: 6px;
    }
    
    /* View all button mobile */
    .view-all-btn {
        padding: 0.8rem 1.5rem !important;
        margin: 1.5rem auto !important;
        font-size: 0.9rem;
    }
}

/* Very small phones (up to 320px) */
@media screen and (max-width: 320px) {
    .products-grid {
        grid-template-columns: 1fr !important; /* Single column on very small screens */
        gap: 6px !important;
    }
    
    .product-image {
        height: 140px !important;
    }
    
    .product-info {
        padding: 0.6rem !important;
    }
    
    .section-title {
        font-size: 1.5rem !important;
    }
    
    .hero-banner h1 {
        font-size: 1.5rem !important;
    }
}

/* Dropdown menu mobile improvements */
@media screen and (max-width: 768px) {
    .w3-dropdown-content {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%);
        min-width: 180px !important;
        max-width: 90vw !important;
        font-size: 14px !important;
    }
    
    .w3-dropdown-content .w3-bar-item {
        padding: 10px 12px !important;
        font-size: 14px;
    }
    
    /* User dropdown specific adjustments */
    .w3-dropdown-hover:last-child .w3-dropdown-content {
        right: 0 !important;
        left: auto !important;
        transform: none;
    }
}

/* Footer mobile optimizations */
@media screen and (max-width: 768px) {
    .footer {
        padding: 1.5rem 0 1rem 0 !important;
        margin-top: 2rem !important;
    }
    
    .footer-container {
        flex-direction: column !important;
        gap: 1rem !important;
        text-align: center !important;
        padding: 0 8px !important;
    }
    
    .footer-logo {
        font-size: 1.4rem !important;
    }
    
    .footer-copy {
        font-size: 0.9rem !important;
    }
    
    .footer-social {
        justify-content: center;
        gap: 0.8rem !important;
    }
    
    .footer-social a {
        font-size: 0.9rem;
    }
}

/* Form elements mobile optimization */
@media screen and (max-width: 768px) {
    .auth-container {
        margin: 1rem auto !important;
        padding: 1.5rem 1rem !important;
        max-width: 90vw !important;
        border-radius: 10px;
    }
    
    .auth-container h1 {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    .auth-form input {
        padding: 0.7em 1em !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .auth-btn {
        padding: 0.7em 0 !important;
        font-size: 1rem !important;
        margin-top: 1rem !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .w3-button, .luxury-icon, .add-to-cart {
        min-height: 44px !important; /* Apple's recommended touch target size */
        min-width: 44px !important;
    }
    
    .nav-menu li a {
        min-height: 44px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects that don't work on touch */
    .product-card:hover {
        transform: none;
        box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    }
    
    .product-card:hover .product-image img {
        transform: none;
    }
    
    .luxury-icon:hover {
        transform: none;
    }
    
    .add-to-cart:hover {
        transform: none;
    }
    
    .view-all-btn:hover {
        transform: none;
    }
}

/* Notification toast mobile adjustments */
@media screen and (max-width: 768px) {
    .notification-toast {
        bottom: 8px !important;
        right: 8px !important;
        left: 8px !important;
        min-width: auto !important;
        max-width: none !important;
        padding: 12px 16px !important;
        font-size: 14px;
    }
    
    .notification-toast .toast-icon {
        font-size: 1em !important;
        margin-right: 8px !important;
    }
    
    .notification-toast .toast-title {
        font-size: 0.9em !important;
        margin-bottom: 2px !important;
    }
    
    .notification-toast .toast-message {
        font-size: 0.85em !important;
    }
}

/* Landscape mobile orientation */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .main-content {
        margin-top: 80px !important; /* Smaller margin in landscape */
    }
    
    .hero-banner {
        padding: 1.5rem 1rem !important;
    }
    
    .hero-banner h1 {
        font-size: 1.6rem !important;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 columns in landscape */
    }
}

/* High DPI/Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on high-DPI displays */
    .luxury-logo, .section-title, .product-title {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility improvements for mobile */
@media screen and (max-width: 768px) {
    /* Larger focus indicators for touch navigation */
    a:focus, button:focus, input:focus {
        outline: 3px solid #D4AF37 !important;
        outline-offset: 2px !important;
    }
    
    /* Better contrast for small text */
    .product-title {
        color: #000 !important;
        font-weight: 600 !important;
    }
    
    /* Ensure minimum font sizes */
    body, p, span, div {
        font-size: max(14px, 1rem) !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .luxury-header {
        position: -webkit-sticky !important;
        position: sticky !important;
    }
    
    /* Fix iOS Safari viewport height issues */
    .main-content {
        min-height: -webkit-fill-available;
    }
    
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Android Chrome specific optimizations */
@media screen and (max-width: 768px) {
    /* Improve performance on Android */
    .product-card, .hero-banner, .luxury-header {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* Loading states for mobile */
@media screen and (max-width: 768px) {
    .add-to-cart[disabled] {
        opacity: 0.7;
        cursor: not-allowed;
    }
    
    /* Better loading indicators */
    .add-to-cart:disabled::after {
        content: "...";
        animation: dots 1s infinite;
    }
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Print styles (mobile-friendly) */
@media print {
    .luxury-header, .footer, .add-to-cart, .luxury-icon {
        display: none !important;
    }
    
    .main-content {
        margin-top: 0 !important;
    }
    
    .product-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
}
