/* ==========================================================
   صفحه سبد خرید — قالب فعال سایت (پیش‌فرض ووکامرس، tamyar-v3)

   این فایل روی خروجی واقعیِ woocommerce/cart/cart.php این تم چایلد
   استایل می‌ذاره: کلاس‌های .tamyar-cart-page / .tamyar-cart-list /
   .tamyar-cart-item برای لیست محصولات (که به‌جای ویجت Elementor، از یک
   قالب اورراید ساده‌ی <ul>/<li> ساخته می‌شه)، و .tamyar-cart-sidebar
   که دورِ خروجیِ خودِ ووکامرس (woocommerce_cart_totals →
   cart/cart-totals.php: .cart_totals/.shop_table/.order-total/
   .woocommerce-shipping-methods) رو می‌گیره.

   (فایل جدای assets/css/custom/cart-page.css برای ویجت‌های Elementor
   قالب Woodmart است — کلاس‌های wd-cart-table/wd-cart-totals — که روی
   سایت فعلی استفاده نمی‌شه.)
   ========================================================== */

.tamyar-cart-page,
.tamyar-cart-page * {
    box-sizing: border-box;
}

.tamyar-cart-page {
    direction: rtl;
    unicode-bidi: embed;
    font-family: 'YekanBakhFaNum', Tahoma, Arial, sans-serif;
    color: var(--tl-text);
}

.tamyar-cart-page .woocommerce-Price-amount {
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
}

.tamyar-cart-page .woocommerce-Price-currencySymbol {
    margin-inline: 3px;
    font-size: 12px;
    opacity: .8;
}

/* ---------- چیدمان کلی: لیست محصولات + سایدبار جمع‌کل ---------- */
.tamyar-cart-layout {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 20px;
}

.tamyar-cart-main {
    flex: 2 1 480px;
    min-width: 320px;
    background: var(--tl-surface);
    border-radius: var(--tl-radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    overflow: hidden;
}

/* ---------- لیست محصولات ---------- */
.tamyar-cart-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tamyar-cart-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--tl-border);
    position: relative;
    transition: background-color .15s ease;
}

.tamyar-cart-item:last-child {
    border-bottom: none;
}

.tamyar-cart-item:hover {
    background: var(--tl-surface-muted);
}

/* تصویر */
.tamyar-cart-item__thumb {
    flex-shrink: 0;
}

.tamyar-cart-item__thumb img {
    display: block;
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: var(--tl-radius-md);
    border: 1px solid var(--tl-border);
}

/* نام محصول + قیمت واحد (نسخه موبایل) */
.tamyar-cart-item__body {
    flex: 1 1 auto;
    min-width: 0;
}

.tamyar-cart-item__name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -.1px;
}

.tamyar-cart-item__name a {
    color: var(--tl-text);
    text-decoration: none;
}

.tamyar-cart-item__name a:hover {
    color: var(--tl-primary);
}

.tamyar-cart-item__name .variation,
.tamyar-cart-item__name .wc-item-meta {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    font-size: 12.5px;
    color: var(--tl-text-muted);
}

.tamyar-cart-item__name .variation dt,
.tamyar-cart-item__name .variation dd,
.tamyar-cart-item__name .wc-item-meta li {
    display: inline;
}

.tamyar-cart-item__name .variation dt::after {
    content: ":";
    margin-inline-end: 4px;
}

.tamyar-cart-item__name .variation dd p {
    display: inline;
    margin: 0;
}

.tamyar-cart-item__name .backorder_notification {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--tl-accent);
}

/* قیمت واحد: خنثی تا فقط جمع‌کل نهایی قرمز و برجسته بمونه.
   !important لازمه چون global-brand.css با !important رنگ قرمز برند رو
   روی همه‌ی .woocommerce-Price-amount سایت می‌ذاره. */
.tamyar-cart-item__price .woocommerce-Price-amount {
    color: var(--tl-text-muted) !important;
    font-weight: 500;
    font-size: 14px;
}

