/**
 * Sidebar Cart Styles
 *
 * Styles for the cart icon with badge (Req 2) and the slide-in
 * sidebar cart panel (Req 3). Uses design tokens from
 * higuppy-design-tokens.css for consistency.
 *
 * @package HiGuppy
 * @since 1.0.0
 */

/* ==========================================================================
   Cart Icon & Badge
   ========================================================================== */

.higuppy-cart-icon-wrapper {
    position: fixed;
    top: calc(var(--higuppy-space) * 2);
    right: calc(var(--higuppy-space) * 2);
    z-index: 9998;
}

.higuppy-cart-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--higuppy-touch-min);
    height: var(--higuppy-touch-min);
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--higuppy-primary);
    color: var(--higuppy-neutral-100);
    cursor: pointer;
    transition: background-color 200ms ease, transform 200ms ease;
}

.higuppy-cart-icon:hover {
    background-color: var(--higuppy-secondary);
    transform: scale(1.05);
}

.higuppy-cart-icon:focus-visible {
    outline: 3px solid var(--higuppy-accent);
    outline-offset: 2px;
}

.higuppy-cart-icon:active {
    transform: scale(0.95);
    background-color: var(--higuppy-secondary);
}

.higuppy-cart-icon-svg {
    width: 22px;
    height: 22px;
}

.higuppy-cart-icon-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 50%;
    background-color: var(--higuppy-accent);
    color: #fff;
    font-family: var(--higuppy-font-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    transition: transform 200ms ease;
}

/* Badge hidden when cart is empty */
.higuppy-cart-icon-badge:empty,
.higuppy-cart-icon-badge.is-hidden {
    display: none;
}

/* Badge bounce animation on update */
@keyframes higuppy-badge-bounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.higuppy-cart-icon-badge.is-updating {
    animation: higuppy-badge-bounce 300ms ease;
}

/* ==========================================================================
   Sidebar Cart Overlay
   ========================================================================== */

.higuppy-sidebar-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.higuppy-sidebar-cart-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Sidebar Cart Panel
   ========================================================================== */

.higuppy-sidebar-cart {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    background-color: var(--higuppy-neutral-100);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

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

.higuppy-sidebar-cart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--higuppy-space) * 2) calc(var(--higuppy-space) * 3);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.higuppy-sidebar-cart__title {
    margin: 0;
    font-family: var(--higuppy-font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--higuppy-neutral-900);
}

.higuppy-sidebar-cart__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--higuppy-touch-min);
    height: var(--higuppy-touch-min);
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--higuppy-neutral-900);
    cursor: pointer;
    transition: background-color 200ms ease;
}

.higuppy-sidebar-cart__close:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.higuppy-sidebar-cart__close:focus-visible {
    outline: 3px solid var(--higuppy-accent);
    outline-offset: 2px;
}

.higuppy-sidebar-cart__close svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Cart Items List
   ========================================================================== */

.higuppy-sidebar-cart__items {
    flex: 1;
    overflow-y: auto;
    padding: calc(var(--higuppy-space) * 2) calc(var(--higuppy-space) * 3);
    -webkit-overflow-scrolling: touch;
}

.higuppy-sidebar-cart__item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: calc(var(--higuppy-space) * 1.5);
    padding: calc(var(--higuppy-space) * 2) 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.higuppy-sidebar-cart__item:last-child {
    border-bottom: none;
}

.higuppy-sidebar-cart__item-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.04);
}

.higuppy-sidebar-cart__item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.higuppy-sidebar-cart__item-details {
    display: flex;
    flex-direction: column;
    gap: calc(var(--higuppy-space) * 0.5);
}

.higuppy-sidebar-cart__item-name {
    margin: 0;
    font-family: var(--higuppy-font-primary);
    font-size: 14px;
    font-weight: 500;
    color: var(--higuppy-neutral-900);
    line-height: 1.3;
}

.higuppy-sidebar-cart__item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--higuppy-font-primary);
    font-size: 13px;
    color: rgba(6, 27, 61, 0.65);
}

.higuppy-sidebar-cart__item-quantity {
    color: rgba(6, 27, 61, 0.65);
}

