/* =============================================================
   مینی‌سبد کشویی + کارت «به سبد اضافه شد» — includes/header/cart/cart-drawer.php
   پنل از سمت چپ (انتهای سطر در فارسی، همان سمت آیکون سبد) باز می‌شود.
============================================================= */
.bkh-cd, .bkh-toast { font-family: var(--bkh-font); box-sizing: border-box; }
.bkh-cd *, .bkh-toast * { box-sizing: border-box; }
.bkh-cd[hidden], .bkh-toast[hidden] { display: none !important; }

.bkh-cd { position: fixed; inset: 0; z-index: 10040; }
.bkh-cd__backdrop { position: absolute; inset: 0; background: rgb(var(--overlay-rgb) / .45); opacity: 0; transition: opacity .25s ease; }
.bkh-cd__panel {
    position: absolute; inset-block: 0; inset-inline-end: 0; display: flex; flex-direction: column;
    width: min(27rem, 100vw); max-width: 100%; background: var(--bkh-white); color: var(--bkh-ink);
    box-shadow: 0 0 40px rgb(var(--shadow-rgb) / calc(.18 * var(--shadow-strength))); transform: translateX(-100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); outline: none;
}
@media (max-width: 1023px) {
    .bkh-cd__panel { width: min(26rem, 92vw); }
    /* موبایل: نوار پایین روی صفحه می‌ماند (مثل پنل دسته‌ها) تا با لمس دوبارهٔ «سبد خرید» بسته شود */
    body:not(.bkh-no-bnav) .bkh-cd { bottom: calc(var(--bkh-bnav-h, 3.5rem) + var(--bkh-safe-b, 0px)); }
    body:not(.bkh-no-bnav) .bkh-cd__foot { padding-bottom: .75rem; box-shadow: none; }
}
.bkh-cd.is-open .bkh-cd__backdrop { opacity: 1; }
/* نوار مدیریت وردپرس (فقط مدیرها) روی بالای پنل نیفتد؛ زیر ۶۰۰px آن نوار ثابت نیست و همراه صفحه می‌رود */
@media (min-width: 601px) {
    body.admin-bar .bkh-cd__panel { inset-block-start: var(--wp-admin--admin-bar--height, 32px); }
}
.bkh-cd.is-open .bkh-cd__panel { transform: none; }

.bkh-cd__head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--bkh-muted); }
.bkh-cd__title { margin: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.5; }
.bkh-cd__n { color: var(--bkh-gray); font-weight: 600; font-size: .9em; }
body .bkh-cd button.bkh-cd__close,
body .bkh-cd button.bkh-cd__close:hover,
body .bkh-cd button.bkh-cd__close:focus { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin: 0; padding: 0; border: 0; border-radius: var(--border-radius-full); background: transparent; color: var(--bkh-ink); cursor: pointer; }
body .bkh-cd button.bkh-cd__close:hover { background: var(--bkh-muted); }
.bkh-cd__close .bkh-i { width: 1.375rem; height: 1.375rem; }
.bkh-cd__alert { margin: .5rem 1rem 0; padding: .5rem .75rem; border-radius: var(--border-radius-m); background: var(--status-error-soft); color: var(--status-error-ink-strong); font-size: var(--bkh-fs); }

.bkh-cd__body { position: relative; display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.bkh-cd__body.is-busy > :not(.bkh-cd__loading) { opacity: .5; pointer-events: none; }
.bkh-cd__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .75rem 1rem 1rem; -webkit-overflow-scrolling: touch; }

/* بارگذاری */
.bkh-cd__loading { display: flex; justify-content: center; gap: .375rem; margin: auto; padding: 3rem 0; }
.bkh-cd__loading span { width: .625rem; height: .625rem; border-radius: 50%; background: var(--bkh-gold); animation: bkh-cd-dot 1s ease-in-out infinite; }
.bkh-cd__loading span:nth-child(2) { animation-delay: .15s; }
.bkh-cd__loading span:nth-child(3) { animation-delay: .3s; }
@keyframes bkh-cd-dot { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-6px); opacity: 1; } }

/* نوار ارسال رایگان (پنل و کارت تأیید) */
.bkh-fs { margin-bottom: .75rem; padding: .625rem .75rem; border-radius: var(--border-radius-m); background: var(--bkh-warm); }
.bkh-fs__msg { margin: 0 0 .4rem; font-size: var(--bkh-fs); line-height: 1.7; }
.bkh-fs__msg .woocommerce-Price-amount { white-space: nowrap; }
.bkh-fs__bar { height: .375rem; overflow: hidden; border-radius: var(--border-radius-full); background: color-mix(in srgb, var(--bkh-green) 16%, transparent); }
.bkh-fs__bar span { display: block; height: 100%; border-radius: inherit; background: var(--bkh-green); transition: width .4s ease; }
.bkh-fs--free { background: color-mix(in srgb, var(--bkh-green) 12%, var(--bkh-white)); }
.bkh-fs--free .bkh-fs__msg { color: var(--bkh-green-d); margin-bottom: .4rem; }
.bkh-fs--blocked .bkh-fs__msg { margin: 0; color: var(--bkh-ink2); }

