/* ==========================================================================
   GK MODERN CART - FINAL FIXES (Unified Stepper)
   ========================================================================== */
:root {
    /* Legacy variables mapped to Canonical Tokens or removed from usage */
}

body.gk-cart-modern .woocommerce * {
    box-sizing: border-box;
}

/* --- 1. لی‌اوت اصلی --- */
body.gk-cart-modern .woocommerce {
    display: flex !important;
    flex-flow: row wrap !important;
    gap: var(--gk-container-gap) !important;
    max-width: var(--gk-site-width);
    margin: 0 auto;
    padding: 30px 15px;
    background: var(--gk-background);
    direction: rtl;
    align-items: flex-start;
}

/* --- استپ‌پر (نوار مراحل) - کاملاً اصلاح شده --- */
body.gk-cart-modern .gk-checkout-steps {
    flex: 0 0 100% !important; order: 1 !important;
    width: 100% !important;
    margin-bottom: 25px;
    background: var(--gk-surface);
    padding: 20px;
    border-radius: var(--gk-radius-lg);
    border: var(--gk-border-width) solid var(--gk-border-color);
    display: block; /* اطمینان از بلاک بودن */
}

body.gk-cart-modern .gk-checkout-steps__list {
    display: flex !important;
    justify-content: space-between; /* پخش در عرض */
    align-items: center;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 50px !important;
    position: relative;
}

/* خط اتصال سراسری */
body.gk-cart-modern .gk-checkout-steps__list::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 60px;
    right: 60px;
    height: 2px;
    background: var(--gk-neutral-100);
    z-index: 0;
    transform: translateY(-50%);
}

body.gk-cart-modern .gk-checkout-steps__item {
    display: flex;
    flex-direction: column; /* عمودی: آیکون بالا، متن پایین */
    align-items: center;
    position: relative;
    z-index: 1;
    background: var(--gk-surface);
    padding: 0 10px;
}

/* آیکون دایره‌ای */
body.gk-cart-modern .gk-checkout-steps__icon {
    width: 32px;
    height: 32px;
    border-radius: var(--gk-radius-round);
    background: var(--gk-surface);
    border: 2px solid var(--gk-neutral-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-neutral-400);
    margin-bottom: 8px;
    font-size: 14px;
}

body.gk-cart-modern .gk-checkout-steps__label {
    font-size: 13px;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-neutral-500);
}

/* حالت فعال/تکمیل */
body.gk-cart-modern .gk-checkout-steps__item.is-current .gk-checkout-steps__icon {
    border-color: var(--gk-primary);
    color: var(--gk-primary);
    background: var(--gk-primary-50);
}
body.gk-cart-modern .gk-checkout-steps__item.is-current .gk-checkout-steps__label {
    color: var(--gk-primary);
}

body.gk-cart-modern .gk-checkout-steps__item.is-completed .gk-checkout-steps__icon {
    background: var(--gk-primary);
    border-color: var(--gk-primary);
    color: var(--gk-surface);
}
body.gk-cart-modern .gk-checkout-steps__item.is-completed .gk-checkout-steps__label {
    color: var(--gk-neutral-800);
}
/* حذف کانکتورهای قدیمی */
body.gk-cart-modern .gk-checkout-steps__connector { display: none !important; }


/* --- تب‌ها --- */
body.gk-cart-modern .gk-next-tabs {
    flex: 0 0 100% !important; order: 2 !important;
    display: flex; gap: 30px; border-bottom: var(--gk-border-width) solid var(--gk-border-color); margin-bottom: 15px;
}
body.gk-cart-modern .gk-next-tabs__tab {
    background: none; border: none; padding: 10px 0 15px; font-size: 16px; font-weight: var(--gk-heading-weight); color: var(--gk-neutral-600); cursor: pointer; position: relative;
}
body.gk-cart-modern .gk-next-tabs__tab.is-active { color: var(--gk-primary); }
body.gk-cart-modern .gk-next-tabs__tab.is-active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 3px; background: var(--gk-primary);
}

