/* ============================================================
   PREMIUM SIDE-DRAWER CART v3.0.0
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --ds-primary:      #033E13;
    --ds-secondary:    #0CA847;
    --ds-accent:       #0DCC58;
    --ds-red:          #E53E3E;
    --ds-red-light:    #FFF5F5;
    --ds-text:         #1A202C;
    --ds-muted:        #718096;
    --ds-border:       #E8EDF2;
    --ds-bg:           #F7F9FB;
    --ds-white:        #FFFFFF;
    --ds-shadow:       0 25px 60px rgba(3,62,19,0.14), 0 8px 24px rgba(0,0,0,0.06);
    --ds-radius:       10px;
    --ds-radius-sm:    6px;
    --ds-transition:   cubic-bezier(0.25, 0.8, 0.25, 1);
    --vh:              1vh; /* overridden by JS for iOS */
}

/* ── Wrapper ───────────────────────────────────────────────── */
#ds-smart-cart-wrapper {
    position: fixed;
    inset: 0;
    z-index: 999999;
    pointer-events: none;
}
#ds-smart-cart-wrapper.ds-active {
    pointer-events: auto;
}
body.ds-cart-open {
    overflow: hidden;
}

/* ── Overlay ───────────────────────────────────────────────── */
.ds-cart-overlay {
    position: absolute;
    inset: 0;
    background: rgba(3, 62, 19, 0.45);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.38s ease;
    cursor: pointer;
}
#ds-smart-cart-wrapper.ds-active .ds-cart-overlay {
    opacity: 1;
}

/* ── Side Panel ────────────────────────────────────────────── */
.ds-side-cart {
    position: absolute;
    top: 0;
    right: -500px;
    width: 100%;
    max-width: 460px;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100); /* iOS fix */
    background: var(--ds-white);
    box-shadow: var(--ds-shadow);
    display: flex;
    flex-direction: column;
    transition: right 0.42s var(--ds-transition);
    will-change: right;
    overflow: hidden;
}
#ds-smart-cart-wrapper.ds-active .ds-side-cart {
    right: 0;
}

/* Loading state */
#ds-smart-cart-wrapper.ds-loading .ds-side-cart {
    opacity: 0.65;
    pointer-events: none;
}

/* ── Header ────────────────────────────────────────────────── */
.ds-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--ds-border);
    background: var(--ds-white);
    flex-shrink: 0;
    gap: 12px;
}
.ds-header-left {
    display: flex;
    align-items: center;
    gap: 9px;
}
.ds-header-icon {
    color: var(--ds-primary);
    flex-shrink: 0;
}
.ds-cart-header h3 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--ds-primary);
    letter-spacing: -0.2px;
    white-space: nowrap;
}
.ds-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ds-secondary);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ds-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: 50%;
    color: var(--ds-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}
.ds-close-btn:hover {
    background: var(--ds-red-light);
    border-color: var(--ds-red);
    color: var(--ds-red);
    transform: rotate(90deg);
}

/* ── Scrollable Body ───────────────────────────────────────── */
.ds-cart-body {
    flex: 1 1 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    -webkit-overflow-scrolling: touch;
}
.ds-cart-body::-webkit-scrollbar { width: 4px; }
.ds-cart-body::-webkit-scrollbar-track { background: transparent; }
.ds-cart-body::-webkit-scrollbar-thumb { background: var(--ds-border); border-radius: 4px; }

