/* =================================================== */
/* ISOLATED CSS RESET FOR CUSTOM BUY BLOCK             */
/* =================================================== */

.cpc-wrapper,
.cpc-wrapper * {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.cpc-wrapper {
    width: 100% !important;
    margin: 0 auto !important;
    direction: rtl !important;
    text-align: right !important;
    font-family: inherit !important;
    clear: both !important;
}

/* 🖥️ DESKTOP VIEW CONTROL */
@media screen and (min-width: 768px) {
    .cpc-wrapper .cpc-mobile-view { display: none !important; }
    .cpc-wrapper .cpc-desktop-view { display: block !important; }
    .cpc-wrapper .cpc-view-cart-mobile { display: none !important; }
}

/* 📱 MOBILE VIEW CONTROL */
@media screen and (max-width: 767px) {
    .cpc-wrapper .cpc-desktop-view { display: none !important; }
    .cpc-wrapper .cpc-mobile-view { display: block !important; }
    .cpc-wrapper .cpc-view-cart-desktop { display: none !important; }
}

/* Attributes Wrap */
.cpc-wrapper .cpc-attributes-wrap {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
}

.cpc-wrapper .cpc-attr-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-size: 12px !important;
    color: #475569 !important;
}

.cpc-wrapper .cpc-select-attr {
    flex: 1 !important;
    height: 34px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    color: #1e293b !important;
    background: #ffffff !important;
    outline: none !important;
}

/* 📐 VERTICAL ORIENTATION */
.cpc-wrapper .cpc-card.cpc-orientation-vertical {
    max-width: 360px !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 20px !important;
    position: relative !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03), 0 12px 28px rgba(15, 23, 42, 0.05) !important;
}

/* 📐 HORIZONTAL ORIENTATION */
.cpc-wrapper .cpc-card.cpc-orientation-horizontal {
    max-width: 720px !important;
    width: 100% !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 20px !important;
    position: relative !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04) !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: center !important;
}

.cpc-wrapper .cpc-card.cpc-orientation-horizontal .cpc-image-box {
    flex: 0 0 220px !important;
    height: 220px !important;
    margin-bottom: 0 !important;
}

.cpc-wrapper .cpc-card.cpc-orientation-horizontal .cpc-card-content { flex: 1 !important; }

.cpc-wrapper .cpc-card.cpc-no-image { padding-top: 28px !important; }
.cpc-wrapper .cpc-card.cpc-no-image .cpc-title { padding-left: 65px !important; }

/* Discount Badge */
.cpc-wrapper .cpc-badge {
    position: absolute !important;
    top: 16px !important;
    left: 16px !important;
    background: #e54b4b !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: bold !important;
    letter-spacing: 0.2px !important;
    padding: 6px 11px !important;
    border-radius: 10px !important;
    text-align: center !important;
    line-height: 1.35 !important;
    z-index: 5 !important;
    box-shadow: 0 6px 14px rgba(229, 75, 75, 0.3) !important;
}

.cpc-wrapper .cpc-badge span { display: block !important; }

/* Image */
.cpc-wrapper .cpc-image-box {
    width: 100% !important;
    height: 190px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-bottom: 12px !important;
}

.cpc-wrapper .cpc-image-box a {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
}

.cpc-wrapper .cpc-image-box img {
    max-height: 100% !important;
    max-width: 100% !important;
    object-fit: contain !important;
    transition: transform 0.3s ease !important;
    border: none !important;
    box-shadow: none !important;
}

.cpc-wrapper .cpc-card:hover .cpc-image-box img { transform: scale(1.03) !important; }

/* Title */
.cpc-wrapper .cpc-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    margin: 0 0 12px 0 !important;
    line-height: 1.6 !important;
}

