/* AJAX Cart Side Drawer Styles - Refined Premium Design */
:root {
    --drawer-bg: #1a4d4d;
    --drawer-card-bg: #ffffff;
    --drawer-text-dark: #333333;
    --drawer-text-light: #ffffff;
    --drawer-accent: #d7faeb;
    --drawer-accent-dark: #2c7a7a;
}

.opacity-80 {
    opacity: 0.8;
}

.opacity-60 {
    opacity: 0.6;
}

.opacity-30 {
    opacity: 0.3;
}

.underline {
    text-decoration: underline;
}

/* Prevent Background Scroll and Layout Shift */
html.modal-open {
    scrollbar-gutter: stable;
}

html.modal-open,
body.modal-open {
    overflow: hidden;
}

.myleaf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100001;
    /* Above WordPress Admin Bar (99999) */
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0.4s;
}

.myleaf-modal.active {
    visibility: visible;
    pointer-events: auto;
}

/* Admin Bar Awareness */
.myleaf-modal {
    top: var(--wp-admin--admin-bar--height, 0px);
}

@media screen and (max-width: 600px) {
    .myleaf-modal {
        top: 0;
    }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.myleaf-modal.active .modal-overlay {
    opacity: 1;
}

.modal-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
    box-shadow: -15px 0 60px rgba(0, 0, 0, 0.3);
}

@media screen and (max-width: 600px) {
    .modal-container {
        height: 100vh;
        height: 100dvh;
        /* Use dynamic viewport height if supported */
    }
}

.modal-container {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--primary);
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.myleaf-modal.active .modal-container {
    transform: translateX(0);
}

/* Header Section */
.modal-header {
    padding: 20px;
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: 'Anton', sans-serif;
    font-weight: 400;
    font-size: var(--xlarge);
    line-height: 1;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0;
    /* Reset letter-spacing for Anton */
    margin: 0;
}

.modal-close-trigger {
    cursor: pointer;
    transition: opacity 0.2s;
    color: #fff;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close-trigger svg {
    width: 30px;
    height: 30px;
}

.modal-close-trigger:hover {
    opacity: 0.7;
}

/* Banner Segment */
.drawer-banner {
    width: 100%;
    height: auto;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0 20px;
    box-sizing: border-box;
}

.drawer-banner img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
}

/* Repeats & Progress Section */
.drawer-repeats-section {
    padding: 20px 0;
    flex-shrink: 0;
}

.repeats-header {
    margin-bottom: 10px;
}

.repeats-progress-track {
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 10px;
    overflow: hidden;
}

.repeats-progress-fill {
    background: var(--secondary);
    height: 100%;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 10px;
}

.drawer-stats-row {
    padding-bottom: 10px;
}

/* Content Area */
.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    min-height: 200px;
    /* Prevent collapse during loading */
    display: flex;
    flex-direction: column;
}

#cart-modal-response {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cart-modal-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cart-modal-inner.is-empty {
    justify-content: center;
}

.empty-cart-message {
    padding: 60px 0px;
    margin: auto 0;
}

.empty-cart-message svg {
    stroke: #fff;
}

.empty-cart-message p {
    color: #fff;
}

.empty-cart-message p {
    color: #fff;
}

