/* ═══════════════════════════════════════════════════════════════
   CART ICON (Header Button)
   ═══════════════════════════════════════════════════════════════ */
.cart-icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-section, #f2efe9);
    border: 1.5px solid var(--border, #e2dfd6);
    color: var(--text-secondary, #3d3d39);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .22s, color .22s, border-color .22s, transform .22s;
    flex-shrink: 0;
}
.cart-icon-btn:hover {
    background: var(--primary-light, #e1f5ee);
    color: var(--primary, #1d9e75);
    border-color: var(--primary, #1d9e75);
    transform: translateY(-1px);
}

/* Badge */
.cart-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #e24b4a;
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    animation: badgePop .25s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
}
@keyframes badgePop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════════
   CART DRAWER OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.cart-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}
.cart-drawer-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ═══════════════════════════════════════════════════════════════
   CART DRAWER PANEL
   ═══════════════════════════════════════════════════════════════ */
.cart-drawer {
    position: fixed;
    top: 0;
    left: 0;                         /* RTL: drawer from left */
    width: 390px;
    max-width: 100vw;
    height: 100dvh;
    background: #fff;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    transform: translateX(-110%);
    transition: transform .32s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,.13);
}
.cart-drawer.open {
    transform: translateX(0);
}

/* ── Header ── */
.cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #e2dfd6;
    flex-shrink: 0;
    background: #fff;
}
.cart-drawer-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1a1a18;
    margin: 0;
}
.cart-drawer-header h2 i {
    color: var(--primary, #1d9e75);
    font-size: 1.1rem;
}
.cart-drawer-count {
    background: var(--primary, #1d9e75);
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
}
.cart-drawer-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f2efe9;
    border: 1.5px solid #e2dfd6;
    color: #7a7a74;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}
.cart-drawer-close:hover {
    background: #fcebeb;
    color: #e24b4a;
    border-color: #e24b4a;
}

/* ── Body ── */
.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scroll-behavior: smooth;
}
.cart-drawer-body::-webkit-scrollbar { width: 4px; }
.cart-drawer-body::-webkit-scrollbar-thumb { background: #d3d1c7; border-radius: 4px; }

/* Empty State */
.cart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px 24px;
    text-align: center;
    gap: 10px;
}
.cart-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #f2efe9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #b4b2a9;
    margin-bottom: 8px;
}
.cart-empty-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1a1a18;
}
.cart-empty-sub {
    font-size: .88rem;
    color: #7a7a74;
    margin-bottom: 8px;
}

/* Items List */
.cart-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Single Item */
.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid #f2efe9;
    transition: background .18s;
    animation: itemSlideIn .25s ease;
}
.cart-item:hover { background: #fafaf8; }

@keyframes itemSlideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Item Image */
.cart-item-img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f2efe9;
    border: 1px solid #e2dfd6;
}
.cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Item Info */
.cart-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.cart-item-name {
    font-size: .9rem;
    font-weight: 700;
    color: #1a1a18;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-category {
    font-size: .75rem;
    color: var(--primary, #1d9e75);
    font-weight: 600;
}
.cart-item-price-unit {
    font-size: .78rem;
    color: #7a7a74;
}

/* Qty + Price Row */
.cart-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}
.cart-item-total {
    font-size: .97rem;
    font-weight: 800;
    color: #0f6e56;
}

/* Quantity Control */
.qty-ctrl {
    display: flex;
    align-items: center;
    border: 1.5px solid #e2dfd6;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.qty-ctrl-btn {
    width: 28px;
    height: 28px;
    background: #f2efe9;
    border: none;
    color: #3d3d39;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, color .18s;
    flex-shrink: 0;
}
.qty-ctrl-btn:hover { background: var(--primary, #1d9e75); color: #fff; }
.qty-ctrl-val {
    width: 30px;
    text-align: center;
    font-size: .88rem;
    font-weight: 700;
    color: #1a1a18;
    border-left: 1px solid #e2dfd6;
    border-right: 1px solid #e2dfd6;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* Remove Button */
.cart-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fcebeb;
    border: none;
    color: #e24b4a;
    font-size: .75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
}
.cart-item-remove:hover { background: #e24b4a; color: #fff; }

/* ── Footer ── */
.cart-drawer-footer {
    border-top: 1px solid #e2dfd6;
    padding: 18px 20px;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cart-subtotal-row,
.cart-shipping-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .88rem;
    color: #7a7a74;
}
.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.08rem;
    font-weight: 800;
    color: #1a1a18;
    padding: 10px 0;
    border-top: 1px solid #e2dfd6;
    border-bottom: 1px solid #e2dfd6;
    margin: 2px 0;
}
.cart-checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    background: var(--primary, #1d9e75);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .2s;
    margin-top: 4px;
}
.cart-checkout-btn:hover {
    background: #0f6e56;
    transform: translateY(-1px);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .cart-drawer { width: 100vw; }
}


/* ═══════════════════════════════════════════════════════════════
   CART HEADER WRAPPER — إخفاء/إظهار زر السلة في الهيدر
   ═══════════════════════════════════════════════════════════════ */
.cart-header-wrapper {
    display: none; /* مخفي افتراضياً قبل تحميل JS */
    align-items: center;
    gap: 10px;
}

    .cart-header-wrapper.visible {
        display: flex; /* يظهر فقط عند وجود عناصر في السلة */
    }

/* ═══════════════════════════════════════════════════════════════
   UNIFIED CART DRAWER — matches Shop/Index drawer markup
   ═══════════════════════════════════════════════════════════════ */
.cart-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}

.cart-overlay.active,
.cart-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.cart-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(410px, 100vw);
    height: 100dvh;
    background: #fff;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    transform: translateX(-110%);
    transition: transform .32s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,.13);
    overflow: hidden;
}

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

.cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, #e2dfd6);
    flex-shrink: 0;
    background: #fff;
}

.cart-drawer-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--text-primary, #1a1a18);
    font-size: 1.05rem;
    font-weight: 900;
}

.cart-drawer-header h3 i {
    color: var(--primary, #2D6A4F);
}

.cart-items-count {
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--primary, #2D6A4F);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 900;
}

.close-cart-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-section, #f2efe9);
    border: 1.5px solid var(--border, #e2dfd6);
    color: var(--text-muted, #7a7a74);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}

.close-cart-btn:hover {
    background: var(--danger-light, #fcebeb);
    border-color: var(--danger, #e24b4a);
    color: var(--danger, #e24b4a);
}

.free-shipping-bar {
    padding: 14px 20px 16px;
    border-bottom: 1px solid var(--border, #e2dfd6);
    background: linear-gradient(135deg, #f7fbf8 0%, #eef8f2 100%);
}

.shipping-progress-text {
    margin: 0 0 10px;
    color: var(--text-secondary, #3d3d39);
    font-size: .86rem;
    line-height: 1.7;
    font-weight: 700;
}

.shipping-progress-text strong {
    color: var(--primary, #2D6A4F);
    margin: 0 4px;
}

.shipping-progress-bar {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border, #e2dfd6);
}

.shipping-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary, #2D6A4F), var(--primary-light, #52B788));
    transition: width .28s ease;
}

.cart-items-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scroll-behavior: smooth;
}

.cart-items-wrapper::-webkit-scrollbar {
    width: 4px;
}

.cart-items-wrapper::-webkit-scrollbar-thumb {
    background: #d3d1c7;
    border-radius: 4px;
}

.cart-empty {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 24px;
    text-align: center;
}

.cart-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-section, #f2efe9);
    color: #b4b2a9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

.cart-empty h4 {
    margin: 0;
    color: var(--text-primary, #1a1a18);
    font-size: 1.1rem;
    font-weight: 900;
}

.cart-empty p {
    margin: 0 0 8px;
    color: var(--text-muted, #7a7a74);
    font-size: .9rem;
}

.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-section, #f2efe9);
    transition: background .18s;
    animation: itemSlideIn .25s ease;
}

.cart-item:hover {
    background: #fafaf8;
}

.cart-item-img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-section, #f2efe9);
    border: 1px solid var(--border, #e2dfd6);
}

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

.cart-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cart-item-name {
    margin: 0;
    color: var(--text-primary, #1a1a18);
    font-size: .9rem;
    font-weight: 800;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-category {
    margin: 0;
    color: var(--primary, #2D6A4F);
    font-size: .75rem;
    font-weight: 700;
}

.cart-item-price-unit {
    margin: 0;
    color: var(--text-muted, #7a7a74);
    font-size: .78rem;
}

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

.qty-control {
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1.5px solid var(--border, #e2dfd6);
    border-radius: 8px;
    background: #fff;
}

.qty-control-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-section, #f2efe9);
    border: 0;
    color: var(--text-secondary, #3d3d39);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background .18s, color .18s;
}

.qty-control-btn:hover {
    background: var(--primary, #2D6A4F);
    color: #fff;
}

.qty-control-val {
    width: 30px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid var(--border, #e2dfd6);
    border-right: 1px solid var(--border, #e2dfd6);
    color: var(--text-primary, #1a1a18);
    font-size: .88rem;
    font-weight: 800;
    user-select: none;
}

.cart-item-price {
    color: var(--primary-dark, #0f6e56);
    font-size: .92rem;
    font-weight: 900;
    white-space: nowrap;
}

.remove-item-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 0;
    background: var(--danger-light, #fcebeb);
    color: var(--danger, #e24b4a);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .18s, color .18s;
}

.remove-item-btn:hover {
    background: var(--danger, #e24b4a);
    color: #fff;
}

.cart-drawer-footer {
    flex-shrink: 0;
    padding: 16px 20px;
    border-top: 1px solid var(--border, #e2dfd6);
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-summary-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-summary-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary, #3d3d39);
    font-size: .88rem;
}

.cart-summary-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid var(--border, #e2dfd6);
    border-bottom: 1px solid var(--border, #e2dfd6);
    color: var(--text-primary, #1a1a18);
    font-size: 1.08rem;
    font-weight: 900;
}

.cart-checkout-btn,
.cart-continue-btn {
    min-height: 46px;
    border-radius: 10px;
}

.cart-continue-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: var(--bg-section, #f2efe9);
    color: var(--text-secondary, #3d3d39);
    border: 1.5px solid var(--border, #e2dfd6);
    font-size: .88rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, color .2s, border-color .2s;
}

.cart-continue-btn:hover {
    border-color: var(--primary, #2D6A4F);
    background: #e8f6ef;
    color: var(--primary, #2D6A4F);
}

.payment-icons-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.payment-icon {
    padding: 4px 10px;
    background: var(--bg-section, #f2efe9);
    border: 1px solid var(--border, #e2dfd6);
    border-radius: 8px;
    color: var(--text-muted, #7a7a74);
    font-size: .72rem;
    font-weight: 800;
}

@media (max-width: 480px) {
    .cart-drawer {
        width: 100vw;
    }

    .cart-item {
        padding-inline: 14px;
        gap: 10px;
    }

    .cart-item-img {
        width: 64px;
        height: 64px;
    }
}
