/**
 * Cart Sidebar Component
 * Slide-out cart panel (desktop: right sidebar, mobile: fullscreen)
 * Updated to match Figma design 88:7580
 */

/* ============================================
   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: #FCFDFF;
    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);
}

/* ============================================
   Title - No border below
   ============================================ */

.cart-sidebar__title {
    font-family: 'Outfit', sans-serif;
    font-size: 36px;
    font-weight: 400;
    line-height: 1.28;
    color: #2C2C34;
    margin: 0;
}

/* ============================================
   Close Button - Circle with X
   ============================================ */

.cart-sidebar__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #FCFDFF;
    border: none;
    cursor: pointer;
    color: #2C2C34;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.cart-sidebar__close:hover {
    opacity: 0.7;
}

/* ============================================
   Empty State
   ============================================ */

.cart-sidebar__empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    height: 100%;
}

.cart-sidebar__empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #F5F5F5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    margin-bottom: 16px;
}

.cart-sidebar__empty p {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    color: #2C2C34;
    opacity: 0.7;
    margin: 0;
}

/* ============================================
   Desktop Layout - Two Columns
   ============================================ */

.cart-sidebar__mobile-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

/* ============================================
   Cart Items - Horizontal Row Layout
   ============================================ */

.cart-sidebar__items,
.cart-sidebar__items-mobile {
    flex: 1;
    overflow-y: auto;
}

/* Cart Item - Single row layout with border around each item */
.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 16px 24px;
    border: 0.5px solid rgba(44, 44, 52, 0.15);
    border-radius: 0;
    position: relative;
}

/* Gap between cart items */
.cart-item + .cart-item {
    margin-top: 8px;
}

/* Image - 56x56 per Figma */
.cart-item__image {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    overflow: hidden;
    background: #F5F5F5;
}

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

/* Product name and price per day - stacked, fixed width per Figma */
.cart-item__details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 191px;
    flex-shrink: 0;
}

.cart-item__name {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.29;
    color: #2C2C34;
    margin: 0;
}

.cart-item__price-label {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 300;
    line-height: 2;
    color: #2C2C34;
    margin: 0;
}

/* Quantity counter - per Figma */
.cart-item__quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 4px 12px;
    border: 1px solid rgba(44, 44, 52, 0.1);
    border-radius: 0;
    background: #FCFDFF;
    flex-shrink: 0;
}

.cart-item__quantity-btn {
    background: none;
    border: none;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #2C2C34;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    font-size: 12px;
    padding: 0;
}

.cart-item__quantity-btn:hover {
    opacity: 1;
}

.cart-item__quantity-input {
    width: 24px;
    text-align: center;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    color: #2C2C34;
    background: transparent;
    padding: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Hide number input spinners */
.cart-item__quantity-input::-webkit-outer-spin-button,
.cart-item__quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Price column */
.cart-item__subtotal {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 60px;
    flex-shrink: 0;
}

.cart-item__subtotal-label {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 300;
    color: #2C2C34;
    opacity: 0.5;
}

.cart-item__subtotal-value {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #2C2C34;
}

/* Remove button - circular 48px per Figma */
.cart-item__remove {
    background: #FCFDFF;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    color: #2C2C34;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-item__remove:hover {
    opacity: 0.7;
}

.cart-item__remove svg,
.cart-item__remove i {
    font-size: 24px;
}

/* ============================================
   Summary Section
   ============================================ */

.cart-sidebar__summary {
    background: #F8F9FB;
    display: flex;
    flex-direction: column;
}

.cart-sidebar__summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 16px 24px;
}

.cart-sidebar__summary-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.29;
    color: #2C2C34;
    margin: 0;
}

.cart-sidebar__summary-count,
.cart-sidebar__summary-count-mobile {
    color: rgba(44, 44, 52, 0.5);
    font-weight: 400;
}

.cart-sidebar__summary-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px 24px 24px;
}

/* Rental Period */
.cart-sidebar__rental-period {
    padding: 12px 16px;
    background: rgba(44, 44, 52, 0.03);
    margin-bottom: 24px;
}

.cart-sidebar__rental-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.cart-sidebar__rental-header svg {
    color: #2C2C34;
    opacity: 0.5;
}

.cart-sidebar__rental-header span {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 300;
    line-height: 2;
    color: #2C2C34;
    opacity: 0.5;
}

.cart-sidebar__rental-dates {
    display: flex;
    justify-content: space-between;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    color: #2C2C34;
}

.cart-sidebar__rental-range,
.cart-sidebar__rental-range-mobile {
    color: #2C2C34;
}

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

/* Price Breakdown - with border per Figma */
.cart-sidebar__breakdown {
    border: 0.5px solid rgba(44, 44, 52, 0.15);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.cart-sidebar__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    line-height: 2;
}

.cart-sidebar__row span:first-child {
    font-weight: 300;
    color: #2C2C34;
    opacity: 0.5;
}

.cart-sidebar__row span:last-child {
    color: #2C2C34;
    font-weight: 400;
}

