/* --- 1. تنظیم چیدمان کلی --- */
.woocommerce div.product form.cart:not(.variations_form),
.woocommerce div.product .woocommerce-variation-add-to-cart {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 15px !important;
    width: 100% !important;
}

.single_variation_wrap {
    width: 100% !important;
}

/* --- 2. استایل کانتینر تعداد --- */
.gk-qty-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 2px solid #e1e1e1;
    border-radius: 12px;
    background: #fff;
    height: 55px;
    width: 100%;
    padding: 0;
    overflow: hidden;
    position: relative; /* برای پوزیشن ابسولوت متن واحد */
    box-sizing: border-box;
}
.single_add_to_cart_button.button.alt {
    font-family: inherit !important;
    font-weight: 500 !important;
}
/* دکمه‌های + و - */
.gk-qty-btn {
    background: #f8f9fa;
    border: none;
    width: 55px;
    height: 100%;
    cursor: pointer;
    font-size: 20px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10; /* روی متن نیفتد */
}

.gk-qty-btn:hover {
    background: #e9ecef;
    color: #000;
}

/* اینپوت وسط */
.gk-qty-container input.qty {
    border: none !important;
    background: transparent !important;
    text-align: center;
    flex-grow: 1;
    height: 100%;
    font-family: 'YekanBakhVF', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: #333;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    z-index: 5;
    position: relative;
}

.gk-qty-container input.qty::-webkit-outer-spin-button,
.gk-qty-container input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.woocommerce-variation-price,
.single_variation .price {
    display: none !important;
}
/* --- استایل جدید: متن واحد (متر/عدد) --- */
.gk-unit-label {
    position: absolute;
    /* تنظیم برای سایت‌های فارسی (RTL) */
    left: 65px; /* فاصله از لبه چپ (نزدیک دکمه مثبت در حالت RTL) */

    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #adb5bd; /* خاکستری روشن و کمرنگ */
    font-weight: 400;
    pointer-events: none;
    z-index: 4;
    user-select: none;
}

/* --- 3. استایل باکس قیمت نهایی --- */
.gk-final-price-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0fdf4;
    border: 1px dashed #22c55e;
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
    min-height: 50px;
}

.gk-final-price-box .label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.gk-final-price-box .price-value {
    font-size: 18px;
    font-weight: 800;
    color: #166534;
    /* جهت LTR را حذف کردیم تا ترتیب فارسی (تومان + عدد) درست دیده شود */
}

/* --- 4. استایل دکمه افزودن به سبد خرید --- */
button.single_add_to_cart_button {
    width: 100% !important;
    display: block !important;
    margin: 0 !important;
    float: none !important;
    border-radius: 12px !important;
    padding: 16px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    background: linear-gradient(to left, #007bff, #0056b3) !important;
    color: #fff !important;
    border: none !important;
    height: auto !important;
    line-height: 1.2 !important;
}

button.single_add_to_cart_button:hover {
    background: linear-gradient(to left, #0056b3, #004494) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
}

button.single_add_to_cart_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc !important;
}

@media (max-width: 768px) {
    .woocommerce div.product form.cart:not(.variations_form),
    .woocommerce div.product .woocommerce-variation-add-to-cart {
        gap: 10px !important;
    }
}




/* =========================================
   مدرن‌سازی بخش انتخاب متغیرها (Variations)
   ========================================= */

/* 1. اصلاح ساختار جدول ووکامرس (چیدمان زیر هم) */
table.variations {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    display: block; /* تبدیل جدول به حالت بلوکی */
}

table.variations tbody,
table.variations tr,
table.variations td {
    display: block; /* نمایش زیر هم */
    width: 100%;
}

table.variations tr {
    margin-bottom: 15px; /* فاصله بین ویژگی‌ها */
}

table.variations td {
    padding: 0;
    text-align: right; /* راست‌چین برای فارسی */
}

table.variations td.label {
    margin-bottom: 8px;
    padding-bottom: 0;
}

table.variations label {
    font-size: 14px;
    font-weight: 700;
    color: #444;
    margin: 0;
}

/* 2. استایل‌دهی به باکس کشویی (Select Box) */
.variations select {
    width: 100%;
    height: 50px; /* ارتفاع مناسب */
    padding: 0 15px;
    /* فضای سمت چپ برای فلش (چون سایت RTL است) */
    padding-left: 40px;

    font-family: 'YekanBakhVF', sans-serif;
    font-size: 15px;
    color: #333;
    background-color: #fff;
    border: 2px solid #e1e1e1;
    border-radius: 12px; /* گرد کردن گوشه‌ها */
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;

    /* حذف ظاهر پیش‌فرض مرورگر */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* اضافه کردن آیکون فلش سفارشی (SVG) */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 15px center; /* فلش سمت چپ */
    background-size: 16px;
}

/* افکت هاور و فوکوس */
.variations select:hover {
    border-color: #b0b0b0;
}

.variations select:focus {
    border-color: #007bff; /* رنگ اصلی سایت */
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
}

/* 3. استایل دکمه پاک کردن (Reset Link) */
a.reset_variations {
    display: inline-flex !important; /* برای نمایش کنار هم آیکون و متن */
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #ef4444; /* رنگ قرمز */
    text-decoration: none;
    margin-top: 8px;
    padding: 5px 10px;
    background: #fef2f2; /* پس‌زمینه قرمز خیلی روشن */
    border-radius: 8px;
    transition: all 0.2s;
    visibility: hidden; /* ووکامرس خودش ویزیبیلیتی را کنترل میکند */
}

a.reset_variations:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* اضافه کردن آیکون ضربدر قبل از متن پاک کردن */
a.reset_variations::before {
    content: "\f335"; /* کد آیکون dashicons-no-alt */
    font-family: dashicons;
    font-size: 14px;
    display: inline-block;
}

/* اصلاح فاصله در موبایل */
@media (max-width: 768px) {
    .variations select {
        font-size: 14px;
        height: 45px;
    }
}