.higuppy-sidebar-cart__item-price {
    font-weight: 600;
    color: var(--higuppy-neutral-900);
}

/* ==========================================================================
   Cart Footer — Subtotal & Buttons
   ========================================================================== */

.higuppy-sidebar-cart__footer {
    flex-shrink: 0;
    padding: calc(var(--higuppy-space) * 2) calc(var(--higuppy-space) * 3) calc(var(--higuppy-space) * 3);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background-color: #fff;
}

.higuppy-sidebar-cart__subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: calc(var(--higuppy-space) * 2);
    font-family: var(--higuppy-font-primary);
}

.higuppy-sidebar-cart__subtotal-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--higuppy-neutral-900);
}

.higuppy-sidebar-cart__subtotal-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--higuppy-neutral-900);
}

.higuppy-sidebar-cart__actions {
    display: flex;
    flex-direction: column;
    gap: calc(var(--higuppy-space) * 1.5);
}

.higuppy-sidebar-cart__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--higuppy-touch-min);
    padding: calc(var(--higuppy-space) * 1.5) calc(var(--higuppy-space) * 2);
    border: none;
    border-radius: 6px;
    font-family: var(--higuppy-font-primary);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background-color 200ms ease, transform 100ms ease;
}

.higuppy-sidebar-cart__btn:active {
    transform: scale(0.98);
}

.higuppy-sidebar-cart__btn:focus-visible {
    outline: 3px solid var(--higuppy-accent);
    outline-offset: 2px;
}

.higuppy-sidebar-cart__btn--checkout {
    background-color: var(--higuppy-accent);
    color: #fff;
}

.higuppy-sidebar-cart__btn--checkout:hover {
    background-color: #e5551f;
}

.higuppy-sidebar-cart__btn--view-cart {
    background-color: transparent;
    color: var(--higuppy-primary);
    border: 2px solid var(--higuppy-primary);
}

.higuppy-sidebar-cart__btn--view-cart:hover {
    background-color: var(--higuppy-primary);
    color: #fff;
}

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

.higuppy-sidebar-cart__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: calc(var(--higuppy-space) * 4) calc(var(--higuppy-space) * 3);
    text-align: center;
}

.higuppy-sidebar-cart__empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: calc(var(--higuppy-space) * 2);
    color: rgba(6, 27, 61, 0.25);
}

.higuppy-sidebar-cart__empty-message {
    margin: 0 0 calc(var(--higuppy-space) * 3);
    font-family: var(--higuppy-font-primary);
    font-size: 16px;
    font-weight: 500;
    color: rgba(6, 27, 61, 0.6);
}

.higuppy-sidebar-cart__empty-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--higuppy-touch-min);
    padding: calc(var(--higuppy-space) * 1.5) calc(var(--higuppy-space) * 3);
    border-radius: 6px;
    background-color: var(--higuppy-primary);
    color: #fff;
    font-family: var(--higuppy-font-primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 200ms ease;
}

.higuppy-sidebar-cart__empty-link:hover {
    background-color: var(--higuppy-secondary);
    color: #fff;
}

.higuppy-sidebar-cart__empty-link:focus-visible {
    outline: 3px solid var(--higuppy-accent);
    outline-offset: 2px;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
    /* Cart icon adjustments for mobile */
    .higuppy-cart-icon-wrapper {
        top: calc(var(--higuppy-space) * 1.5);
        right: calc(var(--higuppy-space) * 1.5);
    }

    .higuppy-cart-icon {
        width: 40px;
        height: 40px;
    }

    .higuppy-cart-icon-svg {
        width: 20px;
        height: 20px;
    }

    .higuppy-cart-icon-badge {
        min-width: 16px;
        height: 16px;
        font-size: 10px;
        top: -3px;
        right: -3px;
    }

    /* Sidebar panel full width on mobile */
    .higuppy-sidebar-cart {
        max-width: 100vw;
    }

    .higuppy-sidebar-cart__item {
        grid-template-columns: 50px 1fr;
    }

    .higuppy-sidebar-cart__item-thumbnail {
        width: 50px;
        height: 50px;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .higuppy-cart-icon-wrapper {
        top: var(--higuppy-space);
        right: var(--higuppy-space);
    }
}
