/**
 * Cart Sidebar Styles
 * Consolidated CSS for cart sidebar component
 */

/* ========================================= */
/* CART SIDEBAR COMPONENT STYLES             */
/* ========================================= */

/* Base styles for all cart components - ensures no inheritance from body */
.tlh-cart-component {
    font-family: var(--font-description) !important;
    color: #333;
}

/* Cart sidebar background */
.cart-sidebar,
.tlh-cart-component.cart-sidebar {
    background: #f6f1e5 !important;
}

/* Cart Backdrop */
.cart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Enhanced cart backdrop with blur */
.cart-backdrop.tlh-cart-component,
.tlh-cart-component.cart-backdrop,
#cart-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                visibility 0.4s ease,
                backdrop-filter 0.4s ease !important;
    z-index: 1059 !important;
    will-change: opacity, backdrop-filter;
}

.cart-backdrop.tlh-cart-component.active,
.tlh-cart-component.cart-backdrop.active,
#cart-backdrop.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Alternative blur effect for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
    .cart-backdrop.tlh-cart-component.active,
    .tlh-cart-component.cart-backdrop.active,
    #cart-backdrop.active {
        background: rgba(0, 0, 0, 0.6) !important;
    }
    
    /* Blur the body content when cart is active */
    body:has(#cart-backdrop.active) > *:not(#cart-backdrop):not(#cart-sidebar),
    body.cart-open > *:not(#cart-backdrop):not(#cart-sidebar) {
        filter: blur(2px);
        transition: filter 0.3s ease;
    }
}

/* Cart Sidebar - Base styles */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background-color: white;
    z-index: 2000;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    transition: right 0.3s ease;
    display: none;
    flex-direction: column;
}

.cart-sidebar.active {
    right: 0;
    display: flex;
}

/* Cart Sidebar - Enhanced TLH component styles */
.tlh-cart-component.cart-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 420px;
    height: 100%;
    background: #f6f1e5 !important;
    z-index: 1060;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: none;
    flex-direction: column;
    will-change: right;
}

.tlh-cart-component.cart-sidebar.active {
    right: 0;
    display: flex;
}

/* Staggered animation for cart content */
.tlh-cart-component.cart-sidebar .cart-header,
.tlh-cart-component.cart-sidebar .free-shipping-banner,
.tlh-cart-component.cart-sidebar .cart-body,
.tlh-cart-component.cart-sidebar .cart-footer {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0s;
}

.tlh-cart-component.cart-sidebar.active .cart-header {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

.tlh-cart-component.cart-sidebar.active .free-shipping-banner {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.15s;
}

.tlh-cart-component.cart-sidebar.active .cart-body {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.2s;
}

.tlh-cart-component.cart-sidebar.active .cart-footer {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.25s;
}

/* ========================================= */
/* CART HEADER                               */
/* ========================================= */

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.tlh-cart-component .cart-header {
    padding: 12px 20px 8px;
    border-bottom: 1px solid #e5e5e5;
    background: #f6f1e5 !important;
    position: relative;
}

.cart-title {
    font-size: 18px;
    font-weight: bold;
    font-family: var(--font-karla);
    color: var(--text-brown);
}

.tlh-cart-component .cart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-brown);
    margin: 0;
    font-family: var(--font-product-title) !important;
}

.tlh-cart-component .cart-count {
    color: #666;
    font-size: 13px;
    margin-top: 1px;
}

.cart-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.cart-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.tlh-cart-component .cart-close-btn {
    position: absolute;
    top: 12px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tlh-cart-component .cart-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* ========================================= */
/* FREE SHIPPING BANNER                      */
/* ========================================= */

.tlh-cart-component .free-shipping-banner {
    background: var(--text-teal);
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-description) !important;
}

/* ========================================= */
/* CART BODY                                 */
/* ========================================= */

.cart-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.tlh-cart-component .cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ========================================= */
/* CART ITEMS                                */
/* ========================================= */

.tlh-cart-component .cart-items {
    padding: 0;
}

/* Cart items fade in animation */
.tlh-cart-component .cart-item {
    opacity: 0;
    transform: translateY(10px);
    animation: cartItemFadeIn 0.3s ease forwards;
}

.tlh-cart-component .cart-item:nth-child(1) { animation-delay: 0.1s; }
.tlh-cart-component .cart-item:nth-child(2) { animation-delay: 0.15s; }
.tlh-cart-component .cart-item:nth-child(3) { animation-delay: 0.2s; }
.tlh-cart-component .cart-item:nth-child(4) { animation-delay: 0.25s; }
.tlh-cart-component .cart-item:nth-child(5) { animation-delay: 0.3s; }

