/* WooCommerce-Style Slide Cart Drawer */
/* iOS-safe, fully responsive, smooth animations */

/* Variables */
:root {
    --cart-bg: rgba(20, 20, 25, 0.95);
    --cart-border: rgba(255, 255, 255, 0.1);
    --cart-text: #ffffff;
    --cart-text-secondary: rgba(255, 255, 255, 0.7);
    --cart-accent: #3b82f6;
    --cart-accent-hover: #2563eb;
    --cart-error: #ef4444;
    --cart-success: #10b981;
    --cart-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Backdrop */
.cart-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 999998;
    will-change: opacity;
}

.cart-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Cart Drawer */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    /* iOS-safe height */
    height: 100dvh;
    height: -webkit-fill-available;
    max-height: 100vh;
    background: var(--cart-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--cart-shadow);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 999999;
    will-change: transform;
    /* Safe area padding for iOS */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    /* Prevent text selection during swipe */
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.cart-drawer.open {
    transform: translateX(0);
}

/* Cart Header */
.cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--cart-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: rgba(20, 20, 25, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.cart-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--cart-text);
}

.cart-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--cart-text);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.cart-close:hover,
.cart-close:focus {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
    outline: none;
}

/* Cart Body - Scrollable */
.cart-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    min-height: 0;
}

/* Empty Cart */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--cart-text-secondary);
    min-height: 300px;
}

.cart-empty p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.cart-empty .btn-browse {
    padding: 0.75rem 1.5rem;
    background: var(--cart-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}

.cart-empty .btn-browse:hover {
    background: var(--cart-accent-hover);
}

/* Cart Items */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--cart-border);
    border-radius: 12px;
    animation: slideIn 0.3s ease-out;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cart-item-image {
    display: none; /* Images removed */
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--cart-text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-item-meta {
    font-size: 0.85rem;
    color: var(--cart-text-secondary);
    margin-bottom: 0.5rem;
}

.cart-item-price {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--cart-accent);
}

.cart-item-remove {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: var(--cart-error);
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.cart-item-remove:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.1);
}

/* Promo Code Section */
.promo-section {
    padding: 1.5rem;
    border-top: 1px solid var(--cart-border);
    border-bottom: 1px solid var(--cart-border);
    background: rgba(255, 255, 255, 0.03);
}

.promo-input-group {
    display: flex;
    gap: 0.5rem;
}

.promo-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--cart-border);
    border-radius: 8px;
    color: var(--cart-text);
    font-size: 0.95rem;
    font-family: inherit;
}

.promo-input:focus {
    outline: none;
    border-color: var(--cart-accent);
    background: rgba(255, 255, 255, 0.15);
}

.promo-input::placeholder {
    color: var(--cart-text-secondary);
}

.btn-apply-promo {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--cart-border);
    border-radius: 8px;
    color: var(--cart-text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-apply-promo:hover {
    background: var(--cart-accent);
    border-color: var(--cart-accent);
}

.promo-message {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.promo-message.success {
    color: var(--cart-success);
}

.promo-message.error {
    color: var(--cart-error);
}

/* Cart Footer */
.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--cart-border);
    background: rgba(20, 20, 25, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.cart-summary {
    margin-bottom: 1rem;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    color: var(--cart-text-secondary);
    font-size: 0.95rem;
}

.cart-row.total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cart-text);
    padding-top: 0.75rem;
    border-top: 1px solid var(--cart-border);
    margin-top: 0.75rem;
}

.cart-row.total span:last-child {
    color: var(--cart-accent);
    font-size: 1.5rem;
}

.checkout-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--cart-accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.checkout-btn:hover {
    background: var(--cart-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.checkout-btn:active {
    transform: translateY(0);
}

.checkout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Cart Toggle Button */
.cart-icon-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--cart-text, #ffffff);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.cart-icon-btn:hover {
    transform: scale(1.1);
}

.cart-icon-btn svg {
    width: 24px;
    height: 24px;
}

.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--cart-accent);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
}

.cart-count:empty {
    display: none;
}

/* Scroll Lock */
body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .cart-drawer {
        width: 420px;
    }
}

/* Responsive - Mobile (Slide Up) */
@media (max-width: 768px) {
    .cart-drawer {
        width: 100vw;
        max-width: 100vw;
        right: 0;
        left: 0;
        top: auto;
        bottom: 0;
        height: 85vh;
        height: 85dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        padding-top: 0;
    }
    
    .cart-drawer.open {
        transform: translateY(0);
    }
    
    .cart-backdrop {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    
    /* Add handle bar for mobile */
    .cart-header::before {
        content: '';
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    .cart-header {
        padding-top: 2rem;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    .cart-drawer {
        height: -webkit-fill-available;
    }
    
    .cart-body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent zoom on inputs */
    .promo-input {
        font-size: 16px;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .cart-drawer {
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }
}

/* Animation for cart item removal */
.cart-item.removing {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
        max-height: 0;
        margin: 0;
        padding: 0;
    }
}

/* Loading state */
.cart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--cart-text-secondary);
}

.cart-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--cart-border);
    border-top-color: var(--cart-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
