/**
 * Comprehensive Mobile Responsive Fixes for Aroma Drops
 * Ensures perfect display across all mobile devices
 */

/* ========================================
   GLOBAL MOBILE FIXES
======================================== */

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Improve touch targets for mobile */
a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}

/* Better text rendering on mobile */
body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ========================================
   HEADER MOBILE FIXES
======================================== */

/* Mobile: Header spacing adjustments */
@media (max-width: 768px) {
    /* Reduce header padding */
    header .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Logo sizing */
    .logo-image {
        height: 40px !important;
        max-width: 150px !important;
    }

    /* Cart and User buttons - better spacing */
    .cart-button, .user-dropdown-button {
        padding: 0.5rem !important;
    }

    .cart-button svg, .user-dropdown-button svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    /* Cart badge positioning */
    .cart-badge-fixed {
        top: -0.125rem !important;
        right: -0.125rem !important;
        min-width: 1rem !important;
        height: 1rem !important;
        font-size: 0.625rem !important;
        border-width: 1px !important;
    }

    /* Mobile menu button */
    #mobile-menu-toggle {
        padding: 0.5rem !important;
    }

    /* Mobile search bar */
    #mobile-menu input[name="search"] {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }

    /* User dropdown on mobile - better positioning */
    .user-dropdown-menu {
        right: 0 !important;
        left: auto !important;
        min-width: 200px !important;
        max-width: 90vw !important;
    }

    .user-dropdown-item {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Mobile menu nav items */
    #mobile-menu nav a {
        font-size: 0.9375rem !important;
        padding: 0.75rem 1rem !important;
    }

    /* Products dropdown in mobile */
    #products-submenu a {
        font-size: 0.875rem !important;
        padding: 0.625rem 1rem !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .logo-image {
        height: 35px !important;
        max-width: 130px !important;
    }

    /* Tighter spacing */
    header .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Smaller icons */
    .cart-button svg, .user-dropdown-button svg {
        width: 1.125rem !important;
        height: 1.125rem !important;
    }
}

