/* Cart Drawer - Right to Left Slide (Shopify Style) */
.cart-drawer {
    position: fixed !important;
    top: 0 !important;
    right: -100%;
    width: 100% !important;
    max-width: 420px !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
    background: #ffffff !important;
    z-index: 99999 !important; /* Highest z-index to ensure it's always on top of everything */
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15) !important;
    display: flex !important;
    flex-direction: column !important;
    /* Edge to edge - no safe area insets */
}

.cart-drawer.active {
    right: 0;
}

.cart-drawer-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 99998 !important; /* Very high z-index, just below cart drawer (99999) to cover entire website */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    pointer-events: none;
    margin: 0 !important;
    padding: 0 !important;
}

.cart-drawer-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: block !important;
}

.cart-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
    /* Edge to edge - no padding */
}

/* Cart Drawer Header */
.cart-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    border-bottom: 2px solid #f0f0f0;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cart-drawer-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

.cart-drawer-close {
    background: #f8f8f8;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cart-drawer-close:hover {
    background: #e8e8e8;
    color: #333;
    transform: rotate(90deg);
}

.cart-drawer-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Cart Drawer Body */
.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fafafa;
}

.cart-drawer-body::-webkit-scrollbar {
    width: 6px;
}

.cart-drawer-body::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.cart-drawer-body::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.cart-drawer-body::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.cart-drawer-items {
    flex: 1;
    min-height: 0;
}

.cart-drawer-item {
    display: flex;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    gap: 16px;
    transition: all 0.2s ease;
    background: #ffffff;
    position: relative;
}

.cart-drawer-item:hover {
    background: #fafafa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cart-drawer-item-image {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cart-drawer-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cart-drawer-item:hover .cart-drawer-item-image img {
    transform: scale(1.05);
}

.cart-drawer-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    padding-right: 35px;
    min-width: 0;
}

.cart-drawer-item-details h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: #1a1a1a;
    word-wrap: break-word;
    overflow-wrap: break-word;
    letter-spacing: -0.2px;
}

.cart-drawer-variant {
    font-size: 12px;
    color: #888;
    margin: 0;
    font-weight: 400;
}

.cart-drawer-item-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.cart-drawer-qty-btn {
    width: 32px;
    height: 32px;
    border: 1.5px solid #e0e0e0;
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #555;
    transition: all 0.2s ease;
    font-weight: 500;
}

.cart-drawer-qty-btn:hover {
    border-color: #037a7a;
    color: #037a7a;
    background: #f0f9f9;
    transform: scale(1.05);
}

.cart-drawer-qty-btn:active {
    transform: scale(0.95);
}

.cart-drawer-qty-value {
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
}

.cart-drawer-item-price {
    font-size: 17px;
    font-weight: 700;
    color: #037a7a;
    margin-top: 4px;
    letter-spacing: -0.3px;
}

.cart-drawer-remove {
    position: absolute;
    top: 4px;
    right: 0;
    background: #f8f8f8;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    z-index: 2;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-drawer-remove:hover {
    background: #fee;
    color: #c53030;
    transform: scale(1.1);
}

.cart-drawer-remove:active {
    transform: scale(0.95);
}

/* Empty Cart */
.cart-drawer-empty {
    text-align: center;
    padding: 8px 20px 40px;
    color: #666;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 0;
    background: #ffffff;
}

.cart-drawer-empty i {
    font-size: 72px;
    color: #e0e0e0;
    margin-bottom: 24px;
    opacity: 0.6;
}

.cart-drawer-empty p {
    font-size: 17px;
    margin: 0 0 28px;
    color: #888;
    font-weight: 500;
    letter-spacing: -0.2px;
}