.tamyar-cart-item__price--mobile {
    display: none;
    margin-top: 6px;
}

.tamyar-cart-item__price--desktop {
    flex-shrink: 0;
    width: 110px;
    text-align: center;
}

/* ---------- کنترل تعداد ---------- */
.tamyar-cart-item__qty {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--tl-surface-muted);
    border-radius: var(--tl-radius-pill);
    padding: 4px;
    border: 1px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}

.tamyar-cart-item__qty:focus-within {
    border-color: var(--tl-primary);
    box-shadow: 0 0 0 3px rgba(196, 22, 28, .12);
}

.tamyar-qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--tl-surface);
    color: var(--tl-text);
    font-size: 15px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.tamyar-qty-btn:hover {
    background: var(--tl-primary);
    color: #fff;
}

.tamyar-qty-input {
    width: 36px;
    height: 28px;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--tl-text);
    padding: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.tamyar-qty-input::-webkit-outer-spin-button,
.tamyar-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tamyar-cart-item__qty-fixed {
    padding: 0 10px;
    font-weight: 600;
    font-size: 14px;
    color: var(--tl-text);
}

/* جمع جزء هر ردیف */
.tamyar-cart-item__subtotal {
    flex-shrink: 0;
    width: 110px;
    text-align: center;
}

.tamyar-cart-item__subtotal .woocommerce-Price-amount {
    color: var(--tl-primary) !important;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

/* حذف */
.tamyar-cart-item__remove {
    flex-shrink: 0;
}

.tamyar-cart-item__remove a.remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #fdeceb;
    color: var(--tl-danger);
    border-radius: 50%;
    text-decoration: none;
    transition: all .2s ease;
    line-height: 1;
    font-size: 0;
}

/* خودِ قالب Woodmart روی a.remove یک آیکون فونتی با ::before اضافه
   می‌کنه که با آیکون svg خودمون هم‌زمان دیده می‌شد؛ خنثی‌اش می‌کنیم. */
.tamyar-cart-item__remove a.remove::before {
    content: none !important;
}

.tamyar-cart-item__remove a.remove::after {
    content: "";
    display: block;
    width: 17px;
    height: 17px;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E51E1E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'%3E%3C/polyline%3E%3Cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'%3E%3C/path%3E%3Cpath d='M10 11v6'%3E%3C/path%3E%3Cpath d='M14 11v6'%3E%3C/path%3E%3Cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'%3E%3C/path%3E%3C/svg%3E");
}

.tamyar-cart-item__remove a.remove:hover {
    background: var(--tl-danger);
}

.tamyar-cart-item__remove a.remove:hover::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'%3E%3C/polyline%3E%3Cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'%3E%3C/path%3E%3Cpath d='M10 11v6'%3E%3C/path%3E%3Cpath d='M14 11v6'%3E%3C/path%3E%3Cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'%3E%3C/path%3E%3C/svg%3E");
}

/* ---------- نوار پایین: کد تخفیف / بروزرسانی سبد ---------- */
.tamyar-cart-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    padding: 18px 22px;
    border-top: 1px solid var(--tl-border);
}

.tamyar-coupon {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 10px;
    flex: 1 1 280px;
    max-width: 380px;
}

.tamyar-coupon #coupon_code {
    flex: 1;
    min-width: 150px;
    padding: 11px 16px;
    border: 1.5px solid var(--tl-border);
    border-radius: var(--tl-radius-pill);
    font-size: 14px;
    background: var(--tl-surface-muted);
    color: var(--tl-text);
    outline: none;
    transition: all .2s;
    text-align: right;
}

.tamyar-coupon #coupon_code:focus {
    border-color: var(--tl-primary);
    background: var(--tl-surface);
    box-shadow: 0 0 0 4px rgba(196, 22, 28, .08);
}

.tamyar-coupon button[name="apply_coupon"] {
    padding: 11px 24px;
    background: var(--tl-primary);
    color: #fff;
    border: none;
    border-radius: var(--tl-radius-pill);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s ease;
}

