/**
 * WooCommerce Variation Swatches Styles
 * Save this as variation-swatches.css in your theme folder
 */

/* Container for swatches */
.ns-variation-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 15px;
}

/* Base swatch styles */
.ns-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* Color swatches */
.ns-swatch-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ns-swatch-color:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ns-swatch-color.ns-selected {
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

/* Add checkmark for selected color */
.ns-swatch-color.ns-selected::after {
    content: "✓";
    position: absolute;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Button swatches */
.ns-swatch-button {
    min-width: 50px;
    height: 40px;
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.ns-swatch-button:hover {
    border-color: #999;
    background-color: #f8f8f8;
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ns-swatch-button.ns-selected {
    border-color: #333;
    background-color: #333;
    color: #fff;
    font-weight: 600;
}

/* Disabled/unavailable swatches */
.ns-swatch.ns-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tooltip on hover */
.ns-swatch[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background-color: #333;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    margin-bottom: 5px;
    z-index: 10;
}

.ns-swatch-color[title]:hover::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    margin-bottom: -5px;
}

/* Hide original select dropdown */
.ns-original-select {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .variation-swatches {
        gap: 8px;
    }
    
    .swatch-color {
        width: 35px;
        height: 35px;
    }
    
    .swatch-button {
        min-width: 45px;
        height: 35px;
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* RTL Support for Persian/Arabic sites */
[dir="rtl"] .variation-swatches {
    direction: rtl;
}

/* Loading state (optional) */
.ns-variation-swatches.ns-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Out of stock indication */
.ns-swatch.ns-out-of-stock {
    opacity: 0.5;
    position: relative;
    cursor: not-allowed;
}

/* Cross line for out of stock color swatches */
.ns-swatch-color.ns-out-of-stock {
    background-image: linear-gradient(
        -45deg,
        transparent calc(50% - 1px),
        #e74c3c calc(50% - 1px),
        #e74c3c calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}

/* Cross line for out of stock button swatches */
.ns-swatch-button.ns-out-of-stock {
    text-decoration: line-through;
    background-color: #f5f5f5;
    color: #999;
    border-color: #ccc;
}

.ns-swatch-button.ns-out-of-stock::after {
    content: " (ناموجود)";
    font-size: 10px;
    margin-right: 3px;
}

/* Prevent hover effects on out of stock items */
.ns-swatch.ns-out-of-stock:hover {
    transform: none;
    box-shadow: none;
}

.ns-swatch-color.ns-out-of-stock:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ns-swatch-button.ns-out-of-stock:hover {
    transform: none;
    background-color: #f5f5f5;
    border-color: #ccc;
}

/* Custom scrollbar for variations table */
.variations {
    max-height: none;
}

/* Additional styling for variation labels */
.variations .label {
    margin-bottom: 5px;
    font-weight: 600;
}

/* Ensure proper spacing in variation form */
.variations_form .variations {
    margin-bottom: 20px;
}

.variations_form .variations tr {
    display: table-row;
}

.variations_form .variations td {
    padding: 10px 0;
    vertical-align: middle;
}

/* Out of stock message styling */
.ns-out-of-stock-message {
    position: absolute;
    bottom: -30px;
    left: 0;
    background-color: #e74c3c;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Make sure parent has position relative for absolute positioning */
.variations_form .value {
    position: relative;
}