/* =====================================================================
   سبد خرید (prefix: ct-)
   1) آیکن سبد در منوی بالای سایت و نوار بالای پنل کاربری + نشان تعداد
   2) پیام «به سبد اضافه شد» (Toast)
   3) دکمه‌ی «افزودن به سبد خرید» (کامل و گرد روی کارت محصول)
   4) انتخاب رنگ/سایز در صفحه‌ی محصول
   5) پوشش کارت محصول در لیست دسته‌بندی
   6) صفحه‌ی سبد خرید در پنل کاربری
   7) واکنش‌گرایی (Responsive) و کاهش حرکت
   همه‌ی رنگ‌ها هم‌خوان با تم سایت (var(--gradient-button) ...) و پنل (بنفش/سرمه‌ای) هستند.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1) آیکن سبد + نشان تعداد
   --------------------------------------------------------------------- */
.app-shell .ct-navlink,
.up-shell .ct-navlink {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #000;
    background: transparent;
    text-decoration: none;
    transition: background .2s ease, color .2s ease, transform .15s ease;
    -webkit-tap-highlight-color: transparent;
}

/* خط زیرین سراسری لینک‌ها (a::after) و سایه‌ی hover برای این آیکن خنثی می‌شود */
.app-shell .ct-navlink::after,
.up-shell .ct-navlink::after {
    content: none;
}

.app-shell .ct-navlink:hover,
.up-shell .ct-navlink:hover {
    background: rgba(0, 0, 0, .08);
    color: #000;
    text-shadow: none;
}

.app-shell .ct-navlink:active,
.up-shell .ct-navlink:active {
    transform: scale(.94);
}

.app-shell .ct-navlink:focus-visible,
.up-shell .ct-navlink:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 2px;
}

.app-shell .ct-navlink.is-active {
    background: rgba(99, 102, 241, .14);
}

.ct-navlink svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* نسخه‌ی نوار بالای پنل کاربری */
.up-shell .ct-navlink {
    width: 38px;
    height: 38px;
    color: #3a0647;
}

.up-shell .ct-navlink:hover {
    background: #ede9fe;
    color: #5b21b6;
}

.up-shell .ct-navlink.is-active {
    background: #ede9fe;
    color: #5b21b6;
}

.ct-badge {
    position: absolute;
    top: 1px;
    inset-inline-end: 0;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    background: var(--gradient-button, linear-gradient(135deg, #6366f1, #8b5cf6));
    box-shadow: 0 0 0 2px #fff, 0 3px 8px rgba(99, 102, 241, .4);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    animation: ct-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}

/* نشان داخل لینک سایدبار پنل کاربری */
.up-nav-link.up-nav-link--cart {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.up-nav-link .ct-badge {
    position: static;
    flex-shrink: 0;
    color: #3a0647;
    background: #fff;
    box-shadow: none;
}

.up-topbar-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
}

/* ---------------------------------------------------------------------
   2) پیام «به سبد خرید اضافه شد»
   --------------------------------------------------------------------- */
.ct-toast-region {
    position: fixed;
    inset-inline: 0;
    bottom: 22px;
    z-index: 1100;
    display: flex;
    justify-content: center;
    padding: 0 14px;
    pointer-events: none;
}

.ct-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(540px, 100%);
    padding-block: 10px;
    padding-inline: 14px 10px;
    border-radius: 16px;
    color: #fff;
    background: rgba(30, 27, 75, .95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .35);
    font-size: 14px;
    animation: ct-toast-in .3s cubic-bezier(.22, 1, .36, 1);
}

.ct-toast-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.ct-toast-icon svg {
    width: 16px;
    height: 16px;
}

.ct-toast.is-success .ct-toast-icon {
    background: #10b981;
}

.ct-toast.is-error .ct-toast-icon {
    background: #f59e0b;
}

.ct-toast-text {
    flex: 1;
    min-width: 0;
    line-height: 1.8;
}

.app-shell .ct-toast-link {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    background: rgba(255, 255, 255, .16);
    text-decoration: none;
    transition: background .2s ease;
}

.app-shell .ct-toast-link::after {
    content: none;
}

.app-shell .ct-toast-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .28);
    text-shadow: none;
}