.tamyar-coupon button[name="apply_coupon"].is-loading {
    opacity: .6;
    cursor: default;
}

.tamyar-coupon button[name="apply_coupon"]:hover {
    background: var(--tl-primary-dark);
}

.tamyar-update-cart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    margin-inline-start: auto;
    padding: 10px 20px;
    background: var(--tl-surface-muted);
    color: var(--tl-text-muted);
    border: none;
    border-radius: var(--tl-radius-pill);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.tamyar-update-cart-btn::before {
    content: "";
    width: 14px;
    height: 14px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23766F6F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'%3E%3C/polyline%3E%3Cpolyline points='1 20 1 14 7 14'%3E%3C/polyline%3E%3Cpath d='M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'%3E%3C/path%3E%3C/svg%3E");
}

.tamyar-update-cart-btn:not(:disabled):hover {
    background: var(--tl-primary);
    color: #fff;
}

.tamyar-update-cart-btn:not(:disabled):hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'%3E%3C/polyline%3E%3Cpolyline points='1 20 1 14 7 14'%3E%3C/polyline%3E%3Cpath d='M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'%3E%3C/path%3E%3C/svg%3E");
}

/* ---------- سایدبار جمع‌کل (خروجی خودِ ووکامرس: .cart_totals و ...) ---------- */
.tamyar-cart-sidebar {
    flex: 1 1 300px;
    min-width: 280px;
}

@media (min-width: 992px) {
    .tamyar-cart-sidebar {
        position: sticky;
        top: 24px;
    }
}

.tamyar-cart-sidebar .cart_totals {
    background: var(--tl-surface-muted);
    border-radius: var(--tl-radius-lg);
    padding: 28px 24px;
    border: none;
    box-shadow: none;
}

.tamyar-cart-sidebar .cart_totals h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--tl-text);
    margin: 0 0 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--tl-primary);
    display: inline-block;
    text-align: right;
}

.tamyar-cart-sidebar .shop_table {
    width: 100%;
    border-spacing: 0;
    background: transparent;
    box-shadow: none;
}

.tamyar-cart-sidebar .shop_table tr {
    border-bottom: 1px solid var(--tl-border);
}

.tamyar-cart-sidebar .shop_table tr:last-child {
    border-bottom: none;
}

.tamyar-cart-sidebar .shop_table th,
.tamyar-cart-sidebar .shop_table td {
    padding: 13px 0;
    text-align: right;
    background: transparent;
    border: none;
    font-size: 14.5px;
}

.tamyar-cart-sidebar .shop_table th {
    font-weight: 600;
    color: var(--tl-text-muted);
}

.tamyar-cart-sidebar .shop_table td {
    font-weight: 500;
    color: var(--tl-text);
}

.tamyar-cart-sidebar .order-total th,
.tamyar-cart-sidebar .order-total td {
    padding-top: 16px;
    font-size: 16.5px;
    font-weight: 700;
    color: var(--tl-text);
}

.tamyar-cart-sidebar .order-total .woocommerce-Price-amount {
    color: var(--tl-primary) !important;
    font-size: 20px;
    font-weight: 800;
}

.tamyar-cart-sidebar .woocommerce-shipping-methods {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tamyar-cart-sidebar .woocommerce-shipping-methods li {
    padding: 6px 0;
    text-align: right;
    font-size: 13.5px;
}

.tamyar-cart-sidebar .woocommerce-shipping-destination {
    font-size: 12.5px;
    color: var(--tl-text-muted);
    background: var(--tl-surface);
    padding: 8px 12px;
    border-radius: var(--tl-radius-sm);
    margin-top: 8px;
    display: block;
}

/* دکمه اقدام به پرداخت */
.tamyar-cart-sidebar .wc-proceed-to-checkout {
    padding: 0;
    margin-top: 20px;
}

.tamyar-cart-sidebar .wc-proceed-to-checkout .checkout-button {
    display: block;
    width: 100%;
    padding: 16px 20px;
    background: var(--tl-primary);
    color: #fff !important;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: var(--tl-radius-pill);
    text-decoration: none;
    transition: background .2s ease, box-shadow .2s ease;
    box-shadow: none;
}

.tamyar-cart-sidebar .wc-proceed-to-checkout .checkout-button:hover {
    background: var(--tl-primary-dark);
    box-shadow: 0 4px 14px rgba(196, 22, 28, .2);
}

/* ---------- سبد خرید خالی ---------- */
.tamyar-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 440px;
    margin: 0 auto;
    padding: 70px 20px;
}

