/* MG Variants - Front-end Styles */

/* Container principal */
.mg-variants {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.mg-variant {
    margin-bottom: 20px;
}

/* Primary feature (Colors) */
.mg-variant-primary {
    margin-bottom: 15px;
}

.mg-variant-primary-label {
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 15px;
}

.mg-variant-primary-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mg-primary-option {
	display: block;
	border: 1px solid #dee2e6;
	border-radius: 4px;
	text-decoration: none;
	color: #333;
	background: #fff;
	min-width: 72px;
	text-align: center;
	transition: all 0.2s;
	cursor: pointer;
	position: relative;
}

.mg-primary-option:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.mg-primary-option.mg-primary-selected {
    border-color: #007bff;
}

.mg-primary-option-image {
    width: 90px;
    height: 90px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 3px;
    margin-bottom: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.mg-primary-option-feature-image {
    width: 40px;
    height: 40px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 3px;
    margin-bottom: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.mg-primary-option-value {
    font-weight: bold;
    font-size: 13px;
}

.mg-primary-option-value-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	padding: 4px 6px;
	font-size: 10px;
	font-weight: 500;
	text-align: center;
	opacity: 0;
	transition: opacity 0.2s;
	border-radius: 0 0 2px 2px;
}

.mg-primary-option:hover .mg-primary-option-value-overlay {
    opacity: 1;
}

.mg-primary-option.mg-primary-selected .mg-primary-option-value-overlay {
    opacity: 1;
}

/* Secondary feature (Sizes) */
.mg-variant-secondary {
    margin-top: 15px;
}

.mg-variant-secondary-label {
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 15px;
}

/* Dropdown mode - Custom dropdown */
.mg-secondary-select-wrapper {
    position: relative;
    max-width: 400px;
}

.mg-custom-select {
    position: relative;
    width: 100%;
}

.mg-custom-select-trigger {
    width: 100%;
    font-size: 14px;
    padding: 12px 35px 12px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mg-custom-select-trigger:hover {
    border-color: #999;
}

.mg-custom-select-arrow {
    color: #666;
    font-size: 10px;
    transition: transform 0.2s;
}

.mg-custom-select.open .mg-custom-select-arrow {
    transform: rotate(180deg);
}

.mg-custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.mg-custom-select.open .mg-custom-select-options {
    display: block;
}

.mg-custom-select-option {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f5f5;
    margin: 2px 0;
    font-size: 14px;
}

.mg-custom-select-option:hover:not(.disabled) {
    background: #007bff;
    color: #fff;
}

.mg-custom-select-option.selected {
    background: #007bff;
    color: #fff;
}

.mg-custom-select-option.disabled {
    color: #ccc;
    cursor: not-allowed;
    background: #fafafa;
}

.mg-custom-select-option-check {
    margin-right: 8px;
    font-weight: bold;
}

.mg-custom-select-option-stock {
    font-size: 13px;
}

/* Thumbnails mode */
.mg-secondary-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mg-secondary-option {
    display: block;
    padding: 12px 18px;
    position: relative;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background: #fff;
    min-width: 90px;
    text-align: center;
    transition: all 0.2s;
}

.mg-secondary-option:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.mg-secondary-option.mg-secondary-selected {
    border-color: #007bff;
}

.mg-secondary-option-unavailable {
    color: #999;
    background: #f5f5f5;
}

.mg-secondary-option-value {
    font-weight: bold;
    font-size: 15px;
    display: block;
}

.mg-secondary-option-price {
    display: block;
    font-size: 13px;
    color: #007bff;
    font-weight: 600;
    margin-top: 4px;
}

.mg-secondary-option-stock {
    display: block;
    font-size: 11px;
    margin-top: 2px;
}

.mg-secondary-option-stock.mg-stock-available {
    color: #28a745;
}

.mg-secondary-option-stock.mg-stock-unavailable {
    color: #dc3545;
}

.mg-secondary-option-cross {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 100%;
    height: 1px;
    background: #dc3545;
}

/* Single feature mode (backward compatibility) */
.mg-variant__header {
    margin-bottom: 12px;
}

.mg-variant__header-label {
    font-weight: bold;
    font-size: 15px;
}

.mg-variant-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mg-variant-thumb {
    display: block;
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background: #fff;
    min-width: 80px;
    text-align: center;
    transition: all 0.2s;
}

.mg-variant-thumb:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.mg-variant-thumb.mg-variant-thumb--selected {
    border-color: #007bff;
}

.mg-variant-thumb-unavailable {
    opacity: 0.6;
}

.mg-variant-thumb-value {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
}

.mg-variant-thumb-price {
    font-size: 13px;
    color: #007bff;
    font-weight: 600;
    margin-bottom: 3px;
}

.mg-variant-thumb-stock {
    font-size: 11px;
}

.mg-variant-thumb-stock-available {
    color: #28a745;
}

.mg-variant-thumb-stock-unavailable {
    color: #dc3545;
}

/* Dropdown select (single feature) */
.mg-variant-select {
    max-width: 300px;
    font-size: 14px;
    padding: 8px;
}

/* Three-level mode styles - Dropdown version */
.mg-three-level-groups {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.mg-three-level-groups.mg-hidden {
    display: none;
}

.mg-three-level-dropdown-wrapper {
    flex: 1 1 calc(50% - 8px);
    max-width: 450px;
}

.mg-three-level-dropdown-label {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
}

/* Modal for multiple products selection */
.mg-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
}

.mg-modal-overlay.show {
    display: block;
}

.mg-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: none;
}

.mg-modal.show {
    display: block;
}

.mg-modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mg-modal-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.mg-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mg-modal-close:hover {
    color: #000;
}

.mg-modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 140px);
}

.mg-modal-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.mg-modal-product {
    border: 2px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
    display: block;
}

.mg-modal-product:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
    transform: translateY(-2px);
}

.mg-modal-product-image {
    width: 100%;
    height: 150px;
    object-fit: contain;
    margin-bottom: 10px;
}

.mg-modal-product-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    color: #333;
}

.mg-modal-product-features {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.mg-modal-product-feature {
    margin: 3px 0;
}

.mg-modal-product-price {
    font-size: 16px;
    color: #007bff;
    font-weight: 600;
    margin-bottom: 5px;
}

.mg-modal-product-stock {
    font-size: 12px;
}

.mg-modal-product-stock.in-stock {
    color: #28a745;
}

.mg-modal-product-stock.out-of-stock {
    color: #dc3545;
}
