/**
 * استایل‌های فرانت‌اند افزونه WC Attribute Swatches
 *
 * @package WC_Attribute_Swatches
 * @since 1.0.0
 */

/* ==========================================
   کلاس‌های Utility (مشابه Tailwind)
   ========================================== */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-3 {
    gap: 0.75rem;
}

.my-4 {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.ms-2 {
    margin-inline-start: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.font-bold {
    font-weight: 700;
}

.text-lg {
    font-size: 1.125rem;
}

.text-gray-700 {
    color: #374151;
}

.text-gray-900 {
    color: #111827;
}

.border-2 {
    border-width: 2px;
}

.border-gray-200 {
    border-color: #e5e7eb;
}

.border-primary-500 {
    border-color: #3b82f6;
}

.rounded-full {
    border-radius: 9999px;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.cursor-pointer {
    cursor: pointer;
}

.select-none {
    user-select: none;
    -webkit-user-select: none;
}

.transition-colors {
    transition-property: color, background-color, border-color;
}

.duration-200 {
    transition-duration: 200ms;
}

.ease-in-out {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}


.dir-ltr {
    direction: ltr;
}

/* peer-checked استایل‌ها */
input.peer:checked + label.peer-checked\:text-gray-900,
input.peer:checked + label {
    color: #111827;
}

input.peer:checked + label.peer-checked\:border-primary-500,
input.peer:checked + label {
    border-color: #3b82f6;
}

/* ==========================================
   متغیرهای CSS
   ========================================== */
:root {
    --wcas-swatch-size: 32px;
    --wcas-swatch-radius: 50%;
    --wcas-swatch-border: #ddd;
    --wcas-swatch-border-hover: #999;
    --wcas-swatch-border-selected: #333;
    --wcas-swatch-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --wcas-swatch-shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
    --wcas-transition: all 0.2s ease-in-out;
    --wcas-tooltip-bg: #333;
    --wcas-tooltip-color: #fff;
    --wcas-disabled-overlay: rgba(255, 255, 255, 0.7);
}

/* ==========================================
   Wrapper Swatches
   ========================================== */
.wcas-swatches-wrapper {
    margin-bottom: 15px;
}

.wcas-swatches-wrapper h4 {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: #111827;
}

.wcas-swatches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* مخفی کردن select اصلی */
.wcas-hidden-select {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* ==========================================
   Swatch پایه
   ========================================== */
.wcas-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--wcas-swatch-size);
    height: var(--wcas-swatch-size);
    border-radius: var(--wcas-swatch-radius);
    border: 2px solid var(--wcas-swatch-border);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    box-sizing: border-box;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

.wcas-swatch:hover {
    border-color: #9ca3af;
}

.wcas-swatch:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* وضعیت انتخاب شده */
.wcas-swatch--selected {
    border-color: #3b82f6;
}

.wcas-swatch--selected::after {
    display: none;
}

.wcas-swatch--selected::before {
    display: none;
}

/* ==========================================
   شکل‌های مختلف
   ========================================== */
.wcas-swatch--circle {
    border-radius: 50%;
}

.wcas-swatch--square {
    border-radius: 0;
}

.wcas-swatch--rounded {
    border-radius: 4px;
}

/* ==========================================
   Color Swatch با Radio Input
   ========================================== */
.wcas-swatch--color {
	width: auto;
	min-width: min-content;
	height: auto;
	padding: 4px 8px;
	position: relative;
	font-size: 14px;
	font-weight: 400;
	color: #374151;
	background: #fff !important;
	border-radius: 9999px;
	border: 2px solid #e5e7eb;
	display: flex !important;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.wcas-swatch--color .wcas-color-circle {
    width: 16px;
    height: 16px;
    border-radius: 9999px;
    flex-shrink: 0;
    display: inline-block;
}

.wcas-swatch--color .wcas-swatch-text {
    color: #374151;
    margin-right: 0.5rem;
}

/* وضعیت peer-checked */
input.peer:checked + .wcas-swatch--color {
    color: #111827;
    border-color: #3b82f6;
}

input.peer:checked + .wcas-swatch--color .wcas-swatch-text {
    color: #111827;
}

/* ==========================================
   Image Swatch با Radio Input
   ========================================== */
.wcas-swatch--image {
    width: auto;
    min-width: 60px;
    height: auto;
    padding: 4px 8px;
    font-size: 14px;
    font-weight: 400;
    color: #374151;
    background: #fff;
    border-radius: 9999px;
    border-width: 2px;
    border-style: solid;
    border-color: #e5e7eb;
    transition: all 0.2s ease-in-out;
}

.wcas-swatch--image .wcas-image-circle {
    width: 16px;
    height: 16px;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-block;
}

.wcas-swatch--image .wcas-swatch-text {
    color: #374151;
    margin-right: 0.5rem;
}

/* وضعیت peer-checked */
input.peer:checked + .wcas-swatch--image {
    color: #111827;
    border-color: #3b82f6;
}

input.peer:checked + .wcas-swatch--image .wcas-swatch-text {
    color: #111827;
}

.wcas-swatch--no-image {
    background: #f5f5f5;
}

/* ==========================================
   Button Swatch
   ========================================== */
.wcas-swatch--button {
    width: auto;
    min-width: 60px;
    height: auto;
    padding: 4px 8px;
    font-size: 14px;
    font-weight: 400;
    color: #374151;
    background: #fff;
    border-radius: 9999px;
    border-width: 2px;
    border-style: solid;
    border-color: #e5e7eb;
    transition: all 0.2s ease-in-out;
}

input.peer:checked + .wcas-swatch--button {
    color: #111827;
    border-color: #3b82f6;
}

/* ==========================================
   Radio Swatch
   ========================================== */
.wcas-swatch--radio {
    width: auto;
    min-width: 60px;
    height: auto;
    padding: 4px 8px;
    font-size: 14px;
    font-weight: 400;
    color: #374151;
    background: #fff;
    border-radius: 9999px;
    border-width: 2px;
    border-style: solid;
    border-color: #e5e7eb;
    transition: all 0.2s ease-in-out;
}

.wcas-radio-indicator {
    width: 16px;
    height: 16px;
    border-radius: 9999px;
    border: 2px solid #d1d5db;
    display: inline-block;
    position: relative;
    margin-left: 0.5rem;
}

input.peer:checked + .wcas-swatch--radio {
    color: #111827;
    border-color: #3b82f6;
}

input.peer:checked + .wcas-swatch--radio .wcas-radio-indicator {
    border-color: #3b82f6;
    background-color: #3b82f6;
}

input.peer:checked + .wcas-swatch--radio .wcas-radio-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background-color: #fff;
}
    height: auto;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 4px;
}

.wcas-swatch--radio .wcas-radio-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.wcas-swatch--radio .wcas-radio-indicator {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 50%;
    position: relative;
    transition: var(--wcas-transition);
}

.wcas-swatch--radio .wcas-radio-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    transition: var(--wcas-transition);
}

.wcas-swatch--radio.wcas-swatch--selected .wcas-radio-indicator {
    border-color: #333;
}

.wcas-swatch--radio.wcas-swatch--selected .wcas-radio-indicator::after {
    transform: translate(-50%, -50%) scale(1);
}

.wcas-swatch--radio.wcas-swatch--selected::before,
.wcas-swatch--radio.wcas-swatch--selected::after {
    display: none;
}

.wcas-swatch--radio .wcas-radio-label {
    font-size: 14px;
    color: #333;
}

/* ==========================================
   وضعیت غیرفعال
   ========================================== */
.wcas-swatch--disabled {
    cursor: not-allowed;
    position: relative;
}

/* استایل ضربدر */
.wcas-swatch--disabled::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 2px;
    background: #cc0000;
    transform: translate(-50%, -50%) rotate(-45deg);
    z-index: 2;
}