/* کالاها */
.bkh-cd__items, .bkh-cd__ups ul { margin: 0; padding: 0; list-style: none; }
.bkh-cd__item, .bkh-cd__up { display: flex; gap: .75rem; margin: 0; padding: .75rem 0; border-bottom: 1px solid var(--bkh-muted); transition: opacity .2s; }
.bkh-cd__item:last-child { border-bottom: 0; }
.bkh-cd__item.is-busy { opacity: .45; pointer-events: none; }
.bkh-cd__thumb { flex: none; width: 4.5rem; height: 4.5rem; overflow: hidden; border-radius: var(--border-radius-m); background: var(--bkh-muted); }
body .bkh-cd .bkh-cd__img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.bkh-cd__info { display: flex; flex: 1 1 auto; flex-direction: column; gap: .25rem; min-width: 0; }
body .bkh-cd a.bkh-cd__name, body .bkh-cd .bkh-cd__name { display: -webkit-box; overflow: hidden; color: var(--bkh-ink); font-size: var(--bkh-fs); font-weight: 600; line-height: 1.6; text-decoration: none; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
body .bkh-cd a.bkh-cd__name:hover { color: var(--bkh-green-d); }
.bkh-cd__meta { color: var(--bkh-gray); font-size: var(--bkh-fs-s); }
.bkh-cd__warn { margin: 0; color: var(--status-error-ink); font-size: var(--bkh-fs-s); }
.bkh-cd__row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; }
.bkh-cd__price { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-size: var(--bkh-fs); line-height: 1.4; text-align: end; }
.bkh-cd__price del { color: var(--bkh-gray); font-weight: 400; font-size: .85em; }
.bkh-cd__price ins { text-decoration: none; }

/* شمارنده: [+] ۲ [−] */
.bkh-cd__qty { display: inline-flex; align-items: center; height: 2.25rem; border: 1px solid var(--bkh-muted); border-radius: var(--border-radius-full); }
body .bkh-cd button.bkh-cd__q,
body .bkh-cd button.bkh-cd__q:hover,
body .bkh-cd button.bkh-cd__q:focus { display: grid; place-items: center; width: 2.25rem; height: 100%; margin: 0; padding: 0; border: 0; border-radius: var(--border-radius-full); background: transparent; color: var(--bkh-green); cursor: pointer; }
body .bkh-cd button.bkh-cd__q:hover { background: var(--bkh-muted); }
body .bkh-cd button.bkh-cd__q.is-remove { color: var(--status-error-ink); }
body .bkh-cd button.bkh-cd__q:disabled { opacity: .35; cursor: default; }
.bkh-cd__q svg { width: 1.125rem; height: 1.125rem; }
.bkh-cd__qn { min-width: 1.75rem; text-align: center; font-weight: 700; font-size: var(--bkh-fs); }

/* محصولات مکمل */
.bkh-cd__ups { margin-top: 1rem; padding: .75rem; border-radius: var(--border-radius-m); background: var(--bkh-warm); }
.bkh-cd__h3 { margin: 0 0 .25rem; font-size: var(--bkh-fs); font-weight: 700; }
.bkh-cd__up { padding: .5rem 0; border-color: color-mix(in srgb, var(--bkh-ink) 8%, transparent); }
.bkh-cd__up:last-child { border-bottom: 0; }
.bkh-cd__up .bkh-cd__thumb { width: 3.5rem; height: 3.5rem; background: var(--bkh-white); }
.bkh-cd__up .bkh-cd__price { font-weight: 600; }
body .bkh-cd button.bkh-cd__add,
body .bkh-cd button.bkh-cd__add:hover,
body .bkh-cd button.bkh-cd__add:focus { display: inline-flex; align-items: center; gap: .25rem; height: 2rem; margin: 0; padding: 0 .75rem; border: 1.5px solid var(--bkh-green); border-radius: var(--border-radius-full); background: var(--bkh-white); color: var(--bkh-green-d); font: inherit; font-size: var(--bkh-fs-s); font-weight: 700; cursor: pointer; }
body .bkh-cd button.bkh-cd__add:hover { background: var(--bkh-green); color: var(--bkh-on-brand); }
.bkh-cd__add svg { width: 1rem; height: 1rem; }
.bkh-cd__add.is-busy { opacity: .5; }

