/* =========================================
   MEDILEAF PREMIUM CART DRAWER
========================================= */

:root {
    --ml-cart-green: #31a050;
    --ml-cart-lime: #7ed13f;
    --ml-cart-dark: #173d24;
    --ml-cart-text: #34433a;
    --ml-cart-muted: #718078;
    --ml-cart-bg: #f7faf5;
    --ml-cart-border: #e4ece3;
    --ml-cart-danger: #d92d20;
    --ml-cart-white: #ffffff;
}

.ml-product-toast {
    position: fixed;
    right: 24px;
    bottom: 104px;
    z-index: 10000;
    max-width: calc(100% - 32px);
    padding: 13px 20px;
    border: 1px solid rgba(49, 160, 80, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ml-cart-dark);
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity .25s ease, visibility .25s ease, transform .25s ease;
    box-shadow: 0 18px 40px rgba(23, 61, 36, .14);
    backdrop-filter: blur(12px);
}

.ml-product-toast::before {
    content: "\F26B";
    font-family: "bootstrap-icons";
    margin-right: 8px;
    color: var(--ml-cart-green);
}

.ml-product-toast.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ml-shop-cart-floating {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9997;
    width: 50px;
    height: 50px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ml-cart-green), var(--ml-cart-lime));
    color: #fff;
    font-size: 23px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .25s ease, box-shadow .25s ease;
    box-shadow: 0 14px 34px rgba(49, 160, 80, .3);
}

.ml-shop-cart-floating:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 20px 40px rgba(49, 160, 80, .36);
}

.ml-shop-cart-floating i {
    line-height: 1;
}

.ml-shop-cart-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(16, 32, 22, .48);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .3s ease, visibility .3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ml-shop-cart-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* =========================================
   CART DRAWER — ROBUST RESPONSIVE STATE
   ========================================= */

.ml-shop-cart-drawer {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    z-index: 9999 !important;

    width: 430px;
    max-width: min(94vw, 430px);
    height: 100vh;
    height: 100dvh;

    padding: 0;
    background: var(--ml-cart-white);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Hidden state: transform is more reliable during viewport resizing
       than moving the drawer with a negative right value. */
    transform: translate3d(105%, 0, 0);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;

    transition:
        transform .38s cubic-bezier(.22, 1, .36, 1),
        opacity .2s ease,
        visibility 0s linear .38s;

    box-shadow: -24px 0 60px rgba(14, 37, 22, .18);
    will-change: transform;
    backface-visibility: hidden;
}

.ml-shop-cart-drawer.active {
    right: 0 !important;
    transform: translate3d(0, 0, 0);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition:
        transform .38s cubic-bezier(.22, 1, .36, 1),
        opacity .2s ease,
        visibility 0s linear 0s;
}

/* Header */
.ml-shop-cart-head {
    min-height: 88px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--ml-cart-border);
    background: linear-gradient(135deg, rgba(49, 160, 80, .08), rgba(126, 209, 63, .05));
}

.ml-shop-cart-head h3 {
    margin: 0;
    color: var(--ml-cart-dark);
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.ml-shop-cart-head h3::before {
    content: "\F179";
    font-family: "bootstrap-icons";
    margin-right: 10px;
    color: var(--ml-cart-green);
    font-size: 22px;
}

.ml-shop-cart-close {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(49, 160, 80, .14);
    border-radius: 50%;
    background: var(--ml-cart-white);
    color: var(--ml-cart-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    transition: background .22s ease, color .22s ease, transform .22s ease;
}

.ml-shop-cart-close:hover {
    background: var(--ml-cart-green);
    color: #fff;
    transform: rotate(90deg);
}

.ml-shop-cart-items {
    flex: 1;
    min-height: 0;
    padding: 8px 22px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(49, 160, 80, .35) transparent;
}

.ml-shop-cart-items::-webkit-scrollbar {
    width: 6px;
}

.ml-shop-cart-items::-webkit-scrollbar-thumb {
    border-radius: 20px;
    background: rgba(49, 160, 80, .3);
}

.ml-shop-cart-empty {
    min-height: 360px;
    margin: 0;
    padding: 48px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ml-cart-muted);
    font-size: 15px;
    text-align: center;
}

.ml-shop-cart-empty::before {
    content: "\F244";
    font-family: "bootstrap-icons";
    display: block;
    margin-right: 10px;
    color: rgba(49, 160, 80, .5);
    font-size: 28px;
}

.ml-shop-cart-item {
    position: relative;
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 14px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--ml-cart-border);
    border-radius: 20px;
    background: #fff;
    transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.ml-shop-cart-item:hover {
    transform: translateY(-2px);
    border-color: rgba(49, 160, 80, .28);
    box-shadow: 0 14px 30px rgba(31, 45, 34, .07);
}

.ml-shop-cart-item>img {
    width: 86px;
    height: 96px;
    padding: 8px;
    border-radius: 16px;
    background: linear-gradient(145deg, #f4faf1, #fff);
    object-fit: contain;
}

.ml-shop-cart-info {
    min-width: 0;
}

.ml-shop-cart-info h4 {
    margin: 1px 0 5px;
    color: var(--ml-cart-dark);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
}

.ml-cart-item-colour {
    display: block;
    margin-bottom: 7px;
    color: var(--ml-cart-muted);
    font-size: 13px;
    line-height: 1.4;
}

.ml-cart-item-colour strong {
    color: var(--ml-cart-text);
    font-weight: 700;
}

.ml-shop-cart-info p {
    margin: 0 0 11px;
    color: var(--ml-cart-green);
    font-size: 16px;
    font-weight: 800;
}

.ml-shop-cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 4px;
    border: 1px solid var(--ml-cart-border);
    border-radius: 999px;
    background: var(--ml-cart-bg);
}

.ml-shop-cart-qty button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ml-cart-green), var(--ml-cart-lime));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: Arial, sans-serif;
    font-size: 17px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.ml-shop-cart-qty button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 14px rgba(49, 160, 80, .25);
}

