/**
 * Vitalis.bg Mobile Optimizations
 * WooCommerce Mobile Responsiveness Improvements
 * Created: 2024
 */

/* ========================================
   MOBILE BASE STYLES
   ======================================== */

@media screen and (max-width: 768px) {

    /* Mobile-first approach for better performance */
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

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

    /* Better mobile typography */
    body {
        font-size: 16px !important;
        line-height: 1.6;
    }

    /* Container adjustments */
    .site-content .ast-container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* ========================================
   WOOCOMMERCE MOBILE OPTIMIZATIONS
   ======================================== */

@media screen and (max-width: 768px) {

    /* Product Grid Optimization */
    .woocommerce ul.products,
    ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 0 !important;
    }

    .woocommerce ul.products li.product,
    ul.products li.product {
        width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    /* Product Images */
    .woocommerce ul.products li.product a img,
    ul.products li.product a img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
    }

    /* Product Titles */
    .woocommerce ul.products li.product h2,
    .woocommerce ul.products li.product .woocommerce-loop-product__title,
    ul.products li.product h2 {
        font-size: 14px !important;
        line-height: 1.3 !important;
        margin: 8px 0 !important;
        min-height: 40px;
    }

    /* Product Price */
    .woocommerce ul.products li.product .price,
    ul.products li.product .price {
        font-size: 16px !important;
        font-weight: bold !important;
        margin-bottom: 10px !important;
    }

    /* Add to Cart Buttons */
    .woocommerce ul.products li.product .button,
    ul.products li.product .button {
        width: 100% !important;
        padding: 10px 5px !important;
        font-size: 13px !important;
        min-height: 40px !important;
        display: block !important;
        text-align: center !important;
    }

    /* Stock Status Badge Fix */
    .woocommerce ul.products li.product {
        position: relative !important;
    }

    .woocommerce ul.products li.product span[style*="position: absolute"] {
        position: static !important;
        transform: none !important;
        left: auto !important;
        bottom: auto !important;
        margin-top: 5px !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        padding: 3px !important;
    }
}

/* ========================================
   SINGLE PRODUCT PAGE MOBILE
   ======================================== */

@media screen and (max-width: 768px) {

    /* Product Gallery */
    .woocommerce div.product div.images,
    .woocommerce div.product div.summary {
        width: 100% !important;
        float: none !important;
        margin-bottom: 20px !important;
    }

    /* Product Summary */
    .woocommerce div.product .summary {
        padding: 0 !important;
    }

    /* Product Title */
    .woocommerce div.product .product_title {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }

    /* Quantity Input */
    .woocommerce .quantity .qty {
        width: 60px !important;
        padding: 10px !important;
        font-size: 16px !important;
    }

    /* Add to Cart Button */
    .woocommerce div.product form.cart .button {
        width: 100% !important;
        padding: 15px !important;
        font-size: 16px !important;
        margin-top: 10px !important;
    }

    /* Product Tabs */
    .woocommerce div.product .woocommerce-tabs ul.tabs {
        display: block !important;
    }

    .woocommerce div.product .woocommerce-tabs ul.tabs li {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        border-bottom: 1px solid #ddd !important;
    }

    .woocommerce div.product .woocommerce-tabs ul.tabs li a {
        display: block !important;
        padding: 12px 15px !important;
    }
}

/* ========================================
   CART PAGE MOBILE
   ======================================== */

@media screen and (max-width: 768px) {

    /* Cart Table to Cards */
    .woocommerce table.shop_table {
        display: block !important;
        border: none !important;
    }

    .woocommerce table.shop_table thead {
        display: none !important;
    }

    .woocommerce table.shop_table tbody,
    .woocommerce table.shop_table tr,
    .woocommerce table.shop_table td {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    .woocommerce table.shop_table tr {
        margin-bottom: 20px !important;
        border: 1px solid #ddd !important;
        padding: 15px !important;
        border-radius: 8px !important;
        background: #fff !important;
    }

    .woocommerce table.shop_table td {
        padding: 10px 0 !important;
        position: relative !important;
        padding-left: 35% !important;
    }

    .woocommerce table.shop_table td:before {
        content: attr(data-title) !important;
        position: absolute !important;
        left: 0 !important;
        width: 30% !important;
        font-weight: bold !important;
    }

    /* Cart Totals */
    .woocommerce .cart-collaterals .cart_totals {
        width: 100% !important;
        float: none !important;
    }

    /* Update Cart Button */
    .woocommerce .cart .actions .button {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
}

/* ========================================
   CHECKOUT PAGE MOBILE
   ======================================== */

@media screen and (max-width: 768px) {

    /* Checkout Columns */
    .woocommerce-checkout .col2-set .col-1,
    .woocommerce-checkout .col2-set .col-2 {
        width: 100% !important;
        float: none !important;
    }

    /* Form Fields */
    .woocommerce form .form-row {
        width: 100% !important;
        float: none !important;
    }

    .woocommerce form .form-row input,
    .woocommerce form .form-row select,
    .woocommerce form .form-row textarea {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important;
    }

    /* Order Review */
    #order_review_heading,
    #order_review {
        width: 100% !important;
        float: none !important;
    }

    /* Place Order Button */
    #place_order {
        width: 100% !important;
        padding: 15px !important;
        font-size: 18px !important;
    }
}

/* ========================================
   HEADER & NAVIGATION MOBILE
   ======================================== */

@media screen and (max-width: 768px) {

    /* Mobile Menu Toggle */
    .ast-mobile-menu-buttons {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Cart Icon */
    .ast-header-woo-cart {
        margin-left: 10px !important;
    }

    /* Search Bar */
    .ast-search-box {
        width: 100% !important;
    }

    .search-field {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important;
    }
}

/* ========================================
   BULGARIAN LANGUAGE SPECIFIC
   ======================================== */

@media screen and (max-width: 768px) {

    /* Adjust for Bulgarian text length */
    .woocommerce ul.products li.product .button {
        word-wrap: break-word !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }

    /* Backorder message optimization */
    p[style*="color: #e67e22"] {
        font-size: 12px !important;
        line-height: 1.3 !important;
        padding: 5px !important;
        margin-bottom: 5px !important;
    }

    p[style*="color: #d35400"] {
        font-size: 14px !important;
        line-height: 1.3 !important;
        padding: 8px !important;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

@media screen and (max-width: 768px) {

    /* Optimize animations */
    * {
        animation-duration: 0.3s !important;
    }

    /* Hardware acceleration for smooth scrolling */
    .woocommerce ul.products {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    /* Reduce shadows on mobile for performance */
    .woocommerce ul.products li.product {
        box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    }
}

/* ========================================
   SMALL MOBILE DEVICES (< 380px)
   ======================================== */

@media screen and (max-width: 380px) {

    /* Single column on very small screens */
    .woocommerce ul.products,
    ul.products {
        grid-template-columns: 1fr !important;
    }

    /* Larger product images on single column */
    .woocommerce ul.products li.product a img {
        max-height: 250px !important;
        object-fit: cover !important;
    }

    /* Adjust font sizes */
    .woocommerce ul.products li.product h2,
    .woocommerce ul.products li.product .woocommerce-loop-product__title {
        font-size: 16px !important;
    }

    .woocommerce ul.products li.product .price {
        font-size: 18px !important;
    }
}