/* Cart Logic CSS */
:root {
    --primary: #111111;
    --secondary: #757575;
    /* --bg: #ffffff; Already defined in theme? */
    --surface: #f9f9f9;
    --border: #e0e0e0;
    --accent: #27ae60;
    --error: #d32f2f;
    --font-main: var(--font-body);
}

body.woocommerce-cart {
    font-family: var(--font-main);
    color: var(--primary);
    /* background-color: var(--bg); */
    line-height: 1.5;
}

/* --- LAYOUT --- */
body.woocommerce-cart .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 40px;
    /* Reduced padding */
}

/* Hide Footer on Cart Page */
body.woocommerce-cart .site-footer,
body.woocommerce-cart .footer-chat-bar {
    display: none !important;
}

body.woocommerce-cart button {
    cursor: pointer;
    font-family: inherit;
}

/* --- HEADER --- */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.cart-header h1 {
    font-size: 1.5rem;
    /* Reduced from 2rem */
    letter-spacing: -0.5px;
    font-weight: 600;
}

.item-count {
    color: var(--secondary);
    font-size: 0.9rem;
}

/* --- GRID --- */
.cart-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 60px;
}

/* --- OFFERS SECTION (NEW) --- */
.offers-banner {
    background-color: #f0fdf4;
    /* Light green bg */
    border: 1px dashed var(--accent);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.offer-icon {
    color: var(--accent);
    font-size: 1.2rem;
}

.offer-code {
    font-weight: 700;
    background: rgba(39, 174, 96, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    cursor: pointer;
}

/* --- ITEMS --- */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.cart-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 20px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

.item-image img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #eee;
}

.item-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.item-name {
    font-weight: 400;
    font-size: 1rem;
    font-family: var(--font-price);
}

.item-name a {
    color: inherit;
    text-decoration: none;
}

.item-meta {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.item-meta dl.variation {
    margin: 0;
    display: grid;
    grid-template-columns: max-content auto;
    column-gap: 5px;
    row-gap: 2px;
}

.item-meta dl.variation dt {
    font-weight: 500;
    margin: 0;
}

.item-meta dl.variation dd {
    margin: 0;
}

.item-meta dl.variation dd p {
    margin: 0;
}

.item-price {
    font-weight: 500;
}

.item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

.qty-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.qty-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    transition: opacity 0.2s;
}

.qty-btn:hover {
    opacity: 0.6;
}

.qty-val {
    font-size: 0.9rem;
    width: 30px;
    text-align: center;
    border: none;
    outline: none;
    appearance: textfield;
    -moz-appearance: textfield;
}

.qty-val::-webkit-outer-spin-button,
.qty-val::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--secondary);
    text-decoration: underline;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.remove-btn:hover {
    color: var(--error);
}

/* --- SUMMARY --- */
.summary-wrapper {
    position: sticky;
    top: 120px;
    /* Adjusted for navbar */
}

.summary-card {
    background-color: var(--surface);
    padding: 30px;
    border-radius: 8px;
}

.summary-header {
    margin-bottom: 25px;
    font-weight: 500;
}

/* CANVAS SHIPPING */
.shipping-tracker {
    margin-bottom: 30px;
    text-align: center;
}

canvas#shippingCanvas {
    width: 100%;
    height: auto;
    display: block;
}

.shipping-msg {
    font-size: 0.8rem;
    margin-top: 10px;
    color: var(--secondary);
    font-weight: 500;
}

/* PROMO CODE (NEW) */
.promo-section {
    margin-bottom: 25px;
}

.promo-input-group {
    display: flex;
    gap: 8px;
}

.promo-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
}

.apply-btn {
    padding: 10px 15px;
    background-color: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.promo-feedback {
    font-size: 0.85rem;
    margin-top: 8px;
    min-height: 20px;
    /* prevent jump */
}

.feedback-success {
    color: var(--accent);
}

.feedback-error {
    color: var(--error);
}

/* COSTS */
.cost-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.discount-row {
    color: var(--accent);
    display: none;
}

/* Hidden by default */
.discount-row.active {
    display: flex;
}

.total {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    font-weight: 700;
    font-size: 1.1rem;
}

.checkout-btn {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 4px;
    margin-top: 25px;
    transition: transform 0.2s ease, box-shadow 0.2s;
    text-align: center;
    display: block;
    text-decoration: none;
}


.checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: var(--primary);
    color: white;
}

/* --- MOBILE ONLY ELEMENTS (Hidden on Desktop) --- */
.mobile-footer-bar,
.mobile-drawer-overlay,
.close-mobile-btn {
    display: none;
}