/* Total Block - Gray background */
.cart-sidebar__total-block {
    background: rgba(44, 44, 52, 0.03);
    padding: 16px;
    margin-top: auto;
    margin-bottom: 16px;
}

.cart-sidebar__total-block .cart-sidebar__row {
    margin-bottom: 8px;
}

.cart-sidebar__total-block .cart-sidebar__row--subtotal {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(44, 44, 52, 0.1);
    margin-bottom: 12px;
}

.cart-sidebar__total {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cart-sidebar__total > span:first-child {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #2C2C34;
    opacity: 0.7;
}

.cart-sidebar__total-value {
    text-align: right;
}

.cart-sidebar__total-amount {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.27;
    color: #2C2C34;
    display: block;
}

.cart-sidebar__deposit-note,
.cart-sidebar__deposit-note-mobile {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: rgba(44, 44, 52, 0.5);
    margin-top: 4px;
    display: block;
}

/* Checkout Button - No border-radius */
.cart-sidebar__checkout,
.cart-sidebar__checkout-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    background: #2C2C34;
    color: #FCFDFF;
    text-align: center;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 2;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.cart-sidebar__checkout:hover,
.cart-sidebar__checkout-mobile:hover {
    opacity: 0.9;
    color: #FCFDFF;
}

/* ============================================
   Mobile Layout
   ============================================ */

.cart-sidebar__mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    flex-shrink: 0;
}

.cart-sidebar__close--mobile {
    background: transparent;
    border: none;
    border-radius: 0;
}

.cart-sidebar__items-mobile {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 24px;
}

/* Phone cart item — vertical card per Figma (node 88-13101):
   large square image, name + price/day, then Price (left) + qty stepper (right),
   trash icon top-right. Replaces the horizontal desktop row that overflowed
   the narrow phone panel and caused side-scrolling. Scoped to ≤768px so the
   wider tablet panel keeps the horizontal row (which fits there). */
@media (max-width: 768px) {
    .cart-sidebar__items-mobile .cart-item {
        flex-wrap: wrap;
        align-items: center;
        gap: 12px 16px;
        padding: 24px;
    }

    .cart-sidebar__items-mobile .cart-item__image {
        order: 1;
        flex: 0 0 100%;
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .cart-sidebar__items-mobile .cart-item__details {
        order: 2;
        flex: 0 0 100%;
        width: 100%;
    }

    .cart-sidebar__items-mobile .cart-item__subtotal {
        order: 3;
        flex: 1 1 auto;
        min-width: 0;
    }

    .cart-sidebar__items-mobile .cart-item__quantity {
        order: 4;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .cart-sidebar__items-mobile .cart-item__remove {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        background: transparent;
        z-index: 2;
    }

    .cart-sidebar__items-mobile .cart-item--has-kit .cart-item__kit-details {
        order: 5;
        flex: 0 0 100%;
    }
}

.cart-sidebar__empty--mobile {
    padding: 40px 24px;
}

/* Mobile Summary Accordion */
.cart-sidebar__summary-mobile {
    background: #F8F9FB;
    padding: 24px;
    flex-shrink: 0;
}

.cart-sidebar__summary-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0 0 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: #2C2C34;
}

.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: 500px;
}

/* ============================================
   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;
        height: 100%;
    }

    /* Left Column - Shopping Cart */
    .cart-sidebar__left {
        display: flex;
        flex-direction: column;
        padding: 32px;
        overflow: hidden;
    }

    .cart-sidebar__left .cart-sidebar__title {
        flex-shrink: 0;
        margin-bottom: 24px;
    }

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

    /* Custom scrollbar for items */
    .cart-sidebar__items::-webkit-scrollbar {
        width: 4px;
    }

    .cart-sidebar__items::-webkit-scrollbar-track {
        background: transparent;
    }

    .cart-sidebar__items::-webkit-scrollbar-thumb {
        background: rgba(44, 44, 52, 0.2);
        border-radius: 2px;
    }

    .cart-sidebar__items::-webkit-scrollbar-thumb:hover {
        background: rgba(44, 44, 52, 0.4);
    }

    /* Right Column - Summary (full height). Scrolls on its own when the
       viewport is short (small laptop screens) — otherwise the totals and
       the checkout button below the fold were unreachable. */
    .cart-sidebar__summary {
        height: 100%;
        min-height: 0;
        overflow-y: auto;
    }

    .cart-sidebar__summary::-webkit-scrollbar {
        width: 4px;
    }

    .cart-sidebar__summary::-webkit-scrollbar-track {
        background: transparent;
    }

    .cart-sidebar__summary::-webkit-scrollbar-thumb {
        background: rgba(44, 44, 52, 0.2);
        border-radius: 2px;
    }

    /* Desktop cart items - image stays 56x56 per Figma */
}

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

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

    .cart-sidebar__left {
        padding: 40px 48px;
    }
}

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

.cart-sidebar__loading {
    position: relative;
    pointer-events: none;
    min-height: 200px;
}

