/* ==========================================
   CART DRAWER - Slide-in Winkelwagen
   ScooterDiscounter Theme
   ========================================== */

/* Overlay */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.cart-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Drawer Panel */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: var(--white, #ffffff);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    will-change: transform;
}

.cart-drawer.is-open {
    transform: translateX(0);
}

/* Swipe indicator for mobile */
.cart-drawer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 6px;
    transform: translateY(-50%);
    width: 4px;
    height: 50px;
    background: var(--gray-300, #d1d5db);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

/* Header */
.cart-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    background: var(--white, #ffffff);
    flex-shrink: 0;
}

.cart-drawer__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark, #1a1a2e);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.cart-drawer__title-icon {
    font-size: 18px;
}

.cart-drawer__count {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-600, #4b5563);
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
}

.cart-drawer__close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100, #f3f4f6);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--gray-600, #4b5563);
    transition: all 0.2s;
    line-height: 1;
}

.cart-drawer__close:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--dark, #1a1a2e);
}

/* Body (scrollable) */
.cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Success Message */
.cart-drawer__success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 20px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.cart-drawer__success.is-visible {
    display: flex;
    animation: cartSuccessSlide 0.3s ease;
}

@keyframes cartSuccessSlide {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cart-drawer__success-icon {
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Cart Items Container */
.cart-drawer__items {
    padding: 12px 20px;
}

/* Single Cart Item */
.cart-drawer__item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
    position: relative;
    animation: cartItemFadeIn 0.3s ease;
}

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

.cart-drawer__item:last-child {
    border-bottom: none;
}

.cart-drawer__item.is-removing {
    animation: cartItemSlideOut 0.3s ease forwards;
}

@keyframes cartItemSlideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

.cart-drawer__item.is-updating {
    opacity: 0.5;
    pointer-events: none;
}

/* Item Image */
.cart-drawer__item-image {
    width: 64px;
    height: 64px;
    background: var(--gray-50, #f9fafb);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.cart-drawer__item-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.cart-drawer__item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

/* Item Details */
.cart-drawer__item-details {
    flex: 1;
    min-width: 0;
    padding-right: 24px;
}

.cart-drawer__item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark, #1a1a2e);
    margin: 0 0 2px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.cart-drawer__item-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.cart-drawer__item-name a:hover {
    color: var(--primary, #FF6B00);
}

.cart-drawer__item-options {
    font-size: 11px;
    color: var(--gray-500, #6b7280);
    margin-bottom: 4px;
}

.cart-drawer__item-price {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.cart-drawer__item-price-current {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary, #FF6B00);
}

.cart-drawer__item-price-old {
    font-size: 12px;
    color: var(--gray-400, #9ca3af);
    text-decoration: line-through;
}

/* Quantity Controls */
.cart-drawer__item-qty {
    display: flex;
    align-items: center;
    gap: 2px;
}

.cart-drawer__item-qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--gray-200, #e5e7eb);
    background: var(--white, #ffffff);
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700, #374151);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__item-qty-btn:hover {
    border-color: var(--primary, #FF6B00);
    color: var(--primary, #FF6B00);
    background: rgba(255, 107, 0, 0.05);
}

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

.cart-drawer__item-qty-input {
    width: 36px;
    height: 26px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 5px;
    text-align: center;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark, #1a1a2e);
    -moz-appearance: textfield;
}

.cart-drawer__item-qty-input::-webkit-outer-spin-button,
.cart-drawer__item-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-drawer__item-qty-input:focus {
    outline: none;
    border-color: var(--primary, #FF6B00);
}

/* Remove Button */
.cart-drawer__item-remove {
    position: absolute;
    top: 12px;
    right: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--gray-400, #9ca3af);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__item-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Empty Cart State */
.cart-drawer__empty {
    padding: 48px 20px;
    text-align: center;
    display: none;
}

.cart-drawer__empty.is-visible {
    display: block;
}

.cart-drawer__empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.cart-drawer__empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark, #1a1a2e);
    margin: 0 0 6px 0;
}

.cart-drawer__empty-text {
    font-size: 13px;
    color: var(--gray-500, #6b7280);
    margin: 0 0 20px 0;
}

.cart-drawer__empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary, #FF6B00);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.cart-drawer__empty-btn:hover {
    background: var(--primary-dark, #E55A00);
    color: white;
}

/* Related Products */
.cart-drawer__related {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    background: var(--gray-50, #f9fafb);
}

.cart-drawer__related-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cart-drawer__related-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--dark, #1a1a2e);
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.cart-drawer__related-nav {
    display: flex;
    gap: 4px;
}

.cart-drawer__related-nav-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--gray-300, #d1d5db);
    background: var(--white, #ffffff);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--gray-600, #4b5563);
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__related-nav-btn:hover:not(:disabled) {
    border-color: var(--primary, #FF6B00);
    color: var(--primary, #FF6B00);
}

.cart-drawer__related-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cart-drawer__related-viewport {
    overflow: hidden;
}

.cart-drawer__related-slider {
    display: flex;
    gap: 6px;
    transition: transform 0.3s ease;
}

.cart-drawer__related-item {
    flex: 0 0 72px;
    background: var(--white, #ffffff);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--gray-200, #e5e7eb);
    transition: border-color 0.2s;
}

.cart-drawer__related-item:hover {
    border-color: var(--primary, #FF6B00);
}

.cart-drawer__related-item-image {
    height: 50px;
    background: var(--gray-50, #f9fafb);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-drawer__related-item-image img {
    max-height: 40px;
    max-width: 90%;
    object-fit: contain;
}

.cart-drawer__related-item-info {
    padding: 4px 5px;
}

.cart-drawer__related-item-name {
    font-size: 9px;
    font-weight: 600;
    color: var(--dark, #1a1a2e);
    margin: 0 0 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.cart-drawer__related-item-name a {
    color: inherit;
    text-decoration: none;
}

.cart-drawer__related-item-price {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary, #FF6B00);
}

.cart-drawer__related-item-add {
    width: 100%;
    padding: 4px;
    background: var(--gray-100, #f3f4f6);
    border: none;
    font-size: 8px;
    font-weight: 600;
    color: var(--dark, #1a1a2e);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__related-item-add:hover {
    background: var(--primary, #FF6B00);
    color: white;
}

.cart-drawer__related-item-add--link {
    text-decoration: none;
    display: block;
    text-align: center;
}

.cart-drawer__related-item-add.is-added {
    background: #10b981;
    color: white;
}

/* Footer */
.cart-drawer__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    background: var(--white, #ffffff);
    flex-shrink: 0;
}

/* Subtotal */
.cart-drawer__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cart-drawer__subtotal-label {
    font-size: 13px;
    color: var(--gray-600, #4b5563);
}

.cart-drawer__subtotal-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark, #1a1a2e);
}

/* Shipping Progress */
.cart-drawer__shipping {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--gray-50, #f9fafb);
    border-radius: 6px;
}

.cart-drawer__shipping-text {
    font-size: 12px;
    color: var(--gray-700, #374151);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cart-drawer__shipping-text strong {
    color: var(--primary, #FF6B00);
}

.cart-drawer__shipping-bar {
    height: 5px;
    background: var(--gray-200, #e5e7eb);
    border-radius: 3px;
    overflow: hidden;
}

.cart-drawer__shipping-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary, #FF6B00) 0%, #FF8533 100%);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.cart-drawer__shipping.is-complete .cart-drawer__shipping-text {
    color: #10b981;
}

.cart-drawer__shipping.is-complete .cart-drawer__shipping-fill {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

/* Total */
.cart-drawer__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    margin-bottom: 12px;
}

.cart-drawer__total-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--dark, #1a1a2e);
}

.cart-drawer__total-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary, #FF6B00);
}

/* Buttons */
.cart-drawer__buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-drawer__btn-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary, #FF6B00) 0%, #E55A00 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.3);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__btn-checkout:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 0, 0.4);
    color: white;
}

.cart-drawer__btn-continue {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 20px;
    background: var(--white, #ffffff);
    color: var(--gray-700, #374151);
    border: 2px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.cart-drawer__btn-continue:hover {
    border-color: var(--primary, #FF6B00);
    color: var(--primary, #FF6B00);
}

.cart-drawer__btn-viewcart {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--gray-500, #6b7280);
    text-decoration: none;
    padding: 6px 0;
    transition: color 0.2s;
}

.cart-drawer__btn-viewcart:hover {
    color: var(--primary, #FF6B00);
    text-decoration: underline;
}

/* Payment Icons */
.cart-drawer__payments {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    font-size: 10px;
    color: var(--gray-400, #9ca3af);
}

/* Loading State */
.cart-drawer__loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.cart-drawer__loading.is-visible {
    display: flex;
}

.cart-drawer__loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--primary, #FF6B00);
    border-radius: 50%;
    animation: cartSpinner 0.8s linear infinite;
}

@keyframes cartSpinner {
    to { transform: rotate(360deg); }
}

/* Body scroll lock */
body.cart-drawer-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */
@media (max-width: 480px) {
    .cart-drawer {
        max-width: 100%;
    }

    .cart-drawer::before {
        opacity: 1;
    }

    .cart-drawer__header {
        padding: 14px 16px;
    }

    .cart-drawer__items {
        padding: 10px 16px;
    }

    .cart-drawer__footer {
        padding: 14px 16px;
    }

    .cart-drawer__related {
        padding: 10px 16px;
    }

    .cart-drawer__item-image {
        width: 56px;
        height: 56px;
    }

    .cart-drawer__item-name {
        font-size: 12px;
    }

    .cart-drawer__item-price-current {
        font-size: 13px;
    }

    .cart-drawer__related-item {
        flex: 0 0 68px;
    }

    .cart-drawer__btn-checkout {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ==========================================
   TABLET
   ========================================== */
@media (min-width: 481px) and (max-width: 768px) {
    .cart-drawer {
        max-width: 380px;
    }
}

/* ==========================================
   LARGE SCREENS
   ========================================== */
@media (min-width: 1400px) {
    .cart-drawer {
        max-width: 420px;
    }
}

/* ==========================================
   REDUCED MOTION
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .cart-drawer,
    .cart-overlay,
    .cart-drawer__item,
    .cart-drawer__related-slider,
    .cart-drawer__shipping-fill {
        transition: none;
    }
    
    .cart-drawer__item,
    .cart-drawer__success,
    .cart-drawer__loading-spinner {
        animation: none;
    }
}