/* ── Shipping Bar ──────────────────────────────────────────── */
.ds-shipping-bar {
    background: var(--ds-bg);
    border: 1px dashed var(--ds-border);
    border-radius: var(--ds-radius);
    padding: 12px 14px;
    transition: background 0.3s ease, border-color 0.3s ease;
}
.ds-shipping-bar.ds-threshold-met {
    background: #F0FFF6;
    border-color: #9AE6B4;
    border-style: solid;
}
.ds-shipping-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ds-muted);
    margin: 0 0 9px 0;
    justify-content: center;
}
.ds-shipping-text strong { color: var(--ds-primary); font-family: 'Poppins', sans-serif; }
.ds-shipping-text em { color: var(--ds-secondary); font-style: normal; font-weight: 600; }
.ds-shipping-success {
    color: var(--ds-secondary) !important;
    font-weight: 600;
    margin-bottom: 0 !important;
}
.ds-progress-bg {
    width: 100%;
    height: 6px;
    background: var(--ds-border);
    border-radius: 10px;
    overflow: hidden;
}
.ds-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ds-secondary), var(--ds-accent));
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ds-progress-fill.ds-complete {
    background: linear-gradient(90deg, #38A169, #48BB78);
}
.ds-threshold-met .ds-progress-bg { display: none; }

/* ── Cart Items ────────────────────────────────────────────── */
.ds-cart-items {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.ds-empty-cart {
    text-align: center;
    padding: 48px 20px;
    color: var(--ds-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.ds-empty-cart p {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ds-text);
}
.ds-empty-cart span {
    font-size: 13px;
    color: var(--ds-muted);
}

/* Item card */
.ds-cart-item {
    display: flex;
    gap: 13px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ds-border);
    transition: opacity 0.28s ease, transform 0.28s ease, max-height 0.28s ease;
    overflow: hidden;
    max-height: 200px;
}
.ds-cart-item:last-child { border-bottom: none; padding-bottom: 0; }

/* Optimistic remove animation */
.ds-item-removing {
    opacity: 0 !important;
    transform: translateX(30px) !important;
    max-height: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.ds-item-img {
    width: 76px;
    height: 76px;
    flex-shrink: 0;
    border-radius: var(--ds-radius-sm);
    overflow: hidden;
    border: 1px solid var(--ds-border);
    background: var(--ds-bg);
}
.ds-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.ds-item-img:hover img { transform: scale(1.05); }

.ds-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}
.ds-item-info h4 {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.35;
    font-weight: 500;
    color: var(--ds-text);
}
.ds-item-info h4 a {
    color: inherit;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ds-item-info h4 a:hover { color: var(--ds-secondary); }
.ds-item-price {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--ds-secondary);
}
.ds-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

/* ── Quantity Stepper ──────────────────────────────────────── */
.ds-qty-stepper {
    display: flex;
    align-items: center;
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: 20px;
    overflow: hidden;
    height: 30px;
}
.ds-qty-btn {
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--ds-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.ds-qty-btn:hover:not(:disabled) {
    background: var(--ds-secondary);
    color: #fff;
}
.ds-qty-btn:disabled {
    color: var(--ds-border);
    cursor: not-allowed;
}
.ds-qty-input {
    width: 34px;
    height: 28px;
    border: none;
    background: transparent;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--ds-primary);
    -moz-appearance: textfield;
    padding: 0;
}
.ds-qty-input::-webkit-inner-spin-button,
.ds-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.ds-qty-input:focus { outline: none; }

/* ── Remove Button ─────────────────────────────────────────── */
.ds-remove-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ds-muted);
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    padding: 0;
}
.ds-remove-item:hover {
    background: var(--ds-red-light);
    border-color: #FED7D7;
    color: var(--ds-red);
}

/* ── Cross-Sells ───────────────────────────────────────────── */
.ds-cart-cross-sells {
    flex-shrink: 0;
    border-top: 2px solid var(--ds-bg);
    padding: 14px 22px 0;
}
.ds-cs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.ds-cs-header h5 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ds-primary);
}
.ds-cs-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}
.ds-cs-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ds-border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.ds-cs-dot.ds-dot-active {
    background: var(--ds-secondary);
    transform: scale(1.3);
}