.ml-shop-cart-qty span {
    min-width: 20px;
    color: var(--ml-cart-dark);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}

.ml-shop-cart-remove {
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ml-cart-danger);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .2s ease, transform .2s ease;
}

.ml-shop-cart-remove::before {
    content: "\F5DE";
    font-family: "bootstrap-icons";
    font-size: 13px;
}

.ml-shop-cart-remove:hover {
    opacity: .78;
    transform: translateX(2px);
}

.ml-shop-cart-bottom {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--ml-cart-border);
    background: linear-gradient(180deg, #fff, #f8fbf7);
    box-shadow: 0 -12px 28px rgba(23, 61, 36, .05);
}

.ml-shop-cart-total {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ml-cart-dark);
    font-size: 15px;
    font-weight: 700;
}

.ml-shop-cart-total strong {
    color: var(--ml-cart-green);
    font-size: 22px;
    font-weight: 800;
}

.ml-shop-checkout-btn {
    width: 100%;
    height: 54px;
    border: 0;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--ml-cart-green), var(--ml-cart-lime));
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .24s ease, box-shadow .24s ease;
}

.ml-shop-checkout-btn::before {
    content: "\F47A";
    font-family: "bootstrap-icons";
    margin-right: 8px;
}

.ml-shop-checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(49, 160, 80, .26);
}

.ml-shop-clear-cart {
    width: 100%;
    height: 48px;
    margin-top: 10px;
    border: 1px solid var(--ml-cart-border);
    border-radius: 50px;
    background: #fff;
    color: var(--ml-cart-text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .22s ease, color .22s ease, background .22s ease;
}

.ml-shop-clear-cart:hover {
    border-color: rgba(217, 45, 32, .3);
    background: #fff7f6;
    color: var(--ml-cart-danger);
}

/* Responsive */
@media (max-width: 991.98px) {
    .ml-shop-cart-drawer {
        width: 420px;
        max-width: min(94vw, 420px);
    }
}

@media (max-width: 575.98px) {
    .ml-product-toast {
        right: 16px;
        bottom: 84px;
    }

    .ml-shop-cart-floating {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
        font-size: 21px;
    }

    .ml-shop-cart-drawer {
        width: 100% !important;
        max-width: 100% !important;
        transform: translate3d(105%, 0, 0);
    }

    .ml-shop-cart-drawer.active {
        transform: translate3d(0, 0, 0);
    }

    .ml-shop-cart-head {
        min-height: 78px;
        padding: 18px;
    }

    .ml-shop-cart-head h3 {
        font-size: 22px;
    }

    .ml-shop-cart-items {
        padding: 5px 14px 16px;
    }

    .ml-shop-cart-item {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 12px;
        padding: 12px;
        border-radius: 17px;
    }

    .ml-shop-cart-item>img {
        width: 76px;
        height: 88px;
    }

    .ml-shop-cart-bottom {
        padding: 16px 18px 20px;
    }
}

@media (max-width:380px) {
    .ml-shop-cart-item {
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .ml-shop-cart-item>img {
        width: 68px;
        height: 80px;
    }

    .ml-shop-cart-info h4 {
        font-size: 15px;
    }
}

/* =========================================
   FINAL SAFETY: drawer must never affect page layout
   or remain visible while inactive.
========================================= */
.ml-shop-cart-drawer:not(.active) {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate3d(105%, 0, 0) !important;
}

.ml-shop-cart-drawer.active {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translate3d(0, 0, 0) !important;
}

@media (min-width: 992px) {
    .ml-shop-cart-floating.d-lg-none {
        display: none !important;
    }
}