.cart-sidebar__loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(252, 253, 255, 0.9);
    z-index: 10;
}

.cart-sidebar__loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid rgba(44, 44, 52, 0.1);
    border-top-color: #2C2C34;
    border-radius: 50%;
    animation: cart-spin 0.8s linear infinite;
    z-index: 11;
}

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

/* ============================================
   Kit Details Sub-row (Figma 1:401 single_choice, 1:644 free_mix)
   ============================================ */

/* Wrap kit details below main row */
.cart-item--has-kit {
    flex-wrap: wrap;
}

/* Shared: full-width sub-row, gray bg, borders on left/bottom/right */
.cart-item__kit-details {
    flex: 0 0 100%;
    background: rgba(44, 44, 52, 0.03);
}

/* ── single_choice layout (Figma 1:401): horizontal chip row, gap 56px ── */
.cart-item__kit-details--single {
    display: flex;
    align-items: center;
    gap: 56px;
    padding: 16px 36px;
    flex-wrap: wrap;
}

/* Each slot chip: [32px thumb] gap-44px [label/value column] */
.kit-cart-slot {
    display: flex;
    align-items: center;
    gap: 44px;
    flex-shrink: 0;
}

/* 32×32px overflow-clip thumbnail */
.kit-cart-slot__thumb {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: cover;
    overflow: hidden;
    display: block;
}

.kit-cart-slot__thumb--placeholder {
    background: rgba(44, 44, 52, 0.05);
    display: inline-block;
}

/* Text column: slot label above, selected value below */
.kit-cart-slot__text {
    display: flex;
    flex-direction: column;
}

.kit-cart-slot__label {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 300;
    color: #2c2c34;
    opacity: 0.5;
    line-height: 0.8;
}

.kit-cart-slot__value {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #2c2c34;
    line-height: 2;
}

/* ── free_mix layout (Figma 1:644): wrapping grid, gap 16px row / 124px col ── */
.cart-item__kit-details--mix {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 124px;
    align-items: flex-start;
    padding: 16px 24px;
}

/* Each mix item: [thumb+color group] gap-32px [qty group] */
.kit-cart-mix__item {
    display: flex;
    align-items: center;
    gap: 32px;
    flex-shrink: 0;
}

/* Thumb + color text: gap-16px */
.kit-cart-mix__color-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 32×32px bordered thumbnail (Figma: border 0.235px rgba(44,44,52,0.15)) */
.kit-cart-mix__thumb {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: cover;
    border: 0.235px solid rgba(44, 44, 52, 0.15);
    display: block;
}

.kit-cart-mix__thumb--placeholder {
    background: rgba(44, 44, 52, 0.05);
    display: inline-block;
}

/* Shared text column styles for both color group and qty group */
.kit-cart-mix__text,
.kit-cart-mix__qty-group {
    display: flex;
    flex-direction: column;
}

/* Label: "Color" or "Quantity" — 12px light opacity-50 leading-0.8 */
.kit-cart-mix__label {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 300;
    color: #2c2c34;
    opacity: 0.5;
    line-height: 0.8;
}

/* Value: "Pink" or "10 pcs" — 14px regular leading-2 */
.kit-cart-mix__value {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #2c2c34;
    line-height: 2;
}

/* Hide quantity counter for free_mix kit items (Figma 1:639 opacity-0) */
.cart-item--kit-mix .cart-item__quantity {
    opacity: 0;
    pointer-events: none;
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
    .cart-item__kit-details--single {
        padding: 12px 16px;
        gap: 24px;
    }

    .kit-cart-slot {
        gap: 12px;
    }

    .cart-item__kit-details--mix {
        padding: 12px 16px;
        gap: 12px 48px;
    }
}

/* ============================================
   EVENT DURATION SELECTOR (billing) — Task 10
   ============================================ */
.cart-sidebar__event-duration {
    margin: 16px 0;
}

.cart-sidebar__ed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: #F8F9FB;
    border: 1px solid transparent;
    border-radius: 8px;
}

.cart-sidebar__ed--required {
    border-color: rgba(192, 57, 43, 0.5);
}

/* Attention pulse replayed on each "Proceed to checkout" click while the
   event duration is still required. */
.cart-sidebar__ed--flash {
    animation: cart-ed-flash 0.55s ease;
}

@keyframes cart-ed-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
    35% { box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.28); }
}

.cart-sidebar__ed-label {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #2C2C34;
}

.cart-sidebar__ed-select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    background: #FCFDFF;
    border: 1px solid rgba(44, 44, 52, 0.15);
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    color: #2C2C34;
    cursor: pointer;
}

.cart-sidebar__ed-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cart-sidebar__ed-hint {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(44, 44, 52, 0.6);
}

.cart-sidebar__ed-error {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    color: #C0392B;
}

/* Checkout button disabled while event duration is required */
.cart-sidebar__checkout--disabled,
.cart-sidebar__checkout-mobile.cart-sidebar__checkout--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

