/* ================================
   SpencoGel Cart Drawer
================================ */

body.spg-cart-open {
    overflow: hidden;
}

.spg-cart-overlay {
    position: fixed;
    inset: 0;
    z-index: 999998;
    background: rgba(20, 16, 20, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.spg-cart-overlay.is-open {
    opacity: 1;
}

.spg-cart-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 999999;

    display: flex;
    flex-direction: column;

    width: min(420px, 100%);
    background: #fff;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.15);

    transform: translateX(-105%);
    transition: transform 0.3s ease;
}

.spg-cart-drawer.is-open {
    transform: translateX(0);
}

.spg-cart-overlay[hidden],
.spg-cart-drawer[hidden] {
    display: none;
}

/* هدر */
.spg-cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    border-bottom: 1px solid #eee7ee;
}

.spg-cart-drawer-title {
    margin: 0;
    color: #222;
    font-size: 17px;
    font-weight: 800;
}

.spg-cart-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #f5f2f5;
    color: #555;
    font-family: inherit;
    font-size: 22px;
    cursor: pointer;
}

/* پیام موفقیت */
.spg-cart-feedback {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 14px 16px 6px;
    padding: 11px 13px;
    border: 1px solid #d9eadf;
    border-radius: 12px;
    background: #f2fbf5;
    color: #277342;
    font-size: 13px;
    font-weight: 700;
}

.spg-cart-feedback-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #2e8b50;
    color: #fff;
    font-size: 13px;
}

/* لیست محصولات */
.spg-cart-drawer-body {
    flex: 1;
    min-height: 0;
    padding: 10px 16px 16px;
    overflow-y: auto;
}

.spg-cart-drawer-empty {
    padding: 45px 20px;
    color: #777;
    text-align: center;
    font-size: 14px;
}


/* هر محصول داخل Drawer */
.spg-cart-drawer-item {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid #f0ebf0;
}

.spg-cart-drawer-item:last-child {
    border-bottom: none;
}

.spg-cart-item-image {
    display: block;
    width: 76px;
    height: 76px;
    border-radius: 11px;
    overflow: hidden;
    background: #f6f4f6;
}

.spg-cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spg-cart-item-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #aaa;
    font-size: 11px;
}

.spg-cart-item-info {
    min-width: 0;
}

.spg-cart-item-name {
    display: block;
    margin-bottom: 7px;
    color: #222;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.7;
    text-decoration: none;
}

.spg-cart-item-size {
    display: inline-flex;
    margin-bottom: 7px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f7f1f7;
    color: #7F2A7D;
    font-size: 11px;
    font-weight: 700;
}

.spg-cart-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.spg-cart-item-quantity {
    color: #777;
    font-size: 12px;
}

.spg-cart-item-price {
    color: #333;
    font-size: 13px;
    font-weight: 800;
}

/* کنترل تعداد و حذف داخل Drawer */
.spg-cart-item-controls {
    display: flex;
    align-items: center;
    gap: 7px;
}

.spg-cart-quantity-control {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid #e8e1e8;
    border-radius: 8px;
    background: #fff;
}

.spg-cart-quantity-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    padding: 0;
    border: none;
    background: transparent;
    color: #7F2A7D;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.spg-cart-quantity-btn:hover {
    background: #f7f1f7;
}

.spg-cart-quantity-btn:disabled,
.spg-cart-remove-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.spg-cart-quantity-value {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 27px;
    border-right: 1px solid #eee8ee;
    border-left: 1px solid #eee8ee;
    color: #333;
    font-size: 12px;
    font-weight: 700;
}

.spg-cart-remove-btn {
    padding: 4px 6px;
    border: none;
    background: transparent;
    color: #a64c4c;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

.spg-cart-remove-btn:hover {
    color: #c62828;
}
/* فوتر */
.spg-cart-drawer-footer {
    padding: 16px;
    border-top: 1px solid #eee7ee;
    background: #fff;
}

.spg-cart-drawer-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 13px;
    color: #555;
    font-size: 14px;
}

.spg-cart-drawer-total strong {
    color: #222;
    font-size: 16px;
}

.spg-cart-primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    border-radius: 11px;
    background: #7F2A7D;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
}

.spg-cart-primary-btn:hover {
    background: #682066;
    color: #fff;
}

.spg-cart-continue-btn {
    width: 100%;
    margin-top: 9px;
    padding: 9px;
    border: none;
    background: transparent;
    color: #666;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

/* موبایل: Bottom Sheet */
@media (max-width: 768px) {
    .spg-cart-drawer {
        top: auto;
        right: 0;
        left: 0;
        bottom: 0;

        width: 100%;
        max-height: 86vh;
        border-radius: 22px 22px 0 0;

        transform: translateY(105%);
    }

    .spg-cart-drawer.is-open {
        transform: translateY(0);
    }

    .spg-cart-drawer-header {
        padding: 15px 16px;
    }

    .spg-cart-drawer::before {
        content: "";
        width: 46px;
        height: 4px;
        margin: 9px auto 0;
        border-radius: 999px;
        background: #ddd5dd;
    }
}

/* مخفی‌کردن قطعی پیام موفقیت */
.spg-cart-feedback[hidden] {
    display: none !important;
}