#my-style-builder-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto 40px;
}

.msb-selection-sections {
    flex: 2;
    min-width: 60%;
    max-width: 100%;
}

.msb-preview-box {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    position: sticky; 
    top: 20px;
    padding: 20px;
    border: 1px solid #eee;
    background-color: #fcfcfc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.msb-section {
    margin-bottom: 30px;
    padding-bottom: 40px;
    border-bottom: 1px solid #eee;
}

.msb-modal-close-btn:hover {
    background-color: transparent !important;
    color: #cc0000; 
}

.msb-section-title {
    font-size: 20px !important;
    color: #333 !important;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #0073aa;
    display: inline-block;
}

.msb-product-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    overflow-x: hidden;
}

.msb-product-item {
    width: auto; 
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.msb-product-item:hover {
    border-color: #0073aa;
    box-shadow: 0 0 10px rgba(0, 115, 170, 0.3);
}

.msb-product-item.selected {
    border-color: #28a745; 
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5); 
}

.msb-product-item.msb-temp-selected {
    border-color: #28a745 !important; 
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5) !important; 
}

.msb-product-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

.msb-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    transition: transform 0.3s ease;
}

.msb-product-info {
    padding: 10px 8px;
    background-color: #f7f7f7;
    flex-grow: 1;
    text-align: center;
}

.msb-selection-status{
	text-align:center;
	margin-top:16px;
	font-size:14px;
}

.msb-preview-title{
	font-size:18px !important;
	text-align:center !important;
	padding: 15px !important;
}

.msb-product-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.msb-details-link {
    font-size: 12px;
    color: #0073aa !important;
    text-decoration: none;
}

.msb-selected-indicator {
    position: absolute;
    top: 5px;
    left: 5px; 
    background-color: #28a745;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
    z-index: 10;
}

.msb-product-item.selected .msb-selected-indicator,
.msb-product-item.msb-temp-selected .msb-selected-indicator {
    opacity: 1;
    transform: scale(1);
}

.msb-load-more-button {
    width: 100%;
    margin-top: 15px;
    background-color: transparent !important;
    color: #0073aa !important;
    border: 1px solid #0073aa !important;
    padding: 8px 15px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-radius: 4px;
}
.msb-load-more-button:hover {
    background-color: #0073aa !important;
    color: #fff !important;
}

/* START: Preview CSS */
.msb-combined-image-container {
    width: 100%;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 20px;
    position: relative; 
    height: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
    padding: 10px;
}

.msb-preview-layer {
    width: 100%;
    height: auto; 
    position: relative; 
    top: auto;
    left: auto;
    display: flex; 
    justify-content: center;
    align-items: center;
    overflow: hidden; 
    transition: opacity 0.4s ease-in-out;
    padding: 5px 0; 
}

.msb-preview-layer .msb-preview-image {
    width: 150px; 
    height: 150px;
    object-fit: contain; 
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.msb-preview-layer.active .msb-preview-image {
    opacity: 1;
}
/* END: Preview CSS */


.msb-total-info {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

#msb-total-price {
    color: #5082a1; 
    font-size: 16px;
}

#msb-add-to-cart-button {
    width: 100%;
    height: auto; 
    min-height: 50px;
    font-size: 1.1rem;
    padding: 10px 20px;
    background-color: #0073aa !important; 
    border: none !important; 
    transition: all 0.3s ease;
    line-height: 1.5; 
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap; 
    color: #fff !important; 
}

#msb-add-to-cart-button:hover:not(:disabled) {
    background-color: #5082a1 !important;
    border-color: #5082a1 !important;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

#msb-add-to-cart-button:disabled {
    background-color: #c1d8e6 !important;
    cursor: not-allowed;
    box-shadow: none;
}

.msb-cart-icon {
    margin-right: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.msb-cart-icon svg {
    width: 100%;
    height: 100%;
    fill: #fff;
    display: block;
}


.msb-loading-icon {
    margin-right: 10px; 
    margin-top: 0;
    font-size: 24px;
    line-height: 1;
    width: 24px;
    height: 24px;
    color: #fff;
    display: flex !important;
    align-items: center;
    justify-content: center;
}
.msb-loading-icon.hidden {
    display: none !important;
}


.msb-add-text {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; 
    width: 100%;
    text-align: center;
    font-weight: bold;
}
.msb-add-text > span {
    margin: 5px 0;
    font-weight: normal;
    display: inline-block;
}

.msb-add-text .msb-view-cart-link {
    margin-right: 10px;
    background: #ff6a00; 
    color: #fff;
    font-size: 0.9rem;
    font-weight: normal;
    padding: 5px 10px;
    text-decoration: none;
    line-height: 1;
    border-radius: 4px;
    border: none;
}


@media (max-width: 992px) {
    #my-style-builder-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .msb-selection-sections {
        min-width: 100%;
    }

    .msb-preview-box {
        position: static;
        max-width: 100%;
        order: 1; 
    }

    .msb-product-list,
    .msb-selected-item-display {
        grid-template-columns: repeat(3, 1fr) !important; 
    }
}

@media (max-width: 576px) {
    .msb-product-list,
    .msb-selected-item-display {
        grid-template-columns: repeat(3, 1fr) !important; 
    }
    
.msb-product-name {
    display: block;
    font-size: 12px;
    }
    .msb-product-item {
        display: block;
        width: auto;
        text-align: center;
        padding: 0;
    }
    
    .msb-product-image {
        width: 100%;
        height: 160px; /* ارتفاع موبایل افزایش یافته */
        margin: 0 auto;
    }
    
    .msb-product-info {
        text-align: center;
        display: block;
    }
}


