/* ==============================================
   GiftecCore - Mobile/Responsive Enhancements
   Optimized for mobile devices and tablets
   ============================================== */

/* ============================================
   0. FIX HORIZONTAL SCROLL (ALL DEVICES)
   ============================================ */

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

* {
    box-sizing: border-box;
}

.container-fluid, .container {
    max-width: 100%;
    overflow-x: hidden;
}

.row {
    margin-left: -15px;
    margin-right: -15px;
    max-width: calc(100% + 30px);
}

/* Ensure images don't cause overflow */
img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   1. MOBILE OPTIMIZATION (Max 767px)
   ============================================ */

@media (max-width: 767px) {
    /* Better tap targets */
    button, .btn, a, input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Larger fonts for readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Better spacing */
    .single_product {
        margin-bottom: 20px;
        padding: 15px;
    }

    /* Full-width cards on mobile */
    .product_row_2,
    .product_row_3,
    .product_row_4 {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .product_row_2 .single_product,
    .product_row_3 .single_product,
    .product_row_4 .single_product {
        width: 100%;
        max-width: 100%;
    }

    /* Header adjustments */
    .header_top {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }

    .header_logo img {
        max-width: 150px;
    }

    .header_number_text h2 {
        font-size: 18px;
    }

    /* Mobile menu improvements */
    .hamburger-menu {
        z-index: 9999;
    }

    .menu__box {
        background: white;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        padding: 20px;
    }

    .menu__item {
        padding: 15px 10px;
        border-bottom: 1px solid #eee;
        transition: all 0.3s ease;
    }

    .menu__item:hover {
        background: rgba(0, 123, 255, 0.05);
        padding-right: 15px;
    }

    /* Hero slider on mobile */
    .hero_slider_content {
        padding: 20px;
    }

    .hero_slider_content h2 {
        font-size: 22px;
    }

    .hero_slider_content p {
        font-size: 14px;
    }

    /* Search bar mobile */
    .midddle_search input {
        width: 100%;
        font-size: 16px;
    }

    /* Footer adjustments */
    .footer_section {
        padding: 30px 15px;
    }

    .footer_single {
        margin-bottom: 30px;
    }

    /* Category menu on mobile */
    .menu_left {
        width: 100%;
        margin-bottom: 20px;
    }

    .product_area {
        width: 100%;
    }

    /* Improved cart/wishlist icons */
    .right_menu ul li {
        margin: 0 8px;
    }

    .right_menu img {
        width: 24px;
        height: 24px;
    }

    /* Better breadcrumbs */
    .breadcrumb {
        font-size: 12px;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Product details on mobile */
    .product_hover {
        flex-direction: column;
    }

    .hover_left,
    .hover_right {
        width: 100%;
    }

    .hover_p_img img {
        max-width: 100%;
        height: auto;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    /* Modal on mobile */
    .modal {
        padding: 20px;
    }

    /* Sticky header on mobile */
    .header_section {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: white;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   2. TABLET OPTIMIZATION (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    /* 2-column layout for products */
    .product_row_2,
    .product_row_3,
    .product_row_4 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    /* Header layout */
    .header_top {
        padding: 20px;
    }

    /* Menu adjustments */
    .left_menu ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .left_menu ul li {
        margin: 5px 10px;
    }

    /* Sidebar width */
    .menu_left {
        width: 30%;
    }

    .product_area {
        width: 68%;
    }

    /* Footer grid */
    .footer_all {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

/* ============================================
   3. TOUCH-FRIENDLY INTERACTIONS
   ============================================ */

/* Remove hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .single_product:hover {
        transform: none;
    }

    .single_product .view {
        opacity: 1; /* Always show on touch */
    }

    /* Tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.2);
    }
}

/* ============================================
   4. ORIENTATION ADJUSTMENTS
   ============================================ */

/* Landscape mode on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .hero_section {
        height: 60vh;
    }

    .hero_slider_content {
        padding: 15px;
    }

    /* Reduce header size */
    .header_top {
        padding: 10px;
    }

    .header_logo img {
        max-width: 100px;
    }
}

/* ============================================
   5. ACCESSIBILITY FOR MOBILE
   ============================================ */

/* Larger focus indicators for mobile */
@media (max-width: 767px) {
    *:focus-visible {
        outline: 4px solid #007bff;
        outline-offset: 3px;
    }
}

/* ============================================
   6. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Disable animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   7. DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a1a;
        color: #f0f0f0;
    }

    .header_section {
        background: #2a2a2a;
        border-bottom: 1px solid #3a3a3a;
    }

    .single_product {
        background: #2a2a2a;
        border: 1px solid #3a3a3a;
    }

    .footer_section {
        background: #2a2a2a;
    }

    input[type="text"],
    input[type="email"],
    input[type="search"],
    textarea {
        background: #3a3a3a;
        color: #f0f0f0;
        border-color: #4a4a4a;
    }
}

/* ============================================
   8. SWIPE GESTURES (MOBILE)
   ============================================ */

.swipe-container {
    touch-action: pan-y;
}

/* Carousel touch improvements */
.owl-carousel {
    touch-action: manipulation;
}

/* ============================================
   9. SAFE AREA INSETS (NOTCH SUPPORT)
   ============================================ */

@supports (padding: max(0px)) {
    .header_section {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .footer_section {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   10. MOBILE SEARCH ENHANCEMENTS
   ============================================ */

@media (max-width: 767px) {
    .mobile_section_menu_search {
        position: sticky;
        top: 60px;
        background: white;
        z-index: 999;
        padding: 10px 0;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    .for_m input {
        border-radius: 25px;
        padding: 12px 40px 12px 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .toggle_icon_div {
        cursor: pointer;
        padding: 10px;
    }
}

/* ============================================
   11. MOBILE IMAGE OPTIMIZATION
   ============================================ */

@media (max-width: 767px) {
    img {
        max-width: 100%;
        height: auto;
    }

    /* Lazy load placeholder */
    img[loading="lazy"] {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s ease-in-out infinite;
    }

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

/* ============================================
   12. MOBILE MODAL IMPROVEMENTS
   ============================================ */

@media (max-width: 767px) {
    .modal {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 15px;
    }

    .modal-content {
        padding: 20px;
    }

    /* Close button */
    .modal .close {
        font-size: 32px;
        padding: 10px;
    }
}

/* ============================================
   13. BETTER GRID LAYOUTS FOR MOBILE
   ============================================ */

@media (max-width: 767px) {
    /* Flexible grid */
    .item_menu_flex {
        display: flex;
        flex-direction: column;
    }

    /* Stack elements */
    .default_title {
        text-align: center;
        margin-bottom: 20px;
    }

    .border_2_px {
        margin: 10px auto;
    }
}

/* ============================================
   14. PULL-TO-REFRESH SUPPORT
   ============================================ */

body {
    overscroll-behavior-y: contain;
}

/* ============================================
   15. IMPROVED CART/WISHLIST ON MOBILE
   ============================================ */

@media (max-width: 767px) {
    .cart span,
    .love span {
        min-width: 20px;
        min-height: 20px;
        font-size: 12px;
        padding: 2px 6px;
    }

    /* Bottom navigation bar for mobile */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-around;
        padding: 10px;
        z-index: 1000;
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 5px;
        color: #666;
        text-decoration: none;
        font-size: 12px;
    }

    .mobile-bottom-nav a.active {
        color: #007bff;
    }

    .mobile-bottom-nav img {
        width: 24px;
        height: 24px;
        margin-bottom: 5px;
    }
}

/* ============================================
   END OF MOBILE ENHANCEMENTS
   ============================================ */