.tlh-cart-component .cart-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    align-items: flex-start;
}

.tlh-cart-component .cart-item:hover {
    background: #fafafa;
}

.tlh-cart-component .cart-item:last-child {
    border-bottom: none;
}

/* Cart Item Image */
.tlh-cart-component .cart-item-image {
    width: 60px;
    height: 75px;
    border-radius: 6px;
    object-fit: cover;
    background: #f8f8f8;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Cart Item Details - Modified for optimized layout */
.tlh-cart-component .cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tlh-cart-component .cart-item-info {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Top row with name and remove button */
.tlh-cart-component .cart-item-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
}

.tlh-cart-component .cart-item-name-section {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 24px);
}

.tlh-cart-component .cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-brown);
    line-height: 1.3;
    margin-bottom: 2px;
    font-family: var(--font-description) !important;
}

.tlh-cart-component .cart-item-variant {
    font-size: 12px;
    color: #666;
    margin-bottom: 0;
    font-family: var(--font-description) !important;
    font-style: normal !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-transform: capitalize !important;
}

/* Middle row with price */
.tlh-cart-component .cart-item-price-row {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tlh-cart-component .cart-item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-brown);
    font-family: var(--font-description) !important;
    display: inline-block;
}

/* Cart Actions - Inline with price */
.tlh-cart-component .cart-item-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

/* Cart Item Actions - Clean minimal style */
.tlh-cart-component .cart-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ========================================= */
/* QUANTITY CONTROLS                         */
/* ========================================= */

.tlh-cart-component .quantity-controls {
    display: inline-flex;
    align-items: center;
    background: transparent;
    height: 22px;
    position: relative;
}

.tlh-cart-component .quantity-btn {
    width: 18px;
    height: 18px;
    border: none;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    color: #666;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tlh-cart-component .quantity-btn:hover {
    background: #f8f8f8;
    color: var(--text-teal);
    transform: scale(1.05);
}

.tlh-cart-component .quantity-btn:active {
    transform: scale(0.95);
}

.tlh-cart-component .quantity-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.tlh-cart-component .quantity-display {
    min-width: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-brown);
    padding: 0 4px;
    border: none;
    background: transparent;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Remove Button - positioned in top row */
.tlh-cart-component .cart-item-remove {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: all 0.15s ease;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    flex-shrink: 0;
    margin-top: 4px;
}

.tlh-cart-component .cart-item-remove:hover {
    color: #e74c3c;
    transform: scale(1.1);
}

/* ========================================= */
/* CART FOOTER                               */
/* ========================================= */

.cart-footer {
    border-top: 1px solid #eee;
    padding: 20px;
}

.tlh-cart-component .cart-footer {
    background: #f6f1e5 !important;
    border-top: 1px solid #e5e5e5;
    padding: 16px 20px;
    margin-top: auto;
}

/* Cart Summary */
.tlh-cart-component .cart-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tlh-cart-component .cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.tlh-cart-component .cart-total-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.tlh-cart-component .cart-total-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-brown);
    font-family: var(--font-description) !important;
    line-height: 1.2;
}

.tlh-cart-component .cart-total-label {
    font-size: 12px;
    color: #666;
    font-weight: 400;
    font-family: var(--font-description) !important;
    line-height: 1;
    margin-top: 2px;
    text-decoration: underline;
}

.tlh-cart-component .cart-offers-message {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

.tlh-cart-component .celebration-emoji {
    font-size: 14px;
}

.tlh-cart-component .offers-text {
    font-size: 11px;
    color: #888;
    font-weight: 400;
    opacity: 0.7;
    font-family: var(--font-description) !important;
}

/* ========================================= */
/* CHECKOUT BUTTON                           */
/* ========================================= */

.tlh-cart-component .checkout-btn {
    background: var(--text-teal);
    color: white;
    border: none;
    border-radius: 0;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-description) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    min-width: 140px;
}

.tlh-cart-component .checkout-btn:hover {
    background: #156b75;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(27, 123, 137, 0.3);
}

.tlh-cart-component .checkout-btn:active {
    transform: translateY(0);
}

/* ========================================= */
/* EMPTY CART STATE                          */
/* ========================================= */

.tlh-cart-component .empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    flex: 1;
}

.tlh-cart-component .empty-cart-icon {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 16px;
}

