/**
 * Cart Sidebar Component
 * Slide-out cart panel (desktop: right sidebar, mobile: fullscreen)
 */

/* ============================================
   Base Styles
   ============================================ */

.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    visibility: hidden;
    transition: visibility 0.3s ease;
}

.cart-sidebar.is-open {
    visibility: visible;
}

/* Overlay */
.cart-sidebar__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.cart-sidebar.is-open .cart-sidebar__overlay {
    opacity: 1;
}

/* Panel */
.cart-sidebar__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

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

/* ============================================
   Header
   ============================================ */

.cart-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #E5E5E5;
    flex-shrink: 0;
}

.cart-sidebar__title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: #1A1A1A;
}

.cart-sidebar__close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-sidebar__close:hover {
    color: #1A1A1A;
}

/* ============================================
   Content
   ============================================ */

.cart-sidebar__content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Empty State */
.cart-sidebar__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.cart-sidebar__empty p {
    margin-top: 16px;
    font-size: 16px;
    color: #666;
}

/* ============================================
   Desktop Layout (Hidden on mobile)
   ============================================ */

.cart-sidebar__mobile-layout {
    display: block;
}

.cart-sidebar__desktop-layout {
    display: none;
}

/* ============================================
   Cart Items (Mobile)
   ============================================ */

.cart-sidebar__items-mobile {
    margin-bottom: 24px;
}

.cart-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    margin-bottom: 16px;
    position: relative;
}

.cart-item__image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #F5F5F5;
}

.cart-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item__details {
    flex: 1;
    min-width: 0;
}

.cart-item__name {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 4px 0;
    color: #1A1A1A;
}

.cart-item__price-label {
    font-size: 14px;
    color: #666;
    margin: 0 0 12px 0;
}

.cart-item__actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cart-item__quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #E5E5E5;
    border-radius: 4px;
    padding: 4px;
}

.cart-item__quantity-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.cart-item__quantity-btn:hover {
    color: #1A1A1A;
}

.cart-item__quantity-input {
    width: 40px;
    text-align: center;
    border: none;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
}

.cart-item__subtotal-label {
    font-size: 12px;
    color: #999;
}

.cart-item__subtotal-value {
    font-size: 16px;
    font-weight: 600;
    color: #1A1A1A;
}

.cart-item__remove {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s ease;
}

.cart-item__remove:hover {
    color: #DC2626;
}

/* ============================================
   Mobile Summary
   ============================================ */

.cart-sidebar__summary-mobile {
    background: #F9F9F9;
    border-radius: 8px;
    padding: 16px;
    margin-top: 24px;
}

.cart-sidebar__summary-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #1A1A1A;
}

.cart-sidebar__summary-count,
.cart-sidebar__summary-count-mobile {
    color: #666;
    font-weight: 400;
}

.cart-sidebar__summary-icon {
    transition: transform 0.3s ease;
}

.cart-sidebar__summary-mobile.is-open .cart-sidebar__summary-icon {
    transform: rotate(180deg);
}

.cart-sidebar__summary-content-mobile {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.cart-sidebar__summary-mobile.is-open .cart-sidebar__summary-content-mobile {
    max-height: 1000px;
    padding-top: 16px;
}

/* ============================================
   Summary Content (Shared)
   ============================================ */

.cart-sidebar__rental-period {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #E5E5E5;
}

.cart-sidebar__rental-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #666;
    font-size: 14px;
}

.cart-sidebar__rental-dates {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.cart-sidebar__rental-range,
.cart-sidebar__rental-range-mobile {
    color: #1A1A1A;
}

.cart-sidebar__rental-days,
.cart-sidebar__rental-days-mobile {
    color: #666;
}

.cart-sidebar__breakdown {
    margin-bottom: 20px;
}

.cart-sidebar__row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
    color: #666;
}

.cart-sidebar__row span:last-child {
    color: #1A1A1A;
    font-weight: 500;
}

.cart-sidebar__total {
    display: flex;
    justify-content: space-between;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid #E5E5E5;
    font-size: 18px;
    font-weight: 600;
    color: #1A1A1A;
}

.cart-sidebar__deposit-note,
.cart-sidebar__deposit-note-mobile {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

/* Checkout Button */
.cart-sidebar__checkout,
.cart-sidebar__checkout-mobile {
    display: block;
    width: 100%;
    padding: 16px;
    background: #1A1A1A;
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 20px;
    transition: background 0.2s ease;
}

.cart-sidebar__checkout:hover,
.cart-sidebar__checkout-mobile:hover {
    background: #333;
}

/* ============================================
   Desktop Styles
   ============================================ */

@media (min-width: 1024px) {
    .cart-sidebar__panel {
        max-width: 1000px;
        width: 100%;
    }

    .cart-sidebar__mobile-layout {
        display: none;
    }

    .cart-sidebar__desktop-layout {
        display: grid;
        grid-template-columns: 1fr 340px;
        gap: 32px;
        height: 100%;
    }

    .cart-sidebar__items {
        overflow-y: auto;
        padding-right: 16px;
    }

    .cart-sidebar__summary {
        background: #F9F9F9;
        border-radius: 8px;
        padding: 24px;
        height: fit-content;
        position: sticky;
        top: 0;
    }

    .cart-sidebar__summary-header h3 {
        font-size: 18px;
        font-weight: 600;
        margin: 0 0 20px 0;
    }

    /* Desktop cart items slightly different */
    .cart-item {
        padding: 20px;
    }

    .cart-item__image {
        width: 100px;
        height: 100px;
    }
}

@media (min-width: 1440px) {
    .cart-sidebar__panel {
        max-width: 1200px;
    }

    .cart-sidebar__desktop-layout {
        grid-template-columns: 1fr 380px;
    }
}

/* ============================================
   Animations
   ============================================ */

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   Loading State
   ============================================ */

.cart-sidebar__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.cart-sidebar__loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #E5E5E5;
    border-top-color: #1A1A1A;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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