.loader-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* White Cards for Items */
.cart-drawer-card {
    background: var(--drawer-card-bg);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.cart-item-card {
    position: relative;
    display: flex;
    gap: 15px;
    overflow: hidden;
    /* For remove icon containment */
}

.item-thumb-wrapper {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.item-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.item-details {
    flex: 1;
}

.item-title {
    color: var(--primary);
    font-weight: 300;
    font-size: 15px;
    margin-bottom: 2px;
    line-height: 1;
    text-transform: capitalize;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.item-meta {
    color: #888;
    font-size: 13px;
    margin-bottom: 15px;
    margin-top: 0;
}

.item-meta {
    color: #888;
    font-size: 13px;
    margin-bottom: 15px;
}

.item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Quantity Selector */
.qty-selector {
    display: flex;
    align-items: center;
    background: #f4f4f4;
    border-radius: 20px;
    padding: 5px 15px;
    gap: 12px;
    min-width: 90px;
    justify-content: center;
}

.qty-btn {
    cursor: pointer;
    font-size: 18px;
    color: #666;
    user-select: none;
    transition: color 0.2s;
    width: 20px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    color: var(--drawer-text-dark);
}

.qty-val {
    font-weight: 600;
    font-size: 14px;
    color: var(--drawer-text-dark);
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.item-price-info {
    text-align: right;
}

.current-price {
    font-weight: 800;
    font-size: 18px;
    color: var(--primary);
}

.old-price {
    font-size: 14px;
    color: var(--primary);
    text-decoration: line-through;
    margin-left: 5px;
    font-weight: 400;
    opacity: 0.8;
}

.remove-item-trigger {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    color: #ccc;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.remove-item-trigger:hover {
    color: #fff;
    background: #ff6b6b;
}

/* Legacy Dried Herb classes removed - unified above */

/* Footer Section */
.modal-footer {
    padding: 0;
    flex-shrink: 0;
}

.drawer-subtotal-row {
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-footer-buttons {
    display: flex;
    width: 100%;
    padding: 10px 20px;
    gap: 15px;
}

.drawer-footer-buttons a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 54px;
    padding: 0 20px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 1px;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex: 1;
}

.drawer-footer-buttons .continue-shopping {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.drawer-footer-buttons .checkout {
    background: var(--secondary);
    color: var(--primary);
    border: 1px solid var(--secondary);
}

.drawer-footer-buttons .checkout:hover {
    background: var(--hexiary);
    color: #fff;
    border-color: var(--hexiary);
}

.cart-compliance-row a:hover {
    opacity: 1;
    text-decoration: none;
}

.drawer-footer-buttons .continue-shopping:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}




/* Added to Cart Feedback on Pharmacy Grid */
.added-to-cart-message {
    cursor: default;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.button-wrapper .added-to-cart-message {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.productaction.added-active {
    background: rgba(215, 250, 235, 0.1) !important;
}

.cart-item-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cart-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.progress-track {
    background: rgba(255, 255, 255, 0.1);
}

.border-b-dark {
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Custom Scrollbar for Drawer */









/* --- Drawer Layout Refinements --- */
.cart-main-products-wrapper {
    min-height: 290px;
    /* Reserves space for ~2 items + progress bar */
    display: flex;
    flex-direction: column;
}

.modal-content {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Hide scrollbar for Chrome/Safari to keep it clean if user finds it messy */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.flex-1 {
    flex: 1;
}

/* --- Quick Add Design --- */
.drawer-quick-add {
    margin-top: 20px;
    overflow: visible;
    position: relative;
    padding-bottom: 5px;
}

.quick-add-header {
    width: 100%;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quick-add-header p {
    margin: 0;
    letter-spacing: 1px;
    color: #fff;
    white-space: nowrap;
}

.quick-add-header .quick-add-pagination {
    position: relative;
    bottom: auto;
    left: auto;
    width: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    justify-content: flex-end;
}

.quick-add-header .quick-add-pagination .swiper-pagination-bullet {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    opacity: 1;
    width: 7px;
    height: 7px;
    margin: 0;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.quick-add-header .quick-add-pagination .swiper-pagination-bullet-active {
    background: var(--secondary);
    width: 24px;
    border-radius: 12px;
    border-color: var(--secondary);
}

/* Swiper Container for Upsells */
.upsell-scroll-container {
    overflow: hidden;
    position: relative;
    padding-bottom: 20px;
    cursor: grab;
    width: 100%;
    min-height: 100px;
}

.upsell-scroll-container:active {
    cursor: grabbing;
}

.upsell-scroll-container::-webkit-scrollbar {
    display: none;
}

.upsell-scroll-inner {
    display: flex;
    transition-property: transform;
    box-sizing: content-box;
    gap: 0;
    /* Managed by Swiper spaceBetween */
}

.upsell-slide {
    flex-shrink: 0;
    width: 78%; /* Match JS slidesPerView: 1.27 */
    height: 100%;
    position: relative;
    transition-property: transform;
    display: flex;
}


.upsell-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 15px;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Custom Dots for Scroll Snap */
.upsell-dots-wrapper {
    display: flex;
    gap: 6px;
}

.upsell-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffffff;
    opacity: 0.3;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.upsell-dot.active {
    opacity: 1;
    transform: scale(1.2);
}

.upsell-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.upsell-card .item-thumb-wrapper {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
}

.upsell-card .item-details {
    padding: 0;
    flex: 1;
    min-width: 0;
}

.upsell-card .item-title {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.upsell-card .current-price {
    font-size: 16px;
    color: var(--primary);
    font-weight: 800;
    opacity: 1;
}

.quick-add-plus-btn {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    text-decoration: none;
    padding: 0;
    overflow: hidden;
}

.quick-add-plus-btn svg {
    display: block;
    color: #fff;
    margin: 0;
}

.quick-add-plus-btn.is-variable a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
    padding: 0;
    margin: 0;
}

.quick-add-plus-btn.is-variable a .variable-chevron {
    width: 14px;
    height: 14px;
    display: block;
}

.item-price-info .old-price,
.item-price-info .old-price .woocommerce-Price-amount,
.upsell-card del,
.upsell-card del .woocommerce-Price-amount {
    font-size: 14px;
    font-weight: 400;
    text-decoration: line-through;
    color: var(--primary);
    opacity: 0.8;
    margin-right: 5px;
}

.upsell-card ins,
.upsell-card ins .woocommerce-Price-amount {
    text-decoration: none;
    font-weight: 800;
}

.quick-add-plus-btn:hover {
    background: var(--primary-dark, #1a4d4d);
    transform: scale(1.1);
}

.quick-add-plus-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.upsell-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.is-consultation-item .item-actions {
    justify-content: flex-end;
}

.drawer-footer-buttons .checkout.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* Compliance Checkbox */
.cart-compliance-row {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 20px 0px;
}

.compliance-checkbox input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0;
}

.compliance-checkbox input[type="checkbox"]:checked {
    background: #00d084;
    border-color: #00d084;
}

.compliance-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: -1px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.compliance-checkbox span {
    line-height: 1.4;
    user-select: none;
}

/* --- Mobile Specific Overrides (End of File for Priority) --- */
@media screen and (max-width: 600px) {
    .modal-content {
        padding: 0 10px;
    }

    .qty-selector {
        padding: 5px 10px;
        gap: 8px;
        min-width: 80px;
    }

    .qty-val {
        font-size: 12px;
        line-height: 1;
    }

    .drawer-subtotal-row {
        margin: 10px 10px 20px;
    }

    .drawer-footer-buttons {
        flex-direction: column;
    }

    .drawer-footer-buttons a {
        width: 100%;
        flex: none;
        padding: 0;
    }

    .modal-container {
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        position: fixed;
        top: 0;
        bottom: 0;
    }

    /* Mobile Quick Add Redesign (Vertical Stack) */
    .upsell-slide {
        width: 174px;
        flex-shrink: 0;
    }

    .upsell-card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
        height: 100%;
        background: #ffffff;
        border-radius: 20px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        width: 100%;
    }

    .upsell-card .item-thumb-wrapper {
        width: 150px;
        height: 150px;
        margin: 0 auto;
        aspect-ratio: 1 / 1;
    }

    .upsell-card .item-details {
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .upsell-card .item-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        height: 2.8em;
        font-size: 13px;
        line-height: 1.4;
    }

    .upsell-card .item-actions {
        margin-top: auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .upsell-card .current-price {
        font-size: 15px;
    }
}