/* Scroller */
.ds-cs-scroller {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 14px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.ds-cs-scroller::-webkit-scrollbar { display: none; }

.ds-cs-card {
    display: flex;
    gap: 10px;
    min-width: calc(100% - 24px);
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    padding: 10px;
    scroll-snap-align: start;
    flex-shrink: 0;
    align-items: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ds-cs-card:hover {
    border-color: #C6E9D4;
    box-shadow: 0 2px 10px rgba(12,168,71,0.08);
}
.ds-cs-img-link {
    display: block;
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: var(--ds-radius-sm);
    overflow: hidden;
    border: 1px solid var(--ds-border);
    background: var(--ds-white);
}
.cs-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cs-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.cs-info h6 {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--ds-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-info h6 a { color: inherit; text-decoration: none; }
.cs-info h6 a:hover { color: var(--ds-secondary); }
.cs-price {
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--ds-secondary);
}
.cs-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: fit-content;
}
.cs-btn-add {
    background: transparent;
    border: 1.5px solid var(--ds-primary) !important;
    color: var(--ds-primary);
}
.cs-btn-add:hover {
    background: var(--ds-primary);
    color: #fff;
}
.cs-btn-incart {
    background: #F0FFF6;
    border: 1.5px solid #9AE6B4 !important;
    color: #38A169;
    cursor: default;
    opacity: 0.85;
}

/* Add button loading state */
.ds-btn-spinning { opacity: 0.7; }
.ds-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ds-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── Footer ────────────────────────────────────────────────── */
.ds-cart-footer {
    flex-shrink: 0;
    padding: 18px 22px 20px;
    border-top: 1px solid var(--ds-border);
    background: var(--ds-white);
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.04);
}
.ds-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ds-total-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ds-total-label span {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ds-muted);
}
.ds-total-label small {
    font-size: 11px;
    color: var(--ds-muted);
    font-weight: 400;
}
.ds-total-amount {
    font-family: 'Poppins', sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: var(--ds-primary);
    line-height: 1;
}

/* Checkout CTA */
.ds-btn-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 20px;
    background: var(--ds-secondary);
    color: #fff;
    text-decoration: none;
    border-radius: var(--ds-radius);
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(12,168,71,0.25), 0 2px 6px rgba(12,168,71,0.15);
    position: relative;
    overflow: hidden;
}
.ds-btn-checkout::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
    pointer-events: none;
}
.ds-btn-checkout:hover {
    background: var(--ds-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(3,62,19,0.25);
    color: #fff;
}
.ds-btn-checkout:active { transform: translateY(0); }

/* Secondary links row */
.ds-footer-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ds-link-cart {
    font-size: 13px;
    color: var(--ds-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}
.ds-link-cart:hover { color: var(--ds-primary); }
.ds-btn-continue {
    background: none;
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--ds-primary);
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ds-btn-continue:hover { opacity: 0.65; }

/* Trust Badges */
.ds-trust-badges {
    display: flex;
    justify-content: space-around;
    padding-top: 2px;
    border-top: 1px solid var(--ds-bg);
}
.ds-trust-badges span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ds-muted);
}
.ds-trust-badges svg { color: var(--ds-secondary); }

/* ── Skeleton Loader ───────────────────────────────────────── */
#ds-skeleton-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}
#ds-skeleton-overlay.ds-sk-visible {
    opacity: 1;
    pointer-events: auto;
}
.ds-skeleton-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 460px;
    height: 100%;
    background: var(--ds-white);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-shadow: var(--ds-shadow);
}
.ds-sk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--ds-border);
}
.ds-sk-bar {
    height: 54px;
    border-radius: var(--ds-radius);
    background: var(--ds-bg);
    overflow: hidden;
}
.ds-sk-item {
    display: flex;
    gap: 14px;
    align-items: center;
}
.ds-sk-img {
    width: 76px;
    height: 76px;
    border-radius: var(--ds-radius-sm);
    flex-shrink: 0;
    overflow: hidden;
}
.ds-sk-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ds-sk-line,
.ds-sk-img,
.ds-sk-bar,
.ds-sk-circle {
    background: linear-gradient(90deg, #F0F4F8 25%, #E2E8F0 50%, #F0F4F8 75%);
    background-size: 200% 100%;
    animation: ds-shimmer 1.5s infinite;
    border-radius: 4px;
    height: 14px;
}
.ds-sk-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ds-sk-line.w40 { width: 40%; }
.ds-sk-line.w50 { width: 50%; }
.ds-sk-line.w55 { width: 55%; }
.ds-sk-line.w65 { width: 65%; }
.ds-sk-line.w75 { width: 75%; }
@keyframes ds-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .ds-side-cart,
    .ds-skeleton-panel {
        max-width: 100%;
        width: 100%;
    }
    .ds-cart-header { padding: 15px 16px; }
    .ds-cart-body   { padding: 15px 16px; }
    .ds-cart-cross-sells { padding: 12px 16px 0; }
    .ds-cart-footer { padding: 14px 16px 18px; }
    .ds-total-amount { font-size: 22px; }
    .ds-cs-card { min-width: calc(88% - 16px); }
}