.cart-drawer-empty button {
    padding: 14px 32px;
    background: linear-gradient(135deg, #037a7a 0%, #026969 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(3, 122, 122, 0.3);
    letter-spacing: 0.3px;
}

.cart-drawer-empty button:hover {
    background: linear-gradient(135deg, #026969 0%, #015555 100%);
    box-shadow: 0 6px 16px rgba(3, 122, 122, 0.4);
    transform: translateY(-2px);
}

.cart-drawer-empty button:active {
    transform: translateY(0);
}

/* Recommended Products in Empty Cart */
.cart-drawer-recommended {
    padding: 20px;
    border-top: 2px solid #f0f0f0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
    order: 2;
    margin-top: auto;
}

.cart-drawer-recommended h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 18px 0;
    text-align: center;
}

.cart-drawer-recommended-products {
    display: flex;
    flex-direction: row;
    gap: 15px;
    flex-wrap: wrap;
}

.cart-drawer-recommended-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.cart-drawer-recommended-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cart-drawer-recommended-item-link {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    cursor: default;
    flex: 1;
    pointer-events: none;
}

.cart-drawer-recommended-item-image {
    width: 100%;
    height: 120px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    order: 1;
}

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

.cart-drawer-recommended-item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    order: 2;
}

.cart-drawer-recommended-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    order: 2;
}

.cart-drawer-recommended-item-price {
    font-size: 16px;
    font-weight: 600;
    color: #4ecdc4;
    margin: 0;
    order: 3;
}

.cart-drawer-recommended-item-price .original-price {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    margin-right: 8px;
    font-weight: 400;
}

.cart-drawer-recommended-add-btn {
    width: 100%;
    padding: 10px;
    background: #4ecdc4;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cart-drawer-recommended-add-btn:hover {
    background: #3ab5ad;
    transform: translateY(-1px);
}

.cart-drawer-recommended-add-btn:active {
    transform: translateY(0);
}

.cart-drawer-recommended-add-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.cart-drawer-recommended-add-btn i {
    font-size: 12px;
}

/* Loading State */
.cart-drawer-loading {
    padding: 20px;
}

.cart-drawer-loading .loader {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4ecdc4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cart-drawer-loading p {
    color: #666;
    font-size: 14px;
    text-align: center;
}

/* Skeleton Loader for Cart Items */
.cart-drawer-skeleton {
    display: flex;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    gap: 15px;
}

.cart-drawer-skeleton-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.cart-drawer-skeleton-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-drawer-skeleton-title {
    height: 16px;
    width: 70%;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.cart-drawer-skeleton-title.short {
    width: 50%;
}

.cart-drawer-skeleton-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.cart-drawer-skeleton-qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.cart-drawer-skeleton-qty-value {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.cart-drawer-skeleton-price {
    height: 18px;
    width: 80px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    margin-top: auto;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error State */
.cart-drawer-error {
    text-align: center;
    padding: 40px 20px;
    color: #e53e3e;
}

.cart-drawer-error p {
    margin: 0;
    font-size: 14px;
}

/* Cart Drawer Footer */
.cart-drawer-footer {
    padding: 20px;
    border-top: 2px solid #f0f0f0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.cart-drawer-summary {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #1a1a1a;
}

.cart-drawer-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 15px;
    color: #1a1a1a;
    font-weight: 500;
}

.cart-drawer-summary-row span {
    color: #1a1a1a;
}

.cart-drawer-summary-row:last-of-type:not(.total) {
    margin-bottom: 0;
}

.cart-drawer-summary-row.total {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 2px solid #f0f0f0;
    margin-bottom: 0;
    letter-spacing: -0.3px;
}

.cart-drawer-summary-row.total span {
    color: #1a1a1a;
}

#cartDrawerSubtotal,
#cartDrawerDelivery,
#cartDrawerTotal {
    color: #1a1a1a;
}

.cart-drawer-checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, #037a7a 0%, #026969 100%);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(3, 122, 122, 0.3);
    letter-spacing: 0.3px;
    border: none;
    cursor: pointer;
}

.cart-drawer-checkout-btn:hover {
    background: linear-gradient(135deg, #026969 0%, #015555 100%);
    box-shadow: 0 6px 16px rgba(3, 122, 122, 0.4);
    transform: translateY(-2px);
}

.cart-drawer-checkout-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(3, 122, 122, 0.3);
}

.cart-drawer-checkout-btn i {
    margin-right: 10px;
    font-size: 15px;
}

.cart-drawer-view-cart-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    color: #037a7a;
    text-align: center;
    text-decoration: none;
    border: 2px solid #037a7a;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    letter-spacing: 0.2px;
}

