/**
 * Color Swatches Fix CSS - PROTECTED VERSION
 * إصلاح مشكلة عرض الألوان في السواتشات - نسخة محمية من التضارب
 */

/* ========================================
   PROTECTION FROM FORMATTING SYSTEM
   ======================================== */

/* Force color swatches to override any conflicting styles */
.cfvsw-swatches-option,
.cfvsw-swatches-option *,
.cfvsw-swatches-option.color-swatch-active,
.cfvsw-swatches-option.color-swatch-active * {
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    background-position: center !important;
}

/* ========================================
   BASIC COLOR SWATCH STYLING
   ======================================== */

/* Basic color swatch styling with maximum specificity */
body .cfvsw-swatches-option.color-swatch-active,
body .cfvsw-swatches-option[data-type="color"],
body .cfvsw-swatches-option[data-type="colour"],
body .cfvsw-swatches-option[data-attribute_type="color"],
body .cfvsw-swatches-option[data-attribute_type="colour"] {
    border: 3px solid rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    position: relative !important;
    overflow: hidden !important;
    color: transparent !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 60px !important;
    min-height: 60px !important;
    border-radius: 12px !important;
    margin: 4px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

/* Make text transparent for color swatches */
body .cfvsw-swatches-option.color-swatch-active .cfvsw-swatch-inner,
body .cfvsw-swatches-option[data-type="color"] .cfvsw-swatch-inner,
body .cfvsw-swatches-option[data-type="colour"] .cfvsw-swatch-inner {
    color: transparent !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
}

/* ========================================
   SPECIFIC COLOR VALUES WITH MAXIMUM SPECIFICITY
   ======================================== */

/* Red - أحمر */
body .cfvsw-swatches-option[data-slug*="red"],
body .cfvsw-swatches-option[data-slug*="أحمر"],
body .cfvsw-swatches-option[data-value*="red"],
body .cfvsw-swatches-option[data-value*="أحمر"],
body .cfvsw-swatches-option[data-slug*="red"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أحمر"].color-swatch-active {
    --swatch-color: #ff0000 !important;
    background-color: #ff0000 !important;
    background: #ff0000 !important;
    background-image: none !important;
}

/* Blue - أزرق */
body .cfvsw-swatches-option[data-slug*="blue"],
body .cfvsw-swatches-option[data-slug*="أزرق"],
body .cfvsw-swatches-option[data-slug*="الازرق"],
body .cfvsw-swatches-option[data-value*="blue"],
body .cfvsw-swatches-option[data-value*="أزرق"],
body .cfvsw-swatches-option[data-value*="الازرق"],
body .cfvsw-swatches-option[data-slug*="blue"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أزرق"].color-swatch-active {
    --swatch-color: #0000ff !important;
    background-color: #0000ff !important;
    background: #0000ff !important;
    background-image: none !important;
}

/* Green - أخضر */
body .cfvsw-swatches-option[data-slug*="green"],
body .cfvsw-swatches-option[data-slug*="أخضر"],
body .cfvsw-swatches-option[data-slug*="اخضر"],
body .cfvsw-swatches-option[data-value*="green"],
body .cfvsw-swatches-option[data-value*="أخضر"],
body .cfvsw-swatches-option[data-value*="اخضر"],
body .cfvsw-swatches-option[data-slug*="green"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أخضر"].color-swatch-active {
    --swatch-color: #00ff00 !important;
    background-color: #00ff00 !important;
    background: #00ff00 !important;
    background-image: none !important;
}

/* Yellow - أصفر */
body .cfvsw-swatches-option[data-slug*="yellow"],
body .cfvsw-swatches-option[data-slug*="أصفر"],
body .cfvsw-swatches-option[data-value*="yellow"],
body .cfvsw-swatches-option[data-value*="أصفر"],
body .cfvsw-swatches-option[data-slug*="yellow"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أصفر"].color-swatch-active {
    --swatch-color: #ffff00 !important;
    background-color: #ffff00 !important;
    background: #ffff00 !important;
    background-image: none !important;
}

/* Purple - بنفسجي */
body .cfvsw-swatches-option[data-slug*="purple"],
body .cfvsw-swatches-option[data-slug*="بنفسجي"],
body .cfvsw-swatches-option[data-slug*="بنفسج"],
body .cfvsw-swatches-option[data-value*="purple"],
body .cfvsw-swatches-option[data-value*="بنفسجي"],
body .cfvsw-swatches-option[data-value*="بنفسج"],
body .cfvsw-swatches-option[data-slug*="purple"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="بنفسجي"].color-swatch-active {
    --swatch-color: #800080 !important;
    background-color: #800080 !important;
    background: #800080 !important;
    background-image: none !important;
}

/* Orange - برتقالي */
body .cfvsw-swatches-option[data-slug*="orange"],
body .cfvsw-swatches-option[data-slug*="برتقالي"],
body .cfvsw-swatches-option[data-value*="orange"],
body .cfvsw-swatches-option[data-value*="برتقالي"],
body .cfvsw-swatches-option[data-slug*="orange"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="برتقالي"].color-swatch-active {
    --swatch-color: #ffa500 !important;
    background-color: #ffa500 !important;
    background: #ffa500 !important;
    background-image: none !important;
}

/* Pink - وردي */
body .cfvsw-swatches-option[data-slug*="pink"],
body .cfvsw-swatches-option[data-slug*="وردي"],
body .cfvsw-swatches-option[data-value*="pink"],
body .cfvsw-swatches-option[data-value*="وردي"],
body .cfvsw-swatches-option[data-slug*="pink"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="وردي"].color-swatch-active {
    --swatch-color: #ffc0cb !important;
    background-color: #ffc0cb !important;
    background: #ffc0cb !important;
    background-image: none !important;
}

/* Brown - بني */
body .cfvsw-swatches-option[data-slug*="brown"],
body .cfvsw-swatches-option[data-slug*="بني"],
body .cfvsw-swatches-option[data-value*="brown"],
body .cfvsw-swatches-option[data-value*="بني"],
body .cfvsw-swatches-option[data-slug*="brown"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="بني"].color-swatch-active {
    --swatch-color: #a52a2a !important;
    background-color: #a52a2a !important;
    background: #a52a2a !important;
    background-image: none !important;
}

/* Black - أسود */
body .cfvsw-swatches-option[data-slug*="black"],
body .cfvsw-swatches-option[data-slug*="أسود"],
body .cfvsw-swatches-option[data-value*="black"],
body .cfvsw-swatches-option[data-value*="أسود"],
body .cfvsw-swatches-option[data-slug*="black"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أسود"].color-swatch-active {
    --swatch-color: #000000 !important;
    background-color: #000000 !important;
    background: #000000 !important;
    background-image: none !important;
}

/* White - أبيض */
body .cfvsw-swatches-option[data-slug*="white"],
body .cfvsw-swatches-option[data-slug*="أبيض"],
body .cfvsw-swatches-option[data-value*="white"],
body .cfvsw-swatches-option[data-value*="أبيض"],
body .cfvsw-swatches-option[data-slug*="white"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="أبيض"].color-swatch-active {
    --swatch-color: #ffffff !important;
    background-color: #ffffff !important;
    background: #ffffff !important;
    background-image: none !important;
    border-color: #ddd !important;
}

/* Gray - رمادي */
body .cfvsw-swatches-option[data-slug*="gray"],
body .cfvsw-swatches-option[data-slug*="grey"],
body .cfvsw-swatches-option[data-slug*="رمادي"],
body .cfvsw-swatches-option[data-value*="gray"],
body .cfvsw-swatches-option[data-value*="grey"],
body .cfvsw-swatches-option[data-value*="رمادي"],
body .cfvsw-swatches-option[data-slug*="gray"].color-swatch-active,
body .cfvsw-swatches-option[data-slug*="رمادي"].color-swatch-active {
    --swatch-color: #808080 !important;
    background-color: #808080 !important;
    background: #808080 !important;
    background-image: none !important;
}

/* ========================================
   CONTAINER STYLING
   ======================================== */

/* Container styling for color swatches */
body .cfvsw-swatches-container.has-color-swatches {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin: 20px 0 !important;
}

/* ========================================
   HOVER EFFECTS
   ======================================== */

/* Hover effects for color swatches */
body .cfvsw-swatches-option.color-swatch-active:hover,
body .cfvsw-swatches-option[data-type="color"]:hover,
body .cfvsw-swatches-option[data-type="colour"]:hover {
    transform: translateY(-4px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15) !important;
    border-color: rgba(0, 122, 255, 0.5) !important;
}

/* ========================================
   SELECTED STATE
   ======================================== */

/* Selected state for color swatches */
body .cfvsw-swatches-option.color-swatch-active.cfvsw-selected-swatch,
body .cfvsw-swatches-option[data-type="color"].cfvsw-selected-swatch,
body .cfvsw-swatches-option[data-type="colour"].cfvsw-selected-swatch {
    border-color: #007AFF !important;
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4) !important;
    transform: translateY(-2px) scale(1.02) !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    body .cfvsw-swatches-option.color-swatch-active,
    body .cfvsw-swatches-option[data-type="color"],
    body .cfvsw-swatches-option[data-type="colour"] {
        min-width: 60px !important;
        min-height: 60px !important;
        border-radius: 12px !important;
        font-size: 11px !important;
        padding: 8px !important;
    }
    
    body .cfvsw-swatches-option.color-swatch-active:hover,
    body .cfvsw-swatches-option[data-type="color"]:hover,
    body .cfvsw-swatches-option[data-type="colour"]:hover {
        transform: translateY(-2px) scale(1.03) !important;
    }
}