@media (max-width: 768px) {
    .cart-grid {
        grid-template-columns: 1fr;
    }

    body.woocommerce-cart .container {
        padding: 20px 15px 100px;
        /* Reduced top padding */
    }

    /* Mobile Drawer */
    .summary-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        max-height: 85vh;
        z-index: 9999;
        transform: translateY(110%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 0;
        top: auto;
        /* Reset sticky top */
    }

    .summary-wrapper.open {
        transform: translateY(0);
    }

    /* Summary Card in Drawer */
    .summary-card {
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        padding: 24px;
        padding-bottom: 90px !important;
        /* Space for footer */
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Header with Close Button */
    .summary-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: sticky;
        top: 0;
        background: var(--surface);
        /* Match card bg */
        z-index: 10;
        padding-bottom: 15px;
        margin-bottom: 10px;
        margin-top: 0;
    }

    .close-mobile-btn {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        padding: 5px;
    }

    /* Mobile Footer Bar */
    .mobile-footer-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        border-top: 1px solid var(--border);
        padding: 15px 20px;
        z-index: 10000 !important;
        /* Above drawer */
        height: auto;
        min-height: 80px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .footer-info {
        display: flex;
        flex-direction: column;
    }

    .footer-total {
        font-weight: 700;
        font-size: 1.1rem;
    }

    .toggle-details-btn {
        background: none;
        border: none;
        color: var(--secondary);
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        padding: 0;
        margin-top: 4px;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .checkout-btn-mobile {
        background-color: var(--primary);
        color: white;
        border: none;
        padding: 12px 24px;
        border-radius: 4px;
        font-weight: 600;
        font-size: 1rem;
        text-decoration: none;
    }

    /* Hide standard checkout button in summary since present in footer */
    .summary-card .checkout-btn {
        display: none;
    }

    /* Overlay */
    .mobile-drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

    .mobile-drawer-overlay.open {
        opacity: 1;
        visibility: visible;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- EMPTY CART --- */
.cart-empty-state {
    text-align: center;
    padding: 80px 20px;
    max-width: 1200px;
    /* Wider for product grid */
    margin: 0 auto;
    animation: fadeIn 0.6s ease;
}

.empty-cart-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    background-color: var(--surface);
    border-radius: 50%;
    margin-bottom: 30px;
    color: var(--primary);
    font-size: 3rem;
}

.empty-cart-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--primary);
    letter-spacing: -0.5px;
    text-align: center;
}

.empty-cart-text {
    color: var(--secondary);
    margin-bottom: 40px;
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.cart-empty-state .cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #fff !important;
    color: #000 !important;
    padding: 14px 40px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 1px solid #000 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cart-empty-state .cta-button:hover {
    background-color: transparent;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* ========================================= */
/* === FULL SCREEN OVERLAY ANIMATION === */
/* ========================================= */

#successOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#successOverlay.active {
    opacity: 1;
    pointer-events: auto;
}

.success-modal {
    background: #fff;
    width: 90%;
    max-width: 320px;
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    transform: scale(0.8) translateY(20px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

#successOverlay.active .success-modal {
    transform: scale(1) translateY(0);
}

/* Animated Checkmark */
.checkmark-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #ecfdf5;
    /* Light green bg */
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.checkmark {
    width: 40px;
    height: 40px;
    stroke-width: 4;
    stroke: var(--accent);
    fill: none;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#successOverlay.active .checkmark {
    animation: drawCheck 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards 0.3s;
}

@keyframes drawCheck {
    100% {
        stroke-dashoffset: 0;
    }
}

/* Text Animations */
.success-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 8px;
    opacity: 0;
    transform: translateY(10px);
}

.success-desc {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(10px);
}

#successOverlay.active .success-title {
    animation: fadeUp 0.5s ease forwards 0.4s;
}

#successOverlay.active .success-desc {
    animation: fadeUp 0.5s ease forwards 0.5s;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Savings Badge */
.savings-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0;
    transform: scale(0.5);
}

#successOverlay.active .savings-badge {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards 0.6s;
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Close Button */
.close-btn {
    background: #f3f4f6;
    color: #374151;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    opacity: 0;
}

#successOverlay.active .close-btn {
    animation: fadeUp 0.5s ease forwards 0.8s;
}

.close-btn:hover {
    background: #e5e7eb;
}

/* Canvas Confetti */
#confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

@media (max-width: 768px) {

    .woocommerce-cart .entry-content,
    .woocommerce-cart,
    .summary-card,
    .woocommerce-cart .pdp-actions,
    .product-pdp-actions-sticky {
        padding-bottom: 90px !important;
    }


}

/* Mobile Drawer Overlay */
#mobileDrawerOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    /* Below drawer (9999) */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#mobileDrawerOverlay.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}