/* ========================================
   HOME PAGE HERO SECTION MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Hero section height adjustment */
    .hero-section,
    section:first-of-type {
        min-height: 60vh !important;
        height: auto !important;
    }

    /* Hero content spacing */
    .hero-section .text-center,
    section:first-of-type .text-center {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* Hero headings */
    h1 {
        font-size: 2rem !important;
        line-height: 1.1 !important;
    }

    h1 span {
        font-size: 2.25rem !important;
    }

    /* Hero description */
    .hero-section p,
    section:first-of-type p {
        font-size: 0.9375rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1.5rem !important;
    }

    /* Hero CTA buttons */
    .hero-section a,
    section:first-of-type a[href*="page=shop"],
    section:first-of-type a[href*="page=about"] {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
        width: 100% !important;
        max-width: 280px !important;
        display: inline-block !important;
        text-align: center !important;
    }

    /* Stack buttons on mobile */
    .hero-section .flex,
    section:first-of-type .flex {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* Trust indicators */
    .hero-section .grid-cols-3 {
        gap: 1rem !important;
        padding: 0 1rem !important;
    }

    .counter-number {
        font-size: 1.5rem !important;
    }

    .counter-number + div {
        font-size: 0.75rem !important;
    }

    /* Slide indicators */
    .slide-indicator {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }

    /* Premium badge */
    .hero-section span[class*="badge"],
    section:first-of-type span[class*="rounded-full"] {
        font-size: 0.75rem !important;
        padding: 0.5rem 1rem !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem !important;
    }

    h1 span {
        font-size: 2rem !important;
    }

    .hero-section p {
        font-size: 0.875rem !important;
    }

    .counter-number {
        font-size: 1.25rem !important;
    }
}

/* ========================================
   PRODUCT CARDS MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Product grid - single column on mobile */
    .grid-cols-4, .grid-cols-3, .grid-cols-2 {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 1rem !important;
    }

    /* Product card */
    .product-card,
    [class*="product"] .bg-white {
        border-radius: 1rem !important;
    }

    /* Product image container */
    .aspect-square {
        border-radius: 1rem 1rem 0 0 !important;
    }

    /* Product title */
    .product-card h3,
    [class*="product"] h3 {
        font-size: 0.875rem !important;
        line-height: 1.3 !important;
    }

    /* Brand name */
    .product-card .text-xs,
    [class*="product"] .text-xs {
        font-size: 0.6875rem !important;
    }

    /* Price */
    .product-card .price,
    [class*="product"] [class*="price"] {
        font-size: 0.875rem !important;
    }

    /* Badges */
    .absolute.top-3 {
        top: 0.5rem !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
    }

    .badge,
    [class*="badge"],
    .rounded-full.text-xs {
        font-size: 0.625rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Add to cart button */
    .add-to-cart-btn,
    button[onclick*="addToCart"] {
        font-size: 0.8125rem !important;
        padding: 0.5rem 1rem !important;
    }
}

@media (max-width: 480px) {
    .grid-cols-4, .grid-cols-3, .grid-cols-2 {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .product-card h3 {
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   SECTIONS MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Section padding */
    section {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    /* Section headings */
    section h2 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }

    section h2 span {
        font-size: 2rem !important;
    }

    /* Section descriptions */
    section p {
        font-size: 0.9375rem !important;
        line-height: 1.5 !important;
    }

    /* Section icons */
    section .w-16 {
        width: 3rem !important;
        height: 3rem !important;
    }

    section .w-8 {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    /* Container padding */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

@media (max-width: 480px) {
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    section h2 {
        font-size: 1.75rem !important;
    }
}

/* ========================================
   CAROUSEL/SLIDER MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Bestsellers carousel */
    .bestsellers-carousel,
    .bestseller-group {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Carousel controls */
    .carousel-control,
    button[class*="carousel"] {
        width: 2rem !important;
        height: 2rem !important;
        padding: 0.25rem !important;
    }

    .carousel-control svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    /* Hide carousel controls if not needed */
    @media (max-width: 640px) {
        .bestsellers-carousel .carousel-control {
            display: none !important;
        }

        .bestseller-group {
            grid-template-columns: 1fr !important;
        }
    }
}

/* ========================================
   FOOTER MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Footer grid - single column */
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Footer heading */
    footer h3 {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    footer h4 {
        font-size: 1.125rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Footer text */
    footer p {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }

    /* Footer links */
    footer a {
        font-size: 0.875rem !important;
        padding: 0.25rem 0 !important;
        display: inline-block !important;
    }

    /* Social icons */
    footer .flex.space-x-4 {
        gap: 1rem !important;
        justify-content: center !important;
        margin-top: 1rem !important;
    }

    footer .w-6 {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    /* Footer bottom bar */
    footer .border-t {
        padding-top: 1.5rem !important;
        margin-top: 2rem !important;
    }

    footer .flex-wrap {
        gap: 0.75rem !important;
        justify-content: center !important;
    }

    footer .text-sm {
        font-size: 0.75rem !important;
    }

    /* Center align everything on mobile */
    footer > div > div {
        text-align: center !important;
    }

    footer ul {
        text-align: center !important;
    }
}

@media (max-width: 480px) {
    footer {
        padding: 2rem 1rem !important;
    }

    footer h3 {
        font-size: 1.25rem !important;
    }

    footer .flex-wrap {
        flex-direction: column !important;
        align-items: center !important;
    }
}

/* ========================================
   FORM ELEMENTS MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Input fields */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem !important;
    }

    /* Buttons */
    button:not(.cart-button):not(.user-dropdown-button):not(#mobile-menu-toggle) {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.9375rem !important;
        min-height: 44px !important;
    }
}

/* ========================================
   TOAST NOTIFICATION MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    .toast-notification {
        left: 0.5rem !important;
        right: 0.5rem !important;
        top: 0.5rem !important;
        min-width: auto !important;
        max-width: calc(100vw - 1rem) !important;
    }

    .toast-content {
        padding: 0.75rem 1rem !important;
    }

    .toast-message {
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   WHATSAPP BUTTON MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    .whatsapp-float {
        width: 50px !important;
        height: 50px !important;
        bottom: 15px !important;
        right: 15px !important;
    }

    .whatsapp-float svg {
        width: 28px !important;
        height: 28px !important;
    }

    /* Hide tooltip on mobile */
    .whatsapp-float::before,
    .whatsapp-float::after {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .whatsapp-float {
        width: 45px !important;
        height: 45px !important;
        bottom: 10px !important;
        right: 10px !important;
    }

    .whatsapp-float svg {
        width: 25px !important;
        height: 25px !important;
    }
}

/* ========================================
   MODAL/POPUP MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    .modal,
    [role="dialog"] {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 1rem !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .modal-header,
    .modal-footer {
        padding: 1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
    }
}

/* ========================================
   TABLE MOBILE FIXES
======================================== */

@media (max-width: 768px) {
    /* Make tables scrollable */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Or stack table cells */
    .table-responsive table,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead {
        display: none;
    }

    .table-responsive tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 0.5rem;
    }

    .table-responsive td {
        text-align: right;
        padding: 0.5rem;
        position: relative;
        padding-left: 50%;
    }

    .table-responsive td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        width: 45%;
        padding-right: 0.5rem;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
    }
}

/* ========================================
   UTILITY CLASSES FOR MOBILE
======================================== */

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

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

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }

    .show-mobile {
        display: none !important;
    }

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

/* Mobile-specific text sizes */
@media (max-width: 768px) {
    .text-mobile-xs { font-size: 0.75rem !important; }
    .text-mobile-sm { font-size: 0.875rem !important; }
    .text-mobile-base { font-size: 1rem !important; }
    .text-mobile-lg { font-size: 1.125rem !important; }
    .text-mobile-xl { font-size: 1.25rem !important; }
}

/* ========================================
   ANIMATION PERFORMANCE OPTIMIZATION
======================================== */

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
    * {
        animation-duration: 0.5s !important;
        transition-duration: 0.3s !important;
    }
}

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

/* ========================================
   FIX COMMON MOBILE ISSUES
======================================== */

/* Fix iOS button styling */
input[type="submit"],
input[type="button"],
button {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0.5rem;
}

/* Fix iOS input shadow */
input,
textarea {
    -webkit-appearance: none;
    appearance: none;
}

/* Improve tap highlight color */
* {
    -webkit-tap-highlight-color: rgba(245, 158, 11, 0.2);
}

/* Fix sticky positioning on iOS */
@supports (-webkit-overflow-scrolling: touch) {
    .header-fixed,
    header[class*="sticky"] {
        position: -webkit-sticky;
        position: sticky;
    }
}