@media (max-width: 480px) {
    body .cfvsw-swatches-option.color-swatch-active,
    body .cfvsw-swatches-option[data-type="color"],
    body .cfvsw-swatches-option[data-type="colour"] {
        min-width: 50px !important;
        min-height: 50px !important;
        border-radius: 10px !important;
        font-size: 10px !important;
        padding: 6px !important;
    }
}

/* ========================================
   ADDITIONAL FORCING RULES
   ======================================== */

/* Force color display for any color-related attributes with maximum specificity */
body .cfvsw-swatches-option[data-type="color"],
body .cfvsw-swatches-option[data-type="colour"],
body .cfvsw-swatches-option[data-attribute_type="color"],
body .cfvsw-swatches-option[data-attribute_type="colour"],
body .cfvsw-swatches-option[data-attribute_type="Color"],
body .cfvsw-swatches-option[data-attribute_type="Colour"] {
    background: var(--swatch-color, #f5f5f7) !important;
    background-color: var(--swatch-color, #f5f5f7) !important;
    background-image: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force WooCommerce variations to show colors */
body .variations .value .cfvsw-swatches-option[data-type="color"],
body .variations .value .cfvsw-swatches-option[data-type="colour"],
body .variations .value .cfvsw-swatches-option[data-attribute_type="color"],
body .variations .value .cfvsw-swatches-option[data-attribute_type="colour"] {
    background: var(--swatch-color, #f5f5f7) !important;
    background-color: var(--swatch-color, #f5f5f7) !important;
    background-image: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ========================================
   OVERRIDE ANY CONFLICTING STYLES
   ======================================== */

/* Override any styles that might interfere with color swatches */
body .cfvsw-swatches-option.color-swatch-active,
body .cfvsw-swatches-option[data-type="color"],
body .cfvsw-swatches-option[data-type="colour"] {
    /* Force these properties to override any conflicting styles */
    background-attachment: scroll !important;
    background-clip: border-box !important;
    background-origin: padding-box !important;
    background-position-x: 0 !important;
    background-position-y: 0 !important;
    background-size: auto !important;
    
    /* Ensure proper display */
    box-sizing: border-box !important;
    float: none !important;
    clear: none !important;
    position: relative !important;
    z-index: 1 !important;
}