/* پایین پنل */
.bkh-cd__foot { flex: none; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--bkh-muted); background: var(--bkh-white); box-shadow: 0 -6px 16px rgb(var(--shadow-rgb) / calc(.04 * var(--shadow-strength))); }
.bkh-cd__sum { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; font-size: var(--bkh-fs); }
.bkh-cd__sum strong { font-size: 1.0625rem; }
.bkh-cd__sum--save { margin-top: .125rem; color: var(--bkh-green-d); }
.bkh-cd__sum--save strong { font-size: var(--bkh-fs); }
.bkh-cd__note { margin: .25rem 0 .625rem; color: var(--bkh-gray); font-size: var(--bkh-fs-s); }
body .bkh-cd a.bkh-cd__btn, body .bkh-cd a.bkh-cd__btn:visited { display: flex; align-items: center; justify-content: center; min-height: 3rem; margin: 0; padding: 0 1rem; border-radius: var(--border-radius-l); font-size: var(--bkh-fs-in); font-weight: 700; text-decoration: none; }
body .bkh-cd a.bkh-cd__btn--main { background: var(--bkh-green); color: var(--bkh-on-brand); }
body .bkh-cd a.bkh-cd__btn--main:hover { background: var(--bkh-green-d); color: var(--bkh-on-brand); }
body .bkh-cd a.bkh-cd__btn--ghost { min-height: 2.5rem; margin-top: .375rem; color: var(--bkh-green-d); font-size: var(--bkh-fs); }
body .bkh-cd a.bkh-cd__btn--ghost:hover { text-decoration: underline; }
body .bkh-cd a:focus-visible, body .bkh-cd button:focus-visible { outline: 2px solid var(--bkh-green); outline-offset: 2px; }

/* سبد خالی */
.bkh-cd__empty { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin: auto; padding: 2rem 1.5rem; text-align: center; color: var(--bkh-ink2); }
.bkh-cd__empty svg { width: 4rem; height: 4rem; color: var(--bkh-gray); }
.bkh-cd__empty p { margin: 0; font-size: var(--bkh-fs-in); }
.bkh-cd__empty .bkh-cd__btn { min-width: 12rem; }

/* ---- کارت «به سبد اضافه شد» ---- */
.bkh-toast {
    position: fixed; z-index: 10030; top: calc(var(--bk-header-h, 4rem) + .5rem); inset-inline-end: var(--bkh-gutter, 1rem);
    width: min(23rem, calc(100vw - 2rem)); padding: .875rem 1rem 1rem; border-radius: var(--border-radius-l);
    background: var(--bkh-white); color: var(--bkh-ink); box-shadow: 0 12px 32px rgb(var(--shadow-rgb) / calc(.18 * var(--shadow-strength)));
    opacity: 0; transform: translateY(-.75rem); transition: opacity .22s ease, transform .22s ease;
}
.bkh-toast.is-in { opacity: 1; transform: none; }
@media (max-width: 1023px) { .bkh-toast { inset-inline: .75rem; width: auto; } }
.bkh-toast__top { display: flex; align-items: center; gap: .5rem; margin-bottom: .625rem; font-size: var(--bkh-fs); }
.bkh-toast__ok { display: grid; place-items: center; flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--bkh-green); color: var(--bkh-on-brand); }
.bkh-toast__ok svg { width: 1rem; height: 1rem; }
body .bkh-toast button.bkh-toast__x,
body .bkh-toast button.bkh-toast__x:hover,
body .bkh-toast button.bkh-toast__x:focus { display: grid; place-items: center; width: 2rem; height: 2rem; margin: 0; margin-inline-start: auto; padding: 0; border: 0; border-radius: var(--border-radius-full); background: transparent; color: var(--bkh-gray); cursor: pointer; }
.bkh-toast__x svg { width: 1.125rem; height: 1.125rem; }
.bkh-toast__item { display: flex; align-items: center; gap: .75rem; margin-bottom: .625rem; }
.bkh-toast__item img { flex: none; width: 3.5rem; height: 3.5rem; border-radius: var(--border-radius-m); background: var(--bkh-muted); object-fit: cover; }
.bkh-toast__name { display: -webkit-box; overflow: hidden; font-size: var(--bkh-fs); font-weight: 600; line-height: 1.6; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bkh-toast .bkh-fs { margin-bottom: .75rem; }
.bkh-toast__btns { display: flex; gap: .5rem; }
body .bkh-toast .bkh-toast__btn,
body .bkh-toast .bkh-toast__btn:hover,
body .bkh-toast .bkh-toast__btn:focus,
body .bkh-toast a.bkh-toast__btn:visited {
    display: flex; flex: 1 1 0; align-items: center; justify-content: center; min-height: 2.75rem; margin: 0; padding: 0 .75rem;
    border: 1.5px solid var(--bkh-green); border-radius: var(--border-radius-m); font: inherit; font-size: var(--bkh-fs); font-weight: 700; text-decoration: none; cursor: pointer;
}
body .bkh-toast .bkh-toast__btn--ghost { background: var(--bkh-white); color: var(--bkh-green-d); }
body .bkh-toast .bkh-toast__btn--main { background: var(--bkh-green); color: var(--bkh-on-brand); }
body .bkh-toast .bkh-toast__btn:focus-visible, body .bkh-toast button:focus-visible { outline: 2px solid var(--bkh-green); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .bkh-cd__backdrop, .bkh-cd__panel, .bkh-toast, .bkh-fs__bar span { transition: none !important; }
    .bkh-cd__loading span { animation: none; }
}