.msb-selected-item-display .msb-product-image {
    height: 200px !important; /* FIX: افزایش ارتفاع برای نمایش کامل تصویر */
}

@media (max-width: 576px) {
    .msb-selected-item-display .msb-product-image {
        height: 160px !important; /* FIX: افزایش ارتفاع برای نمایش کامل تصویر در موبایل */
    }
}

.msb-selected-item-display .msb-product-image {
    height: 200px !important; /* FIX: افزایش ارتفاع برای نمایش کامل تصویر */
}

#msb-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.msb-modal-loading {
    padding: 20px 40px;
    background: #fff;
    border-radius: 8px;
    font-size: 1.2rem;
}

.msb-modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 30px;
    margin: 30px auto;
}

.msb-modal-close-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: #888;
}

.msb-modal-header h2 {
    margin: 0 0 20px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
	font-size: 18px !important;
}

.msb-modal-body {
    display: flex;
    gap: 20px;
}

.msb-modal-image {
    flex-basis: 40%;
    flex-shrink: 0;
}

.msb-modal-image img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.msb-modal-options {
    flex-basis: 60%;
}

.msb-variation-message {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
}

table td, table th {
    vertical-align: middle !important;
}

.msb-modal-options .variations select {
    width: 100%;
}

.msb-confirm-variation-btn {
    width: 100%;
    margin-top: 20px;
    background-color: #0073aa !important;
    color: #fff !important;
    border: none !important;
    padding: 10px 20px;
    font-weight: bold;
    font-size: 16px;
    transition: background-color 0.2s;
}

.msb-confirm-variation-btn:disabled {
    background-color: #ccc !important;
}

@media (max-width: 576px) {
    .msb-modal-body {
        flex-direction: column;
    }
    .msb-modal-content {
        padding: 15px;
    }
    .msb-modal-image, .msb-modal-options {
        flex-basis: 100%;
		text-align: center;
    }
	.msb-modal-close-btn{
		top:10px;
		left:10px;
}
}


.msb-add-to-style-button,
.msb-product-selected {
    width: 100%;
    margin-top: 15px !important;
    background-color: #0073aa !important;
    color: #fff !important;
    border: none !important;
    font-size: 1rem;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msb-add-to-style-button:hover {
    background-color: #5082a1 !important;
}

.msb-product-selected {
    background-color: #28a745 !important;
    cursor: default !important;
    opacity: 0.8;
}

.msb-product-selected:hover {
    background-color: #28a745 !important;
}

.msb-view-style-button {
    background-color: #ff6a00 !important;
    color: #fff !important;
    border: none !important;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
}

.msb-selected-item-display {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    min-height: 150px; 
    align-items: flex-start;
}

.msb-no-selection-message {
    font-size: 0.9rem !important;
    color: #888 !important;
    padding: 15px !important;
    background: #f0f0f0 !important;
    border-radius: 4px !important;
    width: 100% !important;
    text-align: center !important;
    grid-column: 1 / -1; 
}

.msb-selected-item-display .msb-product-item {
    width: auto !important; 
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

.msb-selected-item-display .msb-product-item.msb-temp-selected {
    border-color: #28a745 !important; 
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5) !important; 
}


.msb-selected-item-display .msb-product-image {
    height: 100% !important;
}


.msb-remove-item-btn {
    position: absolute !important;
    top: -15px !important;
    right: -15px !important;
    background-color: #dc3545 !important;
    color: #fff;
    border: 2px solid #fff !important;
    border-radius: 30% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important
;
    justify-content: center !important;
    align-items: center !important;
    cursor: pointer !important;
    z-index: 10 !important;
    transition: all 0.2s 
ease !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    padding: 12px 11px 0px 0px !important;
    line-height: 1 !important;
}

.msb-remove-item-btn:hover {
    background-color: #c82333; 
    transform: scale(1.05); 
}

.msb-remove-item-btn svg {
    display: block !important !important;
    width: 15px !important; 
    height: 15px !important;
}

.msb-loop-button {
    width: 100%;
    margin: 10px 0 0 0 !important;
    padding: 8px 10px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    text-align: center;
    border-radius: 4px;
    background-color: #f7f7f7 !important;
    color: #444 !important;
    border: 1px solid #ddd !important;
    transition: all 0.2s ease;
}

.msb-loop-button:hover {
    background-color: #eee !important;
    color: #0073aa !important;
    border-color: #0073aa !important;
}

.msb-loop-button.msb-product-selected {
    background-color: #28a745 !important;
    color: #fff !important;
    border-color: #28a745 !important;
    cursor: default !important;
}

.msb-loop-button.msb-product-selected:hover {
    background-color: #28a745 !important;
}

.product-element-bottom {
    padding-bottom: 10px;
}


.msb-style-button,
.msb-add-to-style-link,
.msb-loop-button { 
    width: 100%;
    margin: 10px 0 0 0 !important;
    padding: 8px 10px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    text-align: center !important;
    border-radius: 4px !important;
    background-color: #f7f7f7 !important;
    color: #444 !important;
    border: 1px solid #ddd !important;
    transition: all 0.2s ease !important;
}
.msb-style-button{
	margin-bottom: 40px !important;
    margin-right: 30px !important;	
}

.msb-style-button:hover,
.msb-add-to-style-link:hover {
    background-color: #eee !important;
    color: #0073aa !important;
    border-color: #0073aa !important;
}

.msb-product-selected {
    background-color: #28a745 !important;
    cursor: default !important;
    opacity: 0.8;
    color: #fff !important; 
    border-color: #28a745 !important;
}

.product-element-bottom .msb-style-button {
    display: none !important;
}