.wcas-swatch--disabled:hover {
    transform: none;
    box-shadow: none;
}

/* استایل blur */
.wcas-swatches-wrapper[data-disabled-style="blur"] .wcas-swatch--disabled::before {
    display: none;
}

.wcas-swatches-wrapper[data-disabled-style="blur"] .wcas-swatch--disabled {
    opacity: 0.4;
    filter: grayscale(100%);
}

/* استایل hide */
.wcas-swatches-wrapper[data-disabled-style="hide"] .wcas-swatch--disabled {
    display: none !important;
}

/* ==========================================
   Tooltip
   ========================================== */
.wcas-swatch[data-tooltip] {
    position: relative;
}

.wcas-swatch[data-tooltip]::before {
    content: none;
}

.wcas-swatch[data-tooltip]::after {
    content: none;
}

.wcas-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--wcas-tooltip-bg);
    color: var(--wcas-tooltip-color);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: var(--wcas-transition);
}

.wcas-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--wcas-tooltip-bg);
}

.wcas-swatch:hover .wcas-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ==========================================
   لینک پاک کردن
   ========================================== */
.wcas-clear-selection {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: #999;
    text-decoration: none;
    transition: var(--wcas-transition);
}

.wcas-clear-selection:hover {
    color: #333;
}

/* ==========================================
   انیمیشن‌ها
   ========================================== */
@keyframes wcas-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(66, 153, 225, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(66, 153, 225, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(66, 153, 225, 0);
    }
}

.wcas-swatch.wcas-swatch--loading {
    animation: wcas-pulse 1.5s infinite;
}

/* ==========================================
   ریسپانسیو
   ========================================== */
@media (max-width: 768px) {
    :root {
        --wcas-swatch-size: 40px;
    }
    
    .wcas-swatches-list {
        gap: 10px;
    }
    
    .wcas-swatch--button {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .wcas-swatch--radio {
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    :root {
        --wcas-swatch-size: 36px;
    }
    
    .wcas-swatches-list {
        gap: 8px;
    }
    
    .wcas-swatch--button {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ==========================================
   سازگاری با RTL
   ========================================== */
[dir="rtl"] .wcas-swatch--selected::after,
[dir="rtl"] .wcas-swatch--selected::before {
    right: auto;
    left: -4px;
}

[dir="rtl"] .wcas-swatch--radio {
    flex-direction: row-reverse;
}

/* ==========================================
   دسترسی‌پذیری
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .wcas-swatch {
        transition: none;
    }
    
    .wcas-tooltip {
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .wcas-swatch {
        border-width: 3px;
    }
    
    .wcas-swatch--selected {
        border-color: #000;
    }
    
    .wcas-swatch--disabled::before {
        height: 3px;
    }
}
.variations .label {
	display: none;
}