/* جلوگیری از نمایش عناصر پنهان، حتی با وجود استایل عمومی صفحات. */
.zhiura-cart-backdrop[hidden],
.zhiura-cart-drawer[hidden],
.zhiura-cart-toast[hidden],
#cartLoading[hidden],
#cartError[hidden],
#cartEmpty[hidden],
#cartSummary[hidden],
#cartUnavailable[hidden],
[data-cart-count][hidden] {
    display: none !important;
}

/* پس‌زمینه کشوی سبد. */
.zhiura-cart-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #041d19a6;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ظرف اصلی سبد؛ کلاس‌ها مستقل از قالب صفحات هستند. */
.zhiura-cart-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(460px, 100%);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    background: #f3f6f3;
    color: #063b36;
    box-shadow: 0 0 45px #0003;
    font-family: "Vazirmatn", Tahoma, sans-serif;
}

    .zhiura-cart-drawer,
    .zhiura-cart-drawer *,
    .zhiura-cart-toast,
    .zhiura-cart-toast * {
        box-sizing: border-box;
    }

/* سربرگ و دکمه بستن. */
.zhiura-cart-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid #063b3615;
}

    .zhiura-cart-header h2 {
        margin: 6px 0 0;
        font-size: 22px;
    }

    .zhiura-cart-header small {
        color: #a77e29;
    }

    .zhiura-cart-header button,
    .zhiura-cart-line button {
        border: 0;
        border-radius: 12px;
        padding: 10px 14px;
        background: #e6ede8;
        color: #063b36;
        cursor: pointer;
        font: inherit;
    }

/* محصولات؛ اسکرول فقط داخل این بخش انجام می‌شود. */
.zhiura-cart-lines {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 20px;
}

.zhiura-cart-line {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #063b3615;
}

    .zhiura-cart-line img {
        display: block;
        width: 70px;
        height: 70px;
        object-fit: cover;
        border-radius: 14px;
    }

    .zhiura-cart-line h3 {
        font-size: 14px;
        margin: 0 0 8px;
        overflow-wrap: anywhere;
    }

    .zhiura-cart-line p {
        font-size: 12px;
        margin: 0;
        line-height: 1.8;
    }

/* وضعیت بارگذاری، خالی‌بودن و خطای دریافت. */
.zhiura-cart-message,
.zhiura-cart-error {
    padding: 28px;
    text-align: center;
    line-height: 2;
}

.zhiura-cart-error,
.zhiura-cart-unavailable {
    color: #a83228;
}

/* جمع مبلغ و ادامه خرید. */
.zhiura-cart-summary {
    flex-shrink: 0;
    padding: 22px;
    border-top: 1px solid #063b3615;
}

    .zhiura-cart-summary > div {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
    }

    .zhiura-cart-summary p {
        font-size: 12px;
        color: #a83228;
        line-height: 2;
    }

    .zhiura-cart-summary button {
        width: 100%;
        margin-top: 18px;
        padding: 14px;
        border: 0;
        border-radius: 14px;
        background: #063b36;
        color: white;
        cursor: pointer;
        font: inherit;
    }

        .zhiura-cart-summary button:disabled,
        .zhiura-cart-line button:disabled {
            opacity: .55;
            cursor: not-allowed;
        }

/* پیام موفقیت؛ بدون تعریف تکراری رنگ. */
.zhiura-cart-toast {
    position: fixed;
    inset-inline-start: 20px;
    bottom: 20px;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: min(440px, calc(100% - 40px));
    padding: 18px;
    border-radius: 16px;
    background: #146c43;
    color: #fff;
    box-shadow: 0 12px 30px #0003;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    line-height: 1.8;
}

    .zhiura-cart-toast[data-type="error"] {
        background: #a83228;
    }

    .zhiura-cart-toast button {
        flex-shrink: 0;
        border: 0;
        background: transparent;
        color: inherit;
        font-size: 22px;
        cursor: pointer;
    }

#cartToastMessage {
    overflow-wrap: anywhere;
}

/* شمارنده مشترک هدرها. */
[data-cart-count] {
    font-size: 10px;
}

/* فوکوس قابل مشاهده برای استفاده با کیبورد. */
.zhiura-cart-drawer button:focus-visible,
.zhiura-cart-toast button:focus-visible {
    outline: 2px solid #c9a24a;
    outline-offset: 3px;
}

/* اندازه موبایل. */
@media (max-width: 420px) {
    .zhiura-cart-line {
        grid-template-columns: 54px minmax(0, 1fr) auto;
        gap: 8px;
    }

        .zhiura-cart-line img {
            width: 54px;
            height: 54px;
        }

        .zhiura-cart-line button {
            padding: 8px;
            font-size: 12px;
        }
}