.ct-toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, .7);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.ct-toast-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, .14);
}

/* ---------------------------------------------------------------------
   3) دکمه‌ی «افزودن به سبد خرید»
   --------------------------------------------------------------------- */
.ct-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 26px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: var(--gradient-button, linear-gradient(135deg, #6366f1, #8b5cf6));
    box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ct-add:hover:not(:disabled) {
    background: var(--gradient-button-hover, linear-gradient(135deg, #4338ca, #7c3aed));
    box-shadow: 0 12px 26px rgba(99, 102, 241, .45);
    transform: translateY(-1px);
}

.ct-add:active:not(:disabled) {
    transform: translateY(1px);
}

.ct-add:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 2px;
}

.ct-add:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

.ct-add-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.ct-add.is-busy .ct-add-icon {
    animation: ct-bounce .7s ease-in-out infinite;
}

/* نسخه‌ی گرد و فقط‌آیکن روی عکس کارت محصول */
.ct-add.ct-add--compact {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    z-index: 2;
    width: 40px;
    height: 40px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    color: var(--color-primary-dark, #4338ca);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .2);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.ct-add.ct-add--compact:hover:not(:disabled) {
    color: #fff;
    background: var(--gradient-button, linear-gradient(135deg, #6366f1, #8b5cf6));
    box-shadow: 0 8px 18px rgba(99, 102, 241, .4);
    transform: scale(1.06);
}

.ct-add--compact .ct-add-icon {
    width: 19px;
    height: 19px;
}

/* ---------------------------------------------------------------------
   4) انتخاب رنگ/سایز در صفحه‌ی محصول
   --------------------------------------------------------------------- */
.app-shell .ct-buy {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 4px;
}

.app-shell .ct-buy .ct-add {
    width: 100%;
}

.ct-price-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.ct-option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ct-option-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: #4b5563;
}

.ct-option-label b {
    font-weight: 800;
    color: #1e1b4b;
}

.ct-option-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ct-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1.5px solid var(--color-border-light, #ddd6fe);
    background: #fff;
    color: #1e1b4b;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ct-option:hover {
    border-color: var(--color-primary-light, #a5b4fc);
    background: #f8f7ff;
}

.ct-option:focus-visible {
    outline: 3px solid var(--color-focus-ring, #a5b4fc);
    outline-offset: 2px;
}

.ct-option.is-picked {
    border-color: var(--color-primary-dark, #4338ca);
    background: #eef0ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
    font-weight: 800;
}

/* با انتخاب‌های فعلی تنوعی ندارد؛ کم‌رنگ است ولی قابل کلیک می‌ماند */
.ct-option.is-dim {
    opacity: .45;
}

.ct-swatch {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .2);
}

.ct-unavailable {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   5) پوشش کارت محصول (کارت + دکمه‌ی سبد کنار هم، نه تو در تو)
   --------------------------------------------------------------------- */
.app-shell .shop-card-wrap {
    position: relative;
    display: flex;
    min-width: 0;
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

.app-shell .shop-card-wrap > .shop-card {
    flex: 1;
    min-width: 0;
}

/* بالا رفتن کارت روی خود پوشش انجام می‌شود تا دکمه هم‌راهش بالا بیاید */
.app-shell .shop-card-wrap:hover {
    transform: translateY(-5px);
}

.app-shell .shop-card-wrap > .shop-card:hover {
    transform: none;
}

.app-shell .shop-card-wrap:hover > .shop-card {
    border-color: var(--color-primary-light, #a5b4fc);
    box-shadow: 0 14px 30px rgba(99, 102, 241, .22);
}

/* ---------------------------------------------------------------------
   6) صفحه‌ی سبد خرید در پنل کاربری
   --------------------------------------------------------------------- */
.ct-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: .4rem;
}

.ct-page-head .up-title {
    margin: 0;
}

.ct-count-chip {
    padding: .25rem .8rem;
    border-radius: 999px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: .85rem;
    font-weight: 700;
}

.ct-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1.1rem;
    align-items: start;
    margin-top: .9rem;
}

.ct-list {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    min-width: 0;
}

/* ----- کارت هر کالا ----- */
.ct-item {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    align-items: center;
    gap: .9rem 1rem;
    padding: .8rem;
    background: #fff;
    border: 1px solid #ece9f6;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(58, 6, 71, .06);
    transition: box-shadow .2s ease, border-color .2s ease;
}

.ct-item:hover {
    border-color: #ddd6fe;
    box-shadow: 0 8px 22px rgba(58, 6, 71, .1);
}

.ct-item.is-unpriced {
    border-color: #fcd34d;
    background: #fffbeb;
}

.ct-item-media {
    display: block;
    width: 92px;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 12px;
    background: #eef0f6;
}

.ct-item-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ct-item-body {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}

.ct-item-name {
    color: #1f2937;
    font-weight: 700;
    line-height: 1.7;
    text-decoration: none;
    overflow-wrap: anywhere;
}

a.ct-item-name:hover {
    color: #6d28d9;
}

.ct-item-variant {
    align-self: flex-start;
    padding: .1rem .6rem;
    border-radius: 8px;
    background: #f3f4f8;
    color: #4b5563;
    font-size: .78rem;
    font-weight: 600;
}

.ct-item-price {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem .6rem;
    font-size: .82rem;
    color: #6b7280;
}

.ct-old {
    color: #9ca3af;
    text-decoration: line-through;
}

.ct-off {
    padding: .05rem .5rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
}

.ct-item-warn {
    color: #b45309;
    font-size: .82rem;
    font-weight: 600;
}

.ct-item-controls {
    display: flex;
    align-items: center;
    gap: .9rem;
}

.ct-stepper {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 12px;
    background: #f3f4f8;
}

.ct-step {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: #fff;
    color: #5b21b6;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .1);
    transition: background .15s ease, transform .15s ease;
}

.ct-step:hover:not(:disabled) {
    background: #ede9fe;
}

.ct-step:active:not(:disabled) {
    transform: scale(.92);
}

.ct-step:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.ct-step:focus-visible,
.ct-remove:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
}

.ct-qty {
    min-width: 34px;
    text-align: center;
    font-weight: 800;
    color: #3a0647;
    font-variant-numeric: tabular-nums;
}

.ct-line-total {
    min-width: 110px;
    text-align: end;
    color: #047857;
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
}

.ct-remove {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.ct-remove svg {
    width: 19px;
    height: 19px;
}

.ct-remove:hover:not(:disabled) {
    background: #fee2e2;
    color: #dc2626;
}

.ct-remove:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ----- خلاصه‌ی سفارش ----- */
.ct-summary {
    position: sticky;
    top: 4.75rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    padding: 1.15rem;
    background: #fff;
    border: 1px solid #ece9f6;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(58, 6, 71, .08);
}

.ct-summary-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #3a0647;
}

.ct-summary-rows {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin: 0;
}

.ct-summary-rows > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: .92rem;
    color: #4b5563;
}

.ct-summary-rows dt,
.ct-summary-rows dd {
    margin: 0;
}

.ct-summary-rows .is-save {
    color: #047857;
    font-weight: 600;
}

.ct-summary-rows .ct-summary-total {
    margin-top: .1rem;
    padding-top: .8rem;
    border-top: 1px dashed #ddd6fe;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1f2937;
}

.ct-summary-total dd {
    color: #047857;
}

.ct-note {
    margin: 0;
    padding: .6rem .8rem;
    border-radius: 10px;
    background: #f3f4f8;
    color: #4b5563;
    font-size: .84rem;
    line-height: 1.8;
}

.ct-note.is-warn {
    background: #fffbeb;
    color: #92400e;
}

.ct-note.is-error {
    background: #fef2f2;
    color: #b91c1c;
}

.ct-checkout {
    min-height: 46px;
    font-size: 1rem;
    background: linear-gradient(135deg, #6d28d9, #4c1d95);
    box-shadow: 0 8px 20px rgba(76, 29, 149, .3);
}

.ct-checkout:hover:not(:disabled) {
    background: linear-gradient(135deg, #5b21b6, #3b0f7a);
}

.ct-confirm {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .5rem;
}

.ct-continue {
    padding: .4rem;
    text-align: center;
    color: #6d28d9;
    font-weight: 600;
    text-decoration: none;
}

.ct-continue:hover {
    color: #5b21b6;
    text-decoration: underline;
}

/* ----- حالت خالی / موفقیت ----- */
.ct-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    margin-top: .9rem;
    padding: 2.5rem 1.25rem;
    text-align: center;
    background: #fff;
    border: 1px dashed #d1d5db;
    border-radius: 20px;
}

.ct-state-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #ede9fe;
    color: #6d28d9;
}

.ct-state-icon svg {
    width: 36px;
    height: 36px;
}

.ct-state h2 {
    margin: .2rem 0 0;
    font-size: 1.15rem;
    color: #3a0647;
}

.ct-state p {
    margin: 0;
    max-width: 420px;
    font-size: .92rem;
    color: #6b7280;
}

.ct-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .6rem;
    margin-top: .6rem;
}

.ct-state-actions .up-btn {
    text-decoration: none;
}

.ct-state--success {
    border-style: solid;
    border-color: #a7f3d0;
    background: #f0fdf4;
}

.ct-state--success .ct-state-icon {
    background: #d1fae5;
    color: #047857;
}

/* ----- اسکلت بارگذاری ----- */
.ct-skeleton {
    height: 116px;
    border-radius: 16px;
    background: linear-gradient(90deg, #eceaf5 25%, #f6f5fb 37%, #eceaf5 63%);
    background-size: 400% 100%;
    animation: ct-shimmer 1.4s ease infinite;
}

.ct-skeleton--summary {
    height: 260px;
}

/* ---------------------------------------------------------------------
   7) واکنش‌گرایی و کاهش حرکت
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
    .ct-layout {
        grid-template-columns: 1fr;
    }

    .ct-summary {
        position: static;
    }
}

@media (max-width: 640px) {
    .ct-toast-region {
        bottom: 88px; /* بالاتر از دکمه‌ی چت آنلاین */
    }

    .ct-toast {
        font-size: 13px;
    }

    .ct-item {
        grid-template-columns: 72px minmax(0, 1fr);
        padding: .7rem;
    }

    .ct-item-media {
        width: 72px;
    }

    .ct-item-controls {
        grid-column: 1 / -1;
        justify-content: space-between;
        padding-top: .7rem;
        border-top: 1px dashed #ece9f6;
    }

    .ct-line-total {
        flex: 1;
        min-width: 0;
        text-align: center;
    }

    .ct-state {
        padding: 2rem 1rem;
    }

    .app-shell .ct-option {
        min-height: 44px; /* هدف لمسی راحت‌تر در موبایل */
    }
}

@keyframes ct-pop {
    0% { transform: scale(.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes ct-toast-in {
    0% { transform: translateY(18px) scale(.97); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes ct-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes ct-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .ct-badge,
    .ct-toast,
    .ct-skeleton,
    .ct-add.is-busy .ct-add-icon {
        animation: none;
    }

    .ct-add,
    .ct-add.ct-add--compact,
    .ct-navlink,
    .ct-item,
    .ct-step,
    .app-shell .shop-card-wrap {
        transition: none;
    }

    .app-shell .shop-card-wrap:hover,
    .ct-add:hover:not(:disabled),
    .ct-add.ct-add--compact:hover:not(:disabled) {
        transform: none;
    }
}

/* ===== موجودی انبار ===== */
.ct-stock {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin: .25rem 0 .75rem;
    padding: .4rem .8rem;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    background: rgba(34, 197, 94, .12);
    color: #15803d;
}

.ct-stock-dot {
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    background: currentColor;
}

.ct-stock.is-low {
    background: rgba(245, 158, 11, .14);
    color: #b45309;
}

.ct-stock.is-out {
    background: rgba(239, 68, 68, .12);
    color: #b91c1c;
}

.ct-stock-cart {
    font-weight: 500;
    opacity: .85;
}

.ct-item-stock {
    display: block;
    margin-top: .25rem;
    font-size: .85rem;
    color: #15803d;
}

.ct-item-stock.is-low {
    color: #b45309;
}
