/**
 * Mix and Match Frontend Styles
 *
 * @package MixAndMatch
 */

/* Container */
.mnm-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
    clear: both;
    align-items: start;
}

.single-product .entry-summary {
    width: 100% !important;
}

/* Ensure Mix and Match interface images are always visible */
.mnm-product-image,
.mnm-product-image img,
.mnm-product-card img,
.mnm-container img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
}

/* Hide default WooCommerce add to cart when Mix and Match form is present */
.mnm-cart-form ~ form.cart:not(.mnm-cart-form),
.woocommerce div.product form.cart:not(.mnm-cart-form) {
    display: none !important;
}

/* Form container */
.mnm-cart-form {
    width: 100%;
    clear: both;
}

/* Products Wrapper */
.mnm-products-wrapper {
    min-width: 0;
    flex: 1;
}

.mnm-products-wrapper.mnm-products-grid {
    display: grid;
}

/* Grid Layout */
.mnm-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
}

.single-product div.product form.cart .quantity {
    float: none !important;
}

@media (max-width: 1400px) {
    .mnm-products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .mnm-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .mnm-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Hide grid when list layout is active */
.mnm-layout-list .mnm-products-grid {
    display: none !important;
}


/* List Layout - Force list display */
.mnm-products-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    grid-template-columns: none !important;
}

/* Override grid styles for list layout */
.mnm-layout-list .mnm-products-wrapper,
.mnm-layout-list .mnm-products-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    grid-template-columns: none !important;
}

.mnm-layout-list .mnm-products-grid {
    display: none !important;
}

/* Ensure list items are full width */
.mnm-layout-list .mnm-products-list .mnm-product-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* List Layout - Product Cards */
.mnm-layout-list .mnm-product-card,
.mnm-products-list .mnm-product-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    text-align: left !important;
    padding: 15px 20px !important;
    gap: 20px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    transition: all 0.3s ease !important;
    width: 100% !important;
    max-width: 100% !important;
}

.mnm-layout-list .mnm-product-card:hover {
    border-color: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
    transform: translateY(-1px);
}

.mnm-layout-list .mnm-product-card.selected {
    border-color: #4CAF50;
    background: #f8fef9;
}

.mnm-layout-list .mnm-product-image,
.mnm-products-list .mnm-product-image {
    width: 100px !important;
    min-width: 100px !important;
    height: 100px !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background: #fafafa !important;
    max-width: 100px !important;
}

.mnm-layout-list .mnm-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mnm-layout-list .mnm-product-details,
.mnm-products-list .mnm-product-details {
    flex: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 20px !important;
    min-width: 0 !important;
    width: auto !important;
}

.mnm-product-title-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.mnm-layout-list .mnm-product-title-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.mnm-layout-list .mnm-product-title {
    min-height: auto;
    margin: 0;
    text-align: left;
    flex: 1 1 auto;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    padding-right: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    max-width: 100%;
}

.mnm-layout-list .mnm-product-price {
    font-size: 16px;
    font-weight: 600;
    color: #4CAF50;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
    text-align: right;
}

.mnm-layout-list .mnm-quantity-controls {
    flex-shrink: 0;
    margin-left: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mnm-layout-list .mnm-qty-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
}

.mnm-layout-list .mnm-qty-input {
    width: 45px;
    height: 32px;
    font-size: 14px;
    text-align: center !important;
    padding: 0 2px;
    line-height: 32px;
    vertical-align: middle;
}

/* Product Card */
.mnm-product-card {
    background: #ffffff;
    border: 1.5px solid #f0f0f0;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.mnm-product-price {
    font-size: 11px;
    font-weight: 600;
    color: #4CAF50;
    margin: 3px 0;
}

.mnm-product-card:hover {
    border-color: #4CAF50;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
    transform: translateY(-2px);
}

