/**
 * Rozen Flora Pro — Attribute swatches (color circles + button pills).
 * عيّنات الخصائص: دوائر ملونة للّون + أزرار أنيقة للحجم/الخيارات.
 *
 * Replaces WooCommerce's default <select> dropdowns with premium swatches
 * inspired by WoodMart / Astra. Works for both single product and quick view.
 *
 * @package Rozen_Flora_Pro
 */

/* =========================================================
 * Variation / attribute forms — نماذج الخصائص
 * ========================================================= */

/* Reset default table look — إزالة مظهر الجدول الافتراضي */
.woocommerce div.product form.cart .variations,
.woocommerce div.product form.cart .variations tbody,
.woocommerce div.product form.cart .variations tr,
.woocommerce div.product form.cart .variations td,
.woocommerce div.product form.cart .variations th {
    display: block;
    padding: 0 !important;
    margin: 0;
    border: 0;
    background: transparent;
    text-align: start;
}

.woocommerce div.product form.cart .variations {
    margin-bottom: 28px;
}

.woocommerce div.product form.cart .variations tr {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 22px;
}

.woocommerce div.product form.cart .variations .label {
    padding-bottom: 10px !important;
}

.woocommerce div.product form.cart .variations label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--rf-font-body);
    font-weight: 700;
    font-size: 14px;
    color: var(--rf-burgundy);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin: 0;
    padding-inline-end: 0;
}

/* The "selected value" badge next to the label — شارة القيمة المختارة */
.variations .rf-selected-value {
    font-weight: 600;
    color: var(--rf-gold-dark);
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    margin-inline-start: 4px;
}

/* Hide the ugly native reset link — إخفاء رابط إعادة التعيين القبيح */
.woocommerce div.product form.cart .reset_variations {
    display: none !important;
}

/* =========================================================
 * Swatch row container — حاوية الصف
 * ========================================================= */

.rf-swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* =========================================================
 * COLOR swatches — دوائر الألوان
 * ========================================================= */

.rf-color-swatch {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1.5px var(--rf-line), 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background-clip: padding-box;
    padding: 0;
    outline: none;
}

.rf-color-swatch:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 1.5px var(--rf-gold), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.rf-color-swatch.is-selected {
    box-shadow: 0 0 0 2.5px var(--rf-burgundy), 0 4px 12px rgba(114, 47, 55, 0.25);
    transform: scale(1.06);
}

/* Selected checkmark — علامة الاختيار */
.rf-color-swatch.is-selected::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* For light colors use dark check — علامة داكنة على الألوان الفاتحة */
.rf-color-swatch.is-light.is-selected::after {
    color: var(--rf-burgundy);
    text-shadow: none;
}
.rf-color-swatch.is-dark.is-selected::after {
    color: #fff;
}

/* Tooltip on hover — تلميح عند المرور */
.rf-color-swatch::before {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--rf-burgundy-dark);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10;
}
.rf-color-swatch:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* =========================================================
 * BUTTON / PILL swatches — أزرار الحجم والخيارات
 * ========================================================= */

.rf-button-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 44px;
    padding: 8px 18px;
    border: 1.5px solid var(--rf-line);
    border-radius: 999px;
    background: #fff;
    color: var(--rf-ink);
    font-family: var(--rf-font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    line-height: 1.2;
    text-align: center;
}

.rf-button-swatch:hover {
    border-color: var(--rf-burgundy);
    color: var(--rf-burgundy);
    background: var(--rf-cream);
    transform: translateY(-1px);
}

.rf-button-swatch.is-selected {
    background: linear-gradient(180deg, #7d353f 0%, #6e2c35 100%);
    border-color: var(--rf-burgundy);
    color: #fff;
    box-shadow: 0 4px 12px rgba(114, 47, 55, 0.25);
}

/* Price modifier hint inside button — تلميح السعر داخل الزر */
.rf-button-swatch .rf-swatch-price {
    display: inline-block;
    margin-inline-start: 4px;
    font-size: 12px;
    opacity: 0.85;
    font-weight: 700;
}
.rf-button-swatch.is-selected .rf-swatch-price { color: var(--rf-gold-light); }

/* =========================================================
 * Out-of-stock / disabled state — حالة غير متوفر
 * ========================================================= */

.rf-color-swatch.is-disabled,
.rf-button-swatch.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
    pointer-events: none;
}
.rf-color-swatch.is-disabled::after,
.rf-button-swatch.is-disabled::after {
    content: '';
    position: absolute;
    inset: 50% 0 50% 0;
    height: 1.5px;
    background: var(--rf-burgundy-dark);
    transform: translateY(-50%) rotate(-30deg);
}

/* =========================================================
 * Single product quantity + add to cart row
 * ========================================================= */

.woocommerce div.product form.cart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--rf-line-soft);
}

.woocommerce div.product form.cart .quantity {
    margin: 0 !important;
    flex: 0 0 auto;
}

/* Quantity input styled — تنسيق حقل الكمية */
.woocommerce .quantity .qty {
    width: 70px !important;
    height: 50px !important;
    border: 1.5px solid var(--rf-line) !important;
    border-radius: 999px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--rf-burgundy) !important;
    background: var(--rf-cream) !important;
    text-align: center;
}

/* Add-to-cart button — زر أضف للسلة */
.woocommerce div.product form.cart .single_add_to_cart_button,
.woocommerce div.product form.cart .button {
    flex: 1 1 auto;
    min-width: 200px;
    height: 50px !important;
    border-radius: 999px !important;
    background: linear-gradient(180deg, #7d353f 0%, #6e2c35 100%) !important;
    color: #fff !important;
    font-family: var(--rf-font-body) !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    letter-spacing: 0.5px;
    border: 0 !important;
    box-shadow: 0 4px 14px rgba(114, 47, 55, 0.3);
    transition: all 0.25s ease !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.woocommerce div.product form.cart .single_add_to_cart_button:hover,
.woocommerce div.product form.cart .button:hover {
    background: linear-gradient(180deg, var(--rf-gold) 0%, var(--rf-gold-dark) 100%) !important;
    color: var(--rf-burgundy-dark) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

/* =========================================================
 * Responsive
 * ========================================================= */

@media (max-width: 560px) {
    .rf-color-swatch { width: 34px; height: 34px; }
    .rf-button-swatch { padding: 7px 14px; font-size: 13px; }
    .woocommerce div.product form.cart .single_add_to_cart_button,
    .woocommerce div.product form.cart .button {
        flex: 1 1 100%;
    }
}