.cpc-wrapper .cpc-title a { color: inherit !important; text-decoration: none !important; transition: color 0.2s ease !important; }
.cpc-wrapper .cpc-title a:hover { color: var(--cpc-btn-c2, #ff5500) !important; }

/* Colors */
.cpc-wrapper .cpc-color-options {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
}

.cpc-wrapper .cpc-color-item {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    cursor: pointer !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.2s ease !important;
    user-select: none !important;
}

.cpc-wrapper .cpc-color-item.active {
    border-color: var(--cpc-btn-c2, #ff5500) !important;
    background: #fff5f0 !important;
    font-weight: 600 !important;
    color: var(--cpc-btn-c2, #ff5500) !important;
}

.cpc-wrapper .cpc-dot {
    width: 14px !important;
    height: 14px !important;
    border-radius: 50% !important;
    display: inline-block !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

/* Divider & Spacing Fixes */
.cpc-wrapper .cpc-divider {
    border: 0 !important;
    border-top: 1px dashed #e2e8f0 !important;
    margin: 14px 0 !important;
    clear: both !important;
    height: 1px !important;
    background: transparent !important;
}

.cpc-wrapper .cpc-price-divider { margin: 18px 0 16px 0 !important; }

/* Info List */
.cpc-wrapper .cpc-info-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 11px !important;
}

.cpc-wrapper .cpc-info-item {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 12px !important;
    color: #334155 !important;
    line-height: 1.4 !important;
}

.cpc-wrapper .cpc-info-text { display: flex !important; align-items: center !important; gap: 4px !important; flex-wrap: wrap !important; }
.cpc-wrapper .cpc-green-text { color: #059669 !important; }
.cpc-wrapper .cpc-red-text { color: #dc2626 !important; }

/* SVG Icon */
.cpc-wrapper .cpc-icon {
    width: 20px !important;
    height: 20px !important;
    color: #64748b !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
}

.cpc-wrapper .cpc-icon svg { width: 100% !important; height: 100% !important; display: block !important; }
.cpc-wrapper .cpc-green-icon { color: #059669 !important; }
.cpc-wrapper .cpc-red-icon { color: #dc2626 !important; }

/* Rating */
.cpc-wrapper .cpc-stars-wrap { display: inline-flex !important; align-items: center !important; gap: 3px !important; margin-right: 6px !important; font-size: 10px !important; }
.cpc-wrapper .cpc-stars { color: #f59e0b !important; }
.cpc-wrapper .cpc-rating-text { color: #94a3b8 !important; }

/* Price & Square Quantity Row Layout */
.cpc-wrapper .cpc-price-qty-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin: 16px 0 !important;
    padding: 0 !important;
    gap: 12px !important;
}

.cpc-wrapper .cpc-price-and-cart-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    width: 100% !important;
}

.cpc-wrapper .cpc-price-box { text-align: left !important; flex-shrink: 0 !important; }
.cpc-wrapper .cpc-old-price { font-size: 12px !important; color: #94a3b8 !important; text-decoration: line-through !important; margin-bottom: 2px !important; }
.cpc-wrapper .cpc-current-price { font-size: 16px !important; color: #0f172a !important; font-weight: 800 !important; }

/* Square Quantity Controller */
.cpc-wrapper .cpc-qty-box {
    display: inline-flex !important;
    align-items: center !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    height: 38px !important;
    width: auto !important;
    max-width: 120px !important;
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
}

.cpc-wrapper .cpc-qty-btn {
    background: #f8fafc !important;
    border: none !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #475569 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.cpc-wrapper .cpc-qty-btn:hover { background: #e2e8f0 !important; }

.cpc-wrapper input[type="number"].cpc-qty-input {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 38px !important;
    border: none !important;
    border-left: 1px solid #cbd5e1 !important;
    border-right: 1px solid #cbd5e1 !important;
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    -moz-appearance: textfield !important;
}

.cpc-wrapper input[type="number"].cpc-qty-input::-webkit-outer-spin-button,
.cpc-wrapper input[type="number"].cpc-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Shipping Info */
.cpc-wrapper .cpc-shipping {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    font-size: 11px !important;
    color: #475569 !important;
    margin-bottom: 16px !important;
    line-height: 1.5 !important;
    background: #f8fafc !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
}
.cpc-wrapper .cpc-shipping .cpc-icon { margin-top: 2px !important; }

/* ========================================================= */
/* 🛒 INLINE BUTTONS ROW (ردیف دکمه‌های دسکتاپ)              */
/* ========================================================= */
.cpc-wrapper .cpc-buttons-inline-row {
    display: flex !important;
    flex-direction: row !important; /* جهت RTL: اولین عنصر سمت راست، دومین عنصر سمت چپ قرار میگیرد */
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    width: 100% !important;
}

/* ۱. دکمه مشاهده سبد خرید (کادر سبز در تصویر - سمت راست) */
.cpc-wrapper .cpc-view-cart-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    height: 48px !important;
    padding: 0 10px !important;
    background: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    flex: 1 !important; /* عرض متناسب (۵۰٪ کوچکتر از دکمه اصلی) */
}

.cpc-wrapper .cpc-view-cart-btn:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

.cpc-wrapper .cpc-cart-ic {
    width: 16px !important;
    height: 16px !important;
    color: #64748b !important;
}

/* ۲. دکمه افزودن به سبد خرید (کادر نارنجی در تصویر - سمت چپ) */
.cpc-wrapper .cpc-add-to-cart-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex: 1.8 !important; /* عرض کشیده و سایز اصلی */
    height: 48px !important;
    font-weight: bold !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    user-select: none !important;
    white-space: nowrap !important;
}

/* استایل‌های ۵ گانه دکمه افزودن به سبد */
.cpc-wrapper .cpc-btn-style-1 { background: linear-gradient(180deg, var(--cpc-btn-c1, #ff8c42) 0%, var(--cpc-btn-c2, #ff5500) 100%) !important; color: #ffffff !important; border: none !important; border-radius: 12px !important; box-shadow: 0 4px 15px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important; }
.cpc-wrapper .cpc-btn-style-1:hover { transform: translateY(-3px) scale(1.01) !important; box-shadow: 0 8px 25px rgba(255, 85, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important; }
.cpc-wrapper .cpc-btn-style-2 { background: linear-gradient(135deg, var(--cpc-btn-c1, #ff8c42) 0%, var(--cpc-btn-c2, #ff5500) 100%) !important; color: #ffffff !important; border: none !important; border-radius: 30px !important; box-shadow: 0 0 15px var(--cpc-btn-c2, #ff5500) !important; }
.cpc-wrapper .cpc-btn-style-2:hover { box-shadow: 0 0 28px var(--cpc-btn-c1, #ff8c42) !important; transform: scale(1.03) !important; }
.cpc-wrapper .cpc-btn-style-3 { background: var(--cpc-btn-c2, #ff5500) !important; color: #ffffff !important; border: none !important; border-radius: 8px !important; box-shadow: none !important; }
.cpc-wrapper .cpc-btn-style-3:hover { background: var(--cpc-btn-c1, #ff8c42) !important; transform: translateY(-2px) !important; }
.cpc-wrapper .cpc-btn-style-4 { background: linear-gradient(180deg, var(--cpc-btn-c1, #ff8c42) 0%, var(--cpc-btn-c2, #ff5500) 100%) !important; color: #ffffff !important; border: none !important; border-radius: 12px !important; box-shadow: 0 5px 0 rgba(0,0,0,0.2) !important; }
.cpc-wrapper .cpc-btn-style-4:hover { transform: translateY(-2px) !important; box-shadow: 0 7px 0 rgba(0,0,0,0.25) !important; }
.cpc-wrapper .cpc-btn-style-4:active { transform: translateY(3px) !important; box-shadow: 0 2px 0 rgba(0,0,0,0.2) !important; }
.cpc-wrapper .cpc-btn-style-5 { background: transparent !important; color: var(--cpc-btn-c2, #ff5500) !important; border: 2px solid var(--cpc-btn-c2, #ff5500) !important; border-radius: 12px !important; box-shadow: none !important; }
.cpc-wrapper .cpc-btn-style-5:hover { background: linear-gradient(135deg, var(--cpc-btn-c1, #ff8c42) 0%, var(--cpc-btn-c2, #ff5500) 100%) !important; color: #ffffff !important; border-color: transparent !important; transform: translateY(-2px) !important; box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important; }

/* 🌿 Light Smooth Toast Alert Inside Card */
.cpc-wrapper .cpc-msg {
    margin-top: 12px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-align: center !important;
    display: none;
    padding: 10px 14px !important;
    border-radius: 10px !important;
    animation: cpcFadeIn 0.3s ease-in-out !important;
}

.cpc-wrapper .cpc-msg.success { color: #047857 !important; background-color: #ecfdf5 !important; border: 1px solid #a7f3d0 !important; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1) !important; }
.cpc-wrapper .cpc-msg.error { color: #b91c1c !important; background-color: #fef2f2 !important; border: 1px solid #fca5a5 !important; }

/* 🚀 DESKTOP GLOBAL FLOATING TOAST (بالای صفحه) */
#cpc-global-toast {
    position: fixed !important;
    top: 25px !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(-20px) !important;
    z-index: 9999999 !important;
    background: #047857 !important;
    color: #ffffff !important;
    padding: 12px 24px !important;
    border-radius: 30px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    box-shadow: 0 10px 25px rgba(4, 120, 87, 0.35) !important;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

#cpc-global-toast.cpc-show {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
}

/* 🚫 مخفی شدن نوار چسبان موبایل هنگام باز بودن سایدبار «مشاهده سبد خرید» وودمارت
   تا با آن تداخل بصری پیدا نکند (کلاس‌های wd-opened و cpc-cart-drawer-open) */
body:has(.cart-widget-side.wd-opened) .cpc-mobile-sticky-wrapper,
body.cpc-cart-drawer-open .cpc-mobile-sticky-wrapper {
    display: none !important;
}

/* 🛒 آیتم‌های سایدبار «سبد خرید» (mini-cart) — حذف تصویر و بهینه‌سازی فضای خالی
   توجه: این بخش بر اساس کلاس‌های استاندارد ووکامرس/وودمارت نوشته شده؛ اگر قالب شما
   ساختار HTML متفاوتی دارد و اثر نکرد، اسکرین‌شات از Inspect همان آیتم بفرستید تا دقیق‌تر شود. */
.woocommerce-mini-cart-item .cart-item-image,
.woocommerce-mini-cart-item > a:first-child,
.mini_cart_item > a:first-child,
.woocommerce-mini-cart-item .woocommerce-mini-cart-item__images-wrap {
    display: none !important;
}

.woocommerce-mini-cart-item,
.mini_cart_item {
    padding: 10px 0 !important;
    gap: 4px !important;
}

.woocommerce-mini-cart-item .woocommerce-mini-cart-item__quantity-wrap,
.woocommerce-mini-cart-item .quantity {
    margin-top: 4px !important;
}

/* 📱 MOBILE STICKY BAR & LINEAR TOAST (بالای نوار چسبان) */
.cpc-mobile-sticky-wrapper {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 999999 !important;
}

.cpc-wrapper .cpc-msg-mobile-bar {
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
    text-align: center !important;
    border-top: 1px solid #a7f3d0 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05) !important;
}

/* 💰 چیپ ملایم قیمت - داخل خودِ نوار، بدون بیرون‌زدگی از محدوده نوار
   (چون بیرون‌زدگی با ویجت چت شناور سایت که بالای نوار قرار دارد تداخل پیدا می‌کرد) */
.cpc-wrapper .cpc-mobile-price-chip {
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 6px !important;
    line-height: 1.3 !important;
    pointer-events: none !important;
}

.cpc-wrapper .cpc-mobile-price-chip .cpc-old-price { font-size: 10px !important; color: #94a3b8 !important; text-decoration: line-through !important; }
.cpc-wrapper .cpc-mobile-price-chip .cpc-current-price { font-size: 12px !important; font-weight: 800 !important; color: #0f172a !important; }

@media screen and (max-width: 767px) {
    .cpc-wrapper .cpc-mobile-sticky-bar {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 5px !important;
        position: relative !important;
        width: 100% !important;
        height: 84px !important;
        background: #ffffff !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08) !important;
        border-top: 1px solid #e2e8f0 !important;
        /* گوشه بالا-راست به‌عمد خالی گذاشته شده تا با ویجت چت شناور سایت که در همان گوشه است تداخل نداشته باشد */
        padding: 8px 68px 10px 14px !important;
    }

    .cpc-wrapper .cpc-mobile-price-chip {
        align-self: flex-end !important; /* در RTL یعنی سمت چپ */
    }

    .cpc-wrapper .cpc-mobile-controls-row {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        width: 100% !important;
    }

    /* دکمه افزودن به سبد خرید: کمی کوچکتر شد تا در کنار بقیه اجزا مرتب جا شود */
    .cpc-wrapper .cpc-mobile-controls-row .cpc-mobile-main-btn {
        flex: 1 1 auto !important;
        height: 38px !important;
        font-size: 12px !important;
        padding: 0 8px !important;
        order: 2 !important;
    }

    /* جعبه تعداد: سمت راست نوار، با فاصله استاندارد (دیگر چسبیده به لبه نیست) */
    .cpc-wrapper .cpc-mobile-controls-row .cpc-qty-box {
        flex: 0 0 auto !important;
        height: 36px !important;
        order: 1 !important;
        margin: 0 !important;
    }
    .cpc-wrapper .cpc-mobile-controls-row .cpc-qty-btn { width: 28px !important; min-width: 28px !important; height: 36px !important; font-size: 14px !important; }
    .cpc-wrapper .cpc-mobile-controls-row input[type="number"].cpc-qty-input { width: 28px !important; min-width: 28px !important; height: 36px !important; font-size: 11px !important; }

    /* دکمه مشاهده سبد خرید: فشرده و آیکون‌محور، در لبه نوار */
    .cpc-wrapper .cpc-mobile-controls-row .cpc-mobile-view-cart-btn {
        flex: 0 0 auto !important;
        order: 3 !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        gap: 0 !important;
    }
    .cpc-wrapper .cpc-mobile-controls-row .cpc-mobile-view-cart-btn span { display: none !important; }
}

@keyframes cpcFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