.mnm-product-card.selected {
    border-color: #4CAF50;
    background: #f8fef9;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

/* Out of Stock Product Card */
.mnm-product-card.mnm-out-of-stock {
    opacity: 0.6;
    background: #f5f5f5;
    border-color: #d0d0d0;
    cursor: not-allowed;
    position: relative;
}

.mnm-product-card.mnm-out-of-stock:hover {
    border-color: #d0d0d0;
    box-shadow: none;
    transform: none;
}

.mnm-product-card.mnm-out-of-stock .mnm-product-image {
    position: relative;
}

.mnm-product-card.mnm-out-of-stock .mnm-product-image img {
    filter: grayscale(100%);
    opacity: 0.5;
}

.mnm-out-of-stock-badge {
    background: #f44336;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mnm-out-of-stock-badge-image {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Hide badge on image for list layout */
.mnm-layout-list .mnm-out-of-stock-badge-image {
    display: none;
}

/* Show badge above title for list layout */
.mnm-layout-list .mnm-out-of-stock-badge-title {
    display: inline-block;
    position: static;
    align-self: center;
    margin-bottom: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Hide badge above title for grid layout */
.mnm-layout-grid .mnm-out-of-stock-badge-title,
.mnm-products-grid .mnm-out-of-stock-badge-title {
    display: none;
}

/* Grid layout - hide title wrapper styling */
.mnm-layout-grid .mnm-product-title-wrapper,
.mnm-products-grid .mnm-product-title-wrapper {
    display: block;
}

.mnm-stock-message {
    font-size: 12px;
    color: #f44336;
    font-weight: 600;
    margin: 5px 0;
    padding: 6px 10px;
    background: #ffebee;
    border-radius: 6px;
    text-align: center;
    display: none;
}

.mnm-quantity-controls.mnm-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.mnm-quantity-controls.mnm-disabled .mnm-qty-btn,
.mnm-quantity-controls.mnm-disabled .mnm-qty-input {
    cursor: not-allowed;
    background: #f5f5f5;
    color: #999;
}

.mnm-product-card.mnm-out-of-stock .mnm-product-title {
    color: #999;
}

.mnm-product-card.mnm-out-of-stock .mnm-product-price {
    color: #999;
}

/* Product Image */
.mnm-product-image {
    margin-bottom: 6px;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    position: relative;
    width: 100%;
}

.mnm-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mnm-product-card:hover .mnm-product-image img {
    transform: scale(1.05);
}

/* Product Details */
.mnm-product-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mnm-product-title {
    font-size: 11px;
    font-weight: 600;
    color: #4CAF50;
    margin: 0;
    line-height: 1.2;
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quantity Controls */
.mnm-quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 4px;
}

.mnm-qty-btn {
    width: 24px;
    height: 24px;
    border: 1.5px solid #4CAF50;
    background: #ffffff;
    color: #4CAF50;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.mnm-qty-btn:hover:not(.disabled) {
    background: #4CAF50;
    color: #ffffff;
    transform: scale(1.05);
}

.mnm-qty-btn:active:not(.disabled) {
    transform: scale(0.95);
}

.mnm-qty-btn.disabled {
    border-color: #e0e0e0;
    color: #bdbdbd;
    cursor: not-allowed;
    opacity: 0.5;
}

.mnm-qty-input {
    width: 32px;
    height: 24px;
    text-align: center !important;
    border: 1.5px solid #e0e0e0;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #333;
    background: #f9f9f9;
    padding: 0 2px;
    margin: 0;
    line-height: 24px;
    vertical-align: middle;
}

.mnm-product-card.selected .mnm-qty-input {
    border-color: #4CAF50;
    background: #ffffff;
}

/* Custom instruction text above selection area */
.mnm-instruction-text {
    margin-bottom: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

.mnm-instruction-text strong {
    color: #333;
    font-weight: 500;
}

/* Box Builder */
.mnm-box-builder {
    background: #ffffff;
    border: 2px solid #f0f0f0;
    border-radius: 16px;
    padding: 35px;
    position: sticky;
    top: 20px;
    max-width: 400px;
    min-width: 340px;
    align-self: start;
    height: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-left: 20px;
}

.mnm-box-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin: 0 0 25px 0;
    text-align: center;
    letter-spacing: 1px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

/* Button Group Above Box Visual */
.mnm-button-group-above-box {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #ffffff;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

/* Hide collapsible toggle and show box visuals directly */
.mnm-selected-items-collapsible {
    display: none !important;
}

.mnm-selected-items-toggle {
    display: none !important;
}

.mnm-selected-items-content {
    display: none !important;
}

/* Single box visual that adapts to all screen sizes */
.mnm-box-visual {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #fafafa;
    border-radius: 12px;
    transition: transform 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

/* Mobile/Tablet: Adjust grid columns */
@media (max-width: 768px) {
    .mnm-box-visual {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        padding: 12px !important;
    }
}

/* Box Visual */
.mnm-box-visual {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #fafafa;
    border-radius: 12px;
    transition: transform 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

/* Scrollbar styling for box visual (desktop - vertical scroll) */
@media (min-width: 769px) {
    .mnm-box-visual::-webkit-scrollbar {
        width: 8px;
    }

    .mnm-box-visual::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }

    .mnm-box-visual::-webkit-scrollbar-thumb {
        background: var(--mnm-primary-color, #4CAF50);
        border-radius: 10px;
    }

    .mnm-box-visual::-webkit-scrollbar-thumb:hover {
        background: var(--mnm-primary-color-hover, #45a049);
        opacity: 0.8;
    }
}

.mnm-box-visual.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.mnm-box-slot {
    aspect-ratio: 1;
    border: 2px dashed #d0d0d0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    transition: all 0.3s ease;
    min-width: 50px;
    min-height: 50px;
    width: 100%;
    height: auto;
    position: relative;
    box-sizing: border-box;
}

.mnm-box-slot:hover {
    border-color: #4CAF50;
    background: #f8fef9;
}

.mnm-box-slot.filled {
    border-color: #4CAF50;
    border-style: solid;
    background: #f8fef9;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.mnm-box-slot.filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Counter */
.mnm-counter {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px 18px;
    background: linear-gradient(135deg, #f8fef9 0%, #e8f5e9 100%);
    border-radius: 12px;
    border: 2px solid #4CAF50;
}

.mnm-counter-current {
    font-size: 32px;
    font-weight: 700;
    color: #4CAF50;
}

.mnm-counter-separator {
    font-size: 24px;
    color: #999;
    margin: 0 5px;
}

.mnm-counter-total {
    font-size: 32px;
    font-weight: 700;
    color: #666;
}

.mnm-counter-label {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Price Summary */
.mnm-price-summary {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8fef9;
    border-radius: 10px;
}

.mnm-price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.mnm-price-label {
    color: #666;
}

.mnm-price-amount {
    color: #4CAF50;
    font-size: 24px;
}

.mnm-price-breakdown {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
}

.mnm-base-price,
.mnm-selected-price {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    color: #666;
}

.mnm-base-price-amount,
.mnm-selected-price-amount {
    font-weight: 600;
    color: #333;
}

/* Discount Info */
.mnm-discount-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid #4CAF50;
    font-size: 14px;
}

.mnm-discount-amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2e7d32;
}

.mnm-discount-value {
    color: #4CAF50;
    font-size: 18px;
    font-weight: 700;
}

.mnm-discount-message {
    padding: 8px 12px;
    background: #e8f5e9;
    border-radius: 6px;
    color: #2e7d32;
    font-size: 13px;
    text-align: center;
    font-weight: 500;
}

/* Selection Status */
.mnm-selection-status {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    margin-top: 15px;
}

/* Minimum Selection Message */
.mnm-min-selection-message {
    padding: 14px 18px;
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    color: #721c24;
    margin: 15px 0;
    font-weight: 600;
    display: block;
}

.mnm-min-notice {
    padding: 10px;
    background: #fff3e0;
    color: #e65100;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    margin-bottom: 10px;
}

/* Button Group Container */
/* Quantity Wrapper */
.mnm-quantity-wrapper {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8fef9;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.mnm-quantity-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.mnm-quantity-wrapper .quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mnm-quantity-wrapper .quantity input[type="number"] {
    width: 60px;
    text-align: center;
    padding: 8px;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

.mnm-quantity-wrapper .quantity input[type="number"]:focus {
    outline: none;
    border-color: #45a049;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* Sold individually styling */
.mnm-quantity-wrapper.mnm-sold-individually .quantity input[type="number"] {
    cursor: not-allowed;
    background: #f5f5f5;
    opacity: 0.6;
}

.mnm-quantity-wrapper.mnm-sold-individually .quantity input[type="number"]:focus {
    box-shadow: none;
    border-color: #4CAF50;
}

.mnm-button-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 25px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* Hide Clear and Add to Cart buttons initially */
.mnm-clear-btn.mnm-hidden,
.mnm-add-to-cart-btn.mnm-hidden {
    display: none !important;
}

/* Ensure buttons in above-box group are always visible */
.mnm-button-group-above-box .mnm-clear-btn {
    display: inline-flex !important;
}

/* When clear button is hidden (no selections), keep it visible but disabled */
.mnm-button-group-above-box .mnm-clear-btn.mnm-hidden {
    display: inline-flex !important;
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    background: #cccccc !important;
    color: #999 !important;
}

/* Action Buttons (Clear, Add to Cart) */
.mnm-action-btn {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Clear Button */
.mnm-clear-btn {
    background: #f44336;
    color: #ffffff;
}

.mnm-clear-btn:hover:not(:disabled) {
    background: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.mnm-clear-btn:disabled {
    background: #ffcdd2;
    color: #999;
    cursor: not-allowed;
}

/* Add to Cart Button */
.mnm-add-to-cart-btn {
    background: #4CAF50;
    color: #ffffff;
    font-size: 13px;
    padding: 10px 16px;
}

.mnm-add-to-cart-btn:hover:not(.disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.mnm-add-to-cart-btn.disabled {
    background: #cccccc;
    color: #666;
    cursor: not-allowed;
}

/* Button active state */
.mnm-action-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Validation Messages */
.mnm-validation-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

.mnm-validation-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
    font-weight: 600;
    padding: 14px 18px;
    font-size: 15px;
}

.mnm-validation-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.mnm-min-notice {
    padding: 10px;
    background: #fff3e0;
    color: #e65100;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    margin-bottom: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Responsive Design */
@media (max-width: 1200px) and (min-width: 769px) {
    .mnm-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .mnm-box-builder {
        position: relative !important;
        max-width: 100% !important;
        min-width: auto !important;
        top: 0 !important;
    }
    
    .mnm-box-visual {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        padding: 12px;
    }
    
    .mnm-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mnm-button-group-above-box {
        gap: 8px;
        padding: 8px 0;
    }
    
    .mnm-button-group {
        gap: 8px;
    }
    
    .mnm-action-btn {
        padding: 9px 14px;
        font-size: 12px;
    }
}

@media (max-width: 1024px) {
    /* Tablet: Change container layout - box first, then products (similar to mobile) */
    .mnm-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
        grid-template-columns: none !important;
        margin: 20px 15px !important;
        padding: 0 15px 0 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Box builder appears first on tablet */
    .mnm-box-builder {
        order: -1 !important;
        position: relative !important;
        max-width: 100% !important;
        min-width: auto !important;
        width: 100% !important;
        padding: 20px 15px !important;
        margin: 0 0 20px 0 !important;
        box-sizing: border-box !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-self: flex-start !important;
        background: #ffffff !important;
        border: 2px solid #f0f0f0 !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
        z-index: 1 !important;
    }
    
    /* Ensure products wrapper appears after box on tablet */
    .mnm-products-wrapper {
        order: 2 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    .mnm-box-visual {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 12px;
    }
    
    .mnm-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .mnm-layout-list .mnm-product-details {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .mnm-layout-list .mnm-product-price {
        min-width: auto;
    }
    
    .mnm-button-group-above-box {
        gap: 8px;
        padding: 8px 0;
        position: relative !important;
    }
    
    .mnm-button-group {
        gap: 8px;
    }
    
    .mnm-action-btn {
        padding: 9px 14px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    /* Mobile: Change container layout - box first, then products */
    .mnm-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
        grid-template-columns: none !important;
        margin: 20px 15px !important;
        padding: 0 15px 0 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Ensure parent containers don't interfere */
    .mnm-cart-form {
        overflow: visible !important;
    }
    
    /* Ensure WooCommerce containers don't interfere */
    .single-product .entry-summary,
    .woocommerce div.product .summary,
    .woocommerce div.product form.cart {
        overflow: visible !important;
    }
    
    /* Box builder appears first on mobile - NO STICKY to prevent covering products */
    .mnm-box-builder {
        order: -1 !important;
        position: relative !important;
        max-width: 100% !important;
        min-width: auto !important;
        width: 100% !important;
        padding: 20px 15px !important;
        margin: 0 0 20px 0 !important;
        box-sizing: border-box !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-self: flex-start !important;
        background: #ffffff !important;
        border: 2px solid #f0f0f0 !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
        z-index: 1 !important;
    }
    
    .mnm-box-title {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .mnm-counter {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .mnm-price-summary {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .mnm-button-group-above-box {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-wrap: wrap !important;
        position: relative !important;
        background: #ffffff !important;
        padding: 10px 0 !important;
        margin-bottom: 15px !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }
    
    .mnm-button-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-wrap: wrap !important;
    }
    
    .mnm-clear-btn.mnm-hidden,
    .mnm-add-to-cart-btn.mnm-hidden {
        display: none !important;
    }
    
    .mnm-button-group-above-box .mnm-clear-btn.mnm-hidden {
        display: inline-flex !important;
        opacity: 0.5 !important;
        pointer-events: none !important;
        cursor: not-allowed !important;
        background: #cccccc !important;
        color: #999 !important;
    }
    
    .mnm-action-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        flex: 0 0 auto !important;
    }
    
    /* Ensure products wrapper appears after box */
    .mnm-products-wrapper {
        order: 2 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    .mnm-box-slot {
        flex: 0 0 auto !important;
        /* min-width: 65px !important; */
        /* min-height: 65px !important; */
        /* width: 65px !important; */
        /* height: 65px !important; */
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Horizontal scrollbar styling for box visual on mobile */
    .mnm-box-visual::-webkit-scrollbar {
        height: 6px;
        width: auto;
    }

    .mnm-box-visual::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }

    .mnm-box-visual::-webkit-scrollbar-thumb {
        background: var(--mnm-primary-color, #4CAF50);
        border-radius: 10px;
    }

    .mnm-box-visual::-webkit-scrollbar-thumb:hover {
        background: var(--mnm-primary-color-hover, #45a049);
        opacity: 0.8;
    }
    
    .mnm-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    .mnm-product-card {
        padding: 8px !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }

    .mnm-product-title {
        font-size: 11px !important;
        min-height: 26px !important;
        line-height: 1.2 !important;
    }
    
    .mnm-product-price {
        font-size: 11px !important;
        margin: 3px 0 !important;
    }
    
    .mnm-product-image {
        margin-bottom: 6px !important;
        border-radius: 6px !important;
    }
    
    .mnm-qty-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 14px !important;
        border-radius: 4px !important;
    }
    
    .mnm-qty-input {
        width: 32px !important;
        height: 24px !important;
        font-size: 11px !important;
        line-height: 24px !important;
        border-radius: 4px !important;
    }
    
    .mnm-quantity-controls {
        gap: 4px !important;
        margin-top: 4px !important;
    }

    .mnm-layout-list .mnm-product-card {
        flex-direction: row;
        padding: 12px 15px;
        gap: 15px;
    }

    .mnm-layout-list .mnm-product-image {
        width: 80px;
        min-width: 80px;
        height: 80px;
    }

    .mnm-layout-list .mnm-product-details {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .mnm-layout-list .mnm-product-title {
        font-size: 14px;
        padding-right: 10px;
        flex: 1 1 100%;
    }
    
    .mnm-layout-list .mnm-product-price {
        font-size: 14px;
        min-width: auto;
        flex: 0 0 auto;
    }
    
    .mnm-layout-list .mnm-quantity-controls {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    /* Keep 2 columns on mobile as requested */
    .mnm-container {
        margin: 15px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 15px !important;
    }
    
    .mnm-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .mnm-product-card {
        padding: 8px !important;
    }
    
    .mnm-product-title {
        font-size: 10px !important;
        min-height: 24px !important;
    }
    
    .mnm-product-price {
        font-size: 10px !important;
    }
    
    .mnm-qty-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 12px !important;
    }
    
    .mnm-qty-input {
        width: 28px !important;
        height: 22px !important;
        font-size: 10px !important;
        line-height: 22px !important;
    }

    .mnm-counter-current,
    .mnm-counter-total {
        font-size: 24px;
    }
    
    .mnm-box-builder {
        padding: 15px 12px !important;
    }
    
    .mnm-button-group-above-box {
        gap: 6px !important;
        padding: 8px 0 !important;
    }
    
    .mnm-button-group {
        gap: 6px !important;
    }
    
    .mnm-action-btn {
        padding: 8px 10px !important;
        font-size: 11px !important;
    }
    
    .mnm-box-visual {
        padding: 10px 6px !important;
        gap: 6px !important;
        min-height: 75px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-wrap: wrap !important;
    }
    
    .mnm-box-slot {
        flex: 0 0 auto !important;
        min-width: 55px !important;
        min-height: 55px !important;
        width: 55px !important;
        height: 55px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Loading State */
.mnm-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Print Styles */
@media print {
    .mnm-quantity-controls {
        display: none;
    }
}