.tamyar-cart-empty__icon {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--tl-surface-muted);
    color: var(--tl-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.tamyar-cart-empty__title {
    font-size: 19px;
    font-weight: 700;
    color: var(--tl-text);
    margin: 0 0 8px;
}

.tamyar-cart-empty__text {
    font-size: 15.5px;
    color: var(--tl-text-muted);
    margin: 0 0 24px;
}

.tamyar-cart-empty__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 28px;
    background: var(--tl-primary);
    color: #fff !important;
    border-radius: var(--tl-radius-pill);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s ease;
}

.tamyar-cart-empty__cta:hover {
    background: var(--tl-primary-dark);
}

/* ==========================================
   واکنش‌گرایی — هر آیتم به یک کارت تبدیل می‌شه و جمع‌کل به یک
   نوار پرداخت شناور در پایین صفحه تبدیل می‌شه
   ========================================== */
@media (max-width: 767px) {
    .tamyar-cart-layout {
        flex-direction: column;
        gap: 18px;
    }

    /* --- کارت هر محصول --- */
    .tamyar-cart-item {
        display: grid;
        grid-template-columns: 60px 1fr;
        grid-template-areas:
            "thumb body"
            "qty   subtotal";
        column-gap: 12px;
        row-gap: 10px;
        padding: 16px 44px 16px 16px;
    }

    .tamyar-cart-item__thumb {
        grid-area: thumb;
    }

    .tamyar-cart-item__thumb img {
        width: 60px;
        height: 60px;
    }

    .tamyar-cart-item__body {
        grid-area: body;
    }

    .tamyar-cart-item__price--desktop {
        display: none;
    }

    .tamyar-cart-item__price--mobile {
        display: block;
    }

    .tamyar-cart-item__qty {
        grid-area: qty;
        justify-self: start;
    }

    .tamyar-cart-item__subtotal {
        grid-area: subtotal;
        justify-self: end;
        align-self: center;
        width: auto;
        text-align: left;
    }

    .tamyar-cart-item__remove {
        position: absolute;
        top: 14px;
        left: 14px;
    }

    /* --- نوار عملیات (کد تخفیف / بروزرسانی) --- */
    .tamyar-cart-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .tamyar-coupon {
        max-width: none;
        width: 100%;
    }

    .tamyar-update-cart-btn {
        margin-inline-start: 0;
        width: 100%;
    }

    /* --- فضای پایین لیست، تا زیر نوار پرداخت شناور قایم نشه --- */
    .tamyar-cart-main {
        margin-bottom: 260px;
    }

    /* --- نوار پرداخت شناور و همیشه در دید، چسبیده به پایین صفحه --- */
    .tamyar-cart-sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99999999;
        min-width: 0;
        max-height: 65vh;
        overflow-y: auto;
        background: var(--tl-surface);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 28px rgba(0, 0, 0, .18);
    }

    .tamyar-cart-sidebar::before {
        content: "";
        position: sticky;
        top: 0;
        display: block;
        width: 40px;
        height: 4px;
        margin: 10px auto 0;
        border-radius: var(--tl-radius-pill);
        background: var(--tl-border);
    }

    .tamyar-cart-sidebar .cart_totals {
        border-radius: 0;
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    }

    .tamyar-cart-sidebar .cart_totals h2 {
        font-size: 15px;
        margin: 0 0 10px;
        padding-bottom: 8px;
    }
}