.tlh-cart-component .empty-cart-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-brown);
    margin-bottom: 8px;
    font-family: var(--font-description) !important;
}

.tlh-cart-component .empty-cart-message {
    font-size: 14px;
    font-family: var(--font-description) !important;
    color: #666;
    margin-bottom: 24px;
    line-height: 1.4;
}

.tlh-cart-component .continue-shopping-btn {
    background: var(--text-teal);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-description) !important;
}

.tlh-cart-component .continue-shopping-btn:hover {
    background: #156b75;
}

/* ========================================= */
/* CART BADGE                                */
/* ========================================= */

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--text-teal);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ========================================= */
/* ANIMATIONS                                */
/* ========================================= */

@keyframes cartSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes cartItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes backdropFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }
}

/* Loading states */
.tlh-cart-component.cart-sidebar.loading {
    pointer-events: none;
}

.tlh-cart-component.cart-sidebar.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--text-teal);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 9999;
}

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

/* Smooth transitions for interactive elements */
.cart-item-remove,
.quantity-btn,
.checkout-btn {
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cart-item-remove:hover,
.quantity-btn:hover {
    transform: scale(1.05);
}

.checkout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27, 123, 137, 0.3);
}

/* ========================================= */
/* MOBILE RESPONSIVE - 768px                 */
/* ========================================= */

@media (max-width: 768px) {
    .tlh-cart-component.cart-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .tlh-cart-component.cart-sidebar.active {
        right: 0;
    }
    
    .tlh-cart-component .cart-header {
        padding: 14px 18px 10px;
    }
    
    .tlh-cart-component .cart-title {
        font-size: 15px;
    }
    
    .tlh-cart-component .cart-close-btn {
        top: 14px;
        right: 18px;
        width: 26px;
        height: 26px;
        font-size: 16px;
    }
    
    .tlh-cart-component .free-shipping-banner {
        padding: 8px 18px;
        font-size: 12px;
    }
    
    .tlh-cart-component .cart-item {
        padding: 14px 16px;
    }
    
    .tlh-cart-component .cart-item-image {
        width: 55px;
        height: 70px;
        margin-right: 10px;
    }
    
    .tlh-cart-component .cart-item-name {
        font-size: 13px;
    }
    
    .tlh-cart-component .cart-item-variant {
        font-size: 11px;
    }
    
    .tlh-cart-component .cart-item-price {
        font-size: 14px;
    }
    
    .tlh-cart-component .quantity-controls {
        height: 20px;
    }
    
    .tlh-cart-component .quantity-btn {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    .tlh-cart-component .quantity-display {
        min-width: 18px;
        font-size: 11px;
    }
    
    .tlh-cart-component .cart-item-remove {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
}

/* ========================================= */
/* MOBILE RESPONSIVE - 480px                 */
/* ========================================= */

@media (max-width: 480px) {
    .cart-sidebar {
        max-width: 100%;
    }
    
    .cart-item {
        padding: 12px 16px;
    }
    
    .cart-item-image {
        width: 50px;
        height: 65px;
        margin-right: 8px;
    }
    
    .cart-item-name {
        font-size: 12px;
        line-height: 1.2;
    }
    
    .cart-item-variant {
        font-size: 10px;
    }
    
    .cart-item-price {
        font-size: 13px;
    }
    
    .tlh-cart-component .quantity-controls {
        height: 18px;
    }
    
    .tlh-cart-component .quantity-btn {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    
    .tlh-cart-component .quantity-display {
        min-width: 16px;
        font-size: 10px;
    }
    
    .tlh-cart-component .cart-item-remove {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
    
    .cart-footer {
        padding: 12px 16px;
    }
    
    .cart-total-label {
        font-size: 14px;
    }
    
    .cart-total-amount {
        font-size: 16px;
    }
    
    .checkout-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .cart-header {
        padding: 12px 16px 8px;
    }
    
    .cart-title {
        font-size: 14px;
    }
    
    .cart-close-btn {
        top: 12px;
        right: 16px;
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
    
    .free-shipping-banner {
        padding: 6px 16px;
        font-size: 11px;
    }

    .quantity-btn {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
    
    .quantity-display {
        font-size: 11px;
        min-width: 16px;
        padding: 0 2px;
    }
    
    .cart-item-remove {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
}

/* ========================================= */
/* ACCOUNT PAGES SPECIFIC OVERRIDES          */
/* ========================================= */

/* Ensure cart sidebar has proper z-index on account pages */
.account-page .cart-sidebar {
    z-index: 2000 !important;
}