.cart-drawer-view-cart-btn:hover {
    background: #037a7a;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(3, 122, 122, 0.2);
}

.cart-drawer-view-cart-btn:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .cart-drawer {
        max-width: 100% !important;
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .cart-drawer {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .cart-drawer-header {
        padding: 20px 16px;
    }
    
    .cart-drawer-header h2 {
        font-size: 20px;
    }
    
    .cart-drawer-item {
        padding: 14px 16px;
        gap: 14px;
    }
    
    .cart-drawer-item-image {
        width: 80px;
        height: 80px;
    }
    
    .cart-drawer-item-details h4 {
        font-size: 14px;
    }
    
    .cart-drawer-item-price {
        font-size: 16px;
    }
    
    .cart-drawer-footer {
        padding: 16px;
    }
    
    .cart-drawer-checkout-btn {
        padding: 14px 18px;
        font-size: 15px;
    }
    
    .cart-drawer-view-cart-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
}

/* ============================================================================
   CART DRAWER CONSISTENCY OVERRIDES - Ensure consistent styling on all pages
   ============================================================================ */

/* Override any global styles from page-specific CSS that might affect cart drawer */
body:has(.cart-drawer.active) {
    overflow: hidden !important;
    padding-top: 0 !important; /* Override banner padding when drawer is open (including inline styles from banner JS) */
}

body:has(.cart-drawer.active) header {
    position: fixed !important; /* Keep header fixed in place */
    top: 0 !important; /* Keep at top (banner height will be overridden by JS if banner is visible) */
    left: 0 !important;
    right: 0 !important;
    z-index: 99997 !important; /* Just below overlay (99998) but above everything else */
    display: flex !important; /* Ensure header is displayed */
    visibility: visible !important; /* Ensure header is visible */
    opacity: 1 !important; /* Ensure header is fully opaque */
    transform: none !important; /* Prevent any transforms */
    pointer-events: auto !important; /* Allow pointer events */
}

/* Ensure cart drawer styles are not overridden by page-specific CSS */
.cart-drawer,
.cart-drawer * {
    box-sizing: border-box;
}

.cart-drawer-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
    background: #ffffff !important;
}

/* Ensure cart drawer header is always visible */
.cart-drawer-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: #ffffff !important;
    border-bottom: 2px solid #f0f0f0 !important;
}

/* Ensure cart drawer items are properly styled */
.cart-drawer-items {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Ensure cart drawer footer is always visible */
.cart-drawer-footer {
    position: sticky !important;
    bottom: 0 !important;
    background: #ffffff !important;
    border-top: 2px solid #f0f0f0 !important;
    z-index: 10 !important;
}

/* Prevent any page-specific overflow from affecting cart drawer */
#containerProduct:has(+ .cart-drawer.active),
#containerProduct ~ .cart-drawer.active,
body:has(.cart-drawer.active) #containerProduct {
    overflow: visible !important; /* Allow cart drawer to display properly */
}

/* Ensure hero section and other sections don't interfere with cart drawer overlay */
body:has(.cart-drawer.active) .hero-section,
body:has(.cart-drawer.active) section {
    position: relative;
    z-index: 1 !important; /* Below overlay (99998) and drawer (99999) */
}

/* Ensure zoom-result doesn't interfere with cart drawer on contentdetails page */
.zoom-result {
    z-index: 9998 !important; /* Lower than cart drawer overlay (99998) and drawer (99999) */
}