/* پیام‌ها */
body.gk-cart-modern .woocommerce-notices-wrapper { flex: 0 0 100% !important; order: 3 !important; }

/* لیست محصولات */
body.gk-cart-modern .woocommerce-cart-form {
    flex: 1 1 calc(100% - 350px) !important; order: 4 !important; min-width: 0 !important; margin: 0 !important;
}
/* پنل خرید بعدی */
body.gk-cart-modern #gk-next-purchase-panel {
    flex: 1 1 calc(100% - 350px) !important; order: 4 !important; min-width: 0 !important; margin: 0 !important;
    background: var(--gk-surface); border: var(--gk-border-width) solid var(--gk-border-color); border-radius: var(--gk-radius-lg); padding: 20px;
}

/* --- 2. سایدبار --- */
body.gk-cart-modern .cart-collaterals {
    flex: 0 0 320px !important; width: 320px !important; order: 5 !important;
    position: sticky; top: 20px; background: var(--gk-surface); border: var(--gk-border-width) solid var(--gk-border-color); border-radius: var(--gk-radius-lg); padding: 20px !important;
}
body.gk-cart-modern .cart-collaterals .cart_totals {
    float: none !important; width: 100% !important; display: block !important; clear: both !important;
}

/* --- 3. استایل کارت محصول --- */
body.gk-cart-modern table.shop_table {
    display: block !important; border: none; width: 100% !important; border-collapse: collapse;
}
body.gk-cart-modern table.shop_table thead { display: none !important; }
body.gk-cart-modern table.shop_table tbody { display: block !important; }

body.gk-cart-modern tr.cart_item,
body.gk-cart-modern .gk-next-panel__row {
    display: grid !important;
    /* ستون‌ها: تصویر(140px) | محتوا | قیمت/تعداد(200px) */
    grid-template-columns: 140px 1fr 200px !important;
    gap: 20px;
    background: var(--gk-surface);
    border: var(--gk-border-width) solid var(--gk-border-color);
    border-radius: var(--gk-radius-lg);
    padding: 24px;
    margin-bottom: 15px;
    position: relative;
    align-items: flex-start;
}

/* تصویر */
body.gk-cart-modern td.product-thumbnail,
body.gk-cart-modern .gk-next-panel__row .product-thumbnail {
    display: block !important; border: none !important; padding: 0 !important;
}
body.gk-cart-modern td.product-thumbnail img,
body.gk-cart-modern .gk-next-panel__row .product-thumbnail img {
    width: 130px !important; height: 130px !important; object-fit: contain; mix-blend-mode: multiply;
}

/* نام */
body.gk-cart-modern td.product-name,
body.gk-cart-modern .gk-next-panel__row .product-name {
    display: block !important; border: none !important; padding: 0 !important; text-align: right;
}
body.gk-cart-modern td.product-name a,
body.gk-cart-modern .gk-next-panel__row .product-name a {
    font-size: 16px; font-weight: var(--gk-heading-weight); color: var(--gk-text); text-decoration: none; line-height: 1.6; display: block; margin-bottom: 12px;
}

/* --- اصلاح ویژگی‌ها (META FIX) --- */
body.gk-cart-modern dl.variation {
    display: grid !important;
    grid-template-columns: max-content auto !important; /* ستون اول: لیبل، ستون دوم: مقدار */
    gap: 6px 8px !important;
    margin: 0 !important;
    font-size: 13px;
    color: var(--gk-neutral-600);
    align-items: center;
}

/* برچسب (Label) */
body.gk-cart-modern dl.variation dt {
    display: block !important;
    float: none !important;
    margin: 0 !important;
    font-weight: 400 !important;
    color: var(--gk-neutral-600);
}
/* حذف دو نقطه اضافی CSS */
body.gk-cart-modern dl.variation dt::after {
    content: none !important;
}

/* مقدار (Value) */
body.gk-cart-modern dl.variation dd {
    display: flex !important;
    align-items: center;
    float: none !important;
    margin: 0 !important;
    font-weight: 500;
    color: var(--gk-text);
}

/* حذف حاشیه‌های اضافی */
body.gk-cart-modern dl.variation dd p {
    margin: 0 !important;
    display: inline-block;
}

/* آیکون بولت */
body.gk-cart-modern dl.variation dd::before,
.gk-next-panel__variation-item::before {
    content: ''; display: block; width: 6px; height: 6px; background: var(--gk-neutral-300); border-radius: 50%; margin-left: 6px; flex-shrink: 0;
}


/* ستون چپ */
body.gk-cart-modern td.product-subtotal,
body.gk-cart-modern .gk-next-panel__row .product-price {
    grid-column: 3; grid-row: 1; text-align: left;
    font-size: 19px; font-weight: 800; color: var(--gk-text);
    padding: 0 !important; border: none !important; display: block !important;
}

body.gk-cart-modern td.product-quantity,
body.gk-cart-modern .gk-next-panel__row .product-actions {
    grid-column: 3; grid-row: 2;
    display: flex !important; justify-content: flex-end;
    margin-top: 15px; border: none !important; padding: 0 !important;
}

/* دکمه حذف جداگانه */
body.gk-cart-modern td.product-remove,
body.gk-cart-modern .gk-next-panel__row .gk-action-remove {
    display: block !important;
    position: absolute;
    top: 15px;
    left: 15px;
    width: auto !important;
    border: none !important;
    padding: 0 !important;
}
body.gk-cart-modern a.remove {
    color: var(--gk-neutral-400); font-size: 22px; font-weight: 300; text-decoration: none; transition: 0.2s; display: block; line-height: 1;
}
body.gk-cart-modern a.remove:hover { color: var(--gk-primary); transform: scale(1.1); }

/* --- باکس تعداد --- */
body.gk-cart-modern .quantity {
    display: inline-flex !important; align-items: center;
    border: var(--gk-border-width) solid var(--gk-border-color); border-radius: var(--gk-radius-md);
    height: 40px; background: var(--gk-surface); overflow: hidden;
    box-shadow: var(--gk-shadow-sm);
}
body.gk-cart-modern input[type=number]::-webkit-inner-spin-button,
body.gk-cart-modern input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none; margin: 0;
}
body.gk-cart-modern input[type=number] { -moz-appearance: textfield; }

body.gk-cart-modern .quantity input.qty {
    width: 40px !important; border: none !important; background: transparent !important;
    text-align: center; font-weight: var(--gk-heading-weight); font-size: 17px; height: 100% !important;
    color: var(--gk-primary) !important; padding: 0 !important;
}

.gk-qty-btn {
    width: 36px; height: 100%; border: none; background: var(--gk-surface);
    color: var(--gk-primary); font-size: 22px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.gk-qty-btn:hover { background: var(--gk-neutral-50); }
.gk-qty-btn.plus { border-right: 1px solid var(--gk-neutral-100); }
.gk-qty-btn.minus { border-left: 1px solid var(--gk-neutral-100); }
.gk-qty-btn.minus.is-trash span { font-size: 18px; margin-top: 2px; }

/* مخفی کردن قیمت واحد */
body.gk-cart-modern td.product-price { display: none !important; }

/* --- دکمه‌های پایین سبد خرید --- */
body.gk-cart-modern td.actions {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 15px;
    padding: 20px 0 0 !important; border-top: 1px solid var(--gk-neutral-100) !important; margin-top: 20px;
}
body.gk-cart-modern .coupon { display: flex; gap: 10px; }
body.gk-cart-modern .coupon input#coupon_code {
    border: var(--gk-border-width) solid var(--gk-border-color); border-radius: var(--gk-radius-md); padding: 0 15px; height: 42px; width: 200px;
}
body.gk-cart-modern .coupon button,
body.gk-cart-modern button[name="update_cart"],
body.gk-cart-modern .gk-next-bulk-cart {
    background: var(--gk-surface) !important; border: var(--gk-border-width) solid var(--gk-border-color) !important; color: var(--gk-neutral-600) !important;
    padding: 0 20px !important; height: 42px !important; border-radius: var(--gk-radius-md) !important;
    font-weight: var(--gk-heading-weight) !important; font-size: 14px !important; cursor: pointer;
    transition: all 0.2s;
}
body.gk-cart-modern button:hover { border-color: var(--gk-neutral-500) !important; color: var(--gk-neutral-800) !important; }


/* --- استایل دکمه‌های خرید بعدی --- */
.gk-next-panel__action {
    background: var(--gk-surface) !important; border: 1px solid var(--gk-primary) !important; color: var(--gk-primary) !important;
    padding: 8px 16px !important; border-radius: 6px !important; font-size: 13px !important; cursor: pointer;
    margin-right: 5px; text-decoration: none; display: inline-block;
}
.gk-next-panel__action:hover { background: var(--gk-primary) !important; color: var(--gk-surface) !important; }

.gk-next-panel__bulk-actions { margin-bottom: 20px; display: flex; gap: 10px; }
.gk-next-panel__bulk-btn {
    background: var(--gk-neutral-100) !important; border: none !important; color: var(--gk-neutral-700) !important;
    padding: 10px 20px !important; border-radius: var(--gk-radius-md) !important; font-weight: var(--gk-heading-weight) !important; cursor: pointer;
}
.gk-next-panel__bulk-btn:hover { background: var(--gk-border-color) !important; }

.gk-next-panel__variation {
    display: flex; flex-direction: column; gap: 5px; margin-top: 8px; font-size: 13px; color: var(--gk-neutral-600);
}
.gk-next-panel__variation-item {
    display: flex; align-items: center; gap: 5px;
}
.gk-next-panel__variation-item::before {
    content: ''; width: 5px; height: 5px; background: var(--gk-neutral-300); border-radius: 50%;
}

/* موبایل */
@media (max-width: 900px) {
    body.gk-cart-modern .woocommerce { flex-direction: column !important; gap: 10px !important; padding: 10px; }
    body.gk-cart-modern .gk-checkout-steps { order: 1; overflow-x: auto; }
    body.gk-cart-modern .gk-next-tabs { order: 2; }
    body.gk-cart-modern .woocommerce-notices-wrapper { order: 3; }
    body.gk-cart-modern .woocommerce-cart-form, body.gk-cart-modern #gk-next-purchase-panel { order: 4; width: 100% !important; }
    body.gk-cart-modern .cart-collaterals { order: 5; width: 100% !important; position: static !important; }

    body.gk-cart-modern tr.cart_item, body.gk-cart-modern .gk-next-panel__row {
        grid-template-columns: 100px 1fr !important; gap: 15px; padding: 15px;
    }
    body.gk-cart-modern td.product-thumbnail,
    body.gk-cart-modern .gk-next-panel__row .product-thumbnail {
        grid-column: 1; grid-row: 1 / 3;
    }
    body.gk-cart-modern td.product-thumbnail img,
    body.gk-cart-modern .gk-next-panel__row .product-thumbnail img {
        width: 90px !important; height: 90px !important;
    }
    body.gk-cart-modern td.product-name { grid-column: 2; grid-row: 1; }

    body.gk-cart-modern td.product-subtotal,
    body.gk-cart-modern .gk-next-panel__row .product-price {
        grid-column: 2; grid-row: 2; text-align: right; align-self: center; font-size: 16px;
    }
    body.gk-cart-modern td.product-quantity,
    body.gk-cart-modern .gk-next-panel__row .product-actions {
        grid-column: 2; grid-row: 2; justify-content: flex-end; margin-top: 0;
    }

    body.gk-cart-modern td.actions { flex-direction: column; align-items: stretch; }
    body.gk-cart-modern .coupon { width: 100%; }
    body.gk-cart-modern .coupon input#coupon_code { width: 100%; flex: 1; }

    body.gk-cart-modern .gk-checkout-steps__list { padding: 0 !important; gap: 15px; }
    body.gk-cart-modern .gk-checkout-steps__list::before { left: 20px; right: 20px; }
    body.gk-cart-modern .gk-checkout-steps__icon { width: 40px; height: 40px; font-size: 14px; }
    body.gk-cart-modern .gk-checkout-steps__label { font-size: 11px; }
}
