/**
 * FBL Shopping Cart Styles
 * Matches the existing site design (soft pink theme)
 */

/* ===== Cart Icon Button (Header) ===== */
.cart-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-dark, #2d3436);
    transition: color 0.3s ease, transform 0.3s ease;
    margin-left: 1rem;
}

.cart-icon-btn:hover {
    color: var(--primary-dark, #e8b4c4);
}

.cart-icon-btn svg {
    width: 24px;
    height: 24px;
}

/* Cart count badge */
.cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--primary-dark, #e8b4c4);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    line-height: 1;
}

/* Cart icon bump animation */
.cart-icon-btn.cart-icon-bump {
    animation: cartBump 0.3s ease;
}

@keyframes cartBump {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===== Cart Overlay ===== */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1100;
}

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

/* ===== Cart Panel ===== */
.cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1101;
    display: flex;
    flex-direction: column;
}

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

/* ===== Cart Header ===== */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.cart-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark, #2d3436);
}

.cart-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-medium, #636e72);
    transition: color 0.2s ease;
    border-radius: 50%;
}

.cart-close:hover {
    color: var(--text-dark, #2d3436);
    background: #f5f5f5;
}

/* ===== Cart Items Container ===== */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* ===== Individual Cart Item ===== */
.cart-item {
    display: grid;
    grid-template-columns: 70px 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

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

.cart-item-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
}

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

.cart-item-details {
    min-width: 0;
}

.cart-item-name {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark, #2d3436);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-medium, #636e72);
}

/* Quantity controls */
.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f5f5f5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-dark, #2d3436);
    transition: background 0.2s ease;
}

.cart-qty-btn:hover {
    background: var(--primary, #f5d5e0);
}

.cart-qty-value {
    min-width: 20px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Item total */
.cart-item-total {
    font-weight: 600;
    color: var(--text-dark, #2d3436);
    font-size: 0.95rem;
}

/* Remove button */
.cart-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-light, #b2bec3);
    transition: color 0.2s ease;
    border-radius: 4px;
}

.cart-item-remove:hover {
    color: #e74c3c;
    background: #fef5f5;
}

/* ===== Cart Footer ===== */
.cart-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.cart-subtotal span:first-child {
    color: var(--text-medium, #636e72);
}

.cart-subtotal span:last-child {
    font-weight: 700;
    color: var(--text-dark, #2d3436);
}

.cart-checkout-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--primary-dark, #e8b4c4);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

.cart-checkout-btn:hover:not(:disabled) {
    background: #d9a3b3;
    transform: translateY(-1px);
}

.cart-checkout-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.cart-shipping-note {
    margin: 0.75rem 0 0 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light, #b2bec3);
}

/* ===== Empty Cart State ===== */
.cart-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-light, #b2bec3);
}

.cart-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.cart-empty p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-medium, #636e72);
}

/* ===== Add to Cart Button Styles ===== */
/* These styles enhance the existing buttons with add-to-cart behavior */
[data-add-to-cart] {
    position: relative;
    overflow: hidden;
}

[data-add-to-cart]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

[data-add-to-cart]:active::after {
    width: 200%;
    height: 200%;
}

/* ===== Responsive Styles ===== */
@media (max-width: 480px) {
    .cart-panel {
        max-width: 100%;
    }

    .cart-item {
        grid-template-columns: 60px 1fr auto;
        gap: 0.75rem;
    }

    .cart-item-total {
        display: none;
    }

    .cart-item-image {
        width: 60px;
        height: 60px;
    }

    .cart-item-name {
        font-size: 0.9rem;
    }

    .cart-icon-btn {
        width: 40px;
        height: 40px;
        margin-left: 0.5rem;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    .cart-panel,
    .cart-overlay,
    .cart-icon-btn,
    .cart-checkout-btn,
    [data-add-to-cart]::after {
        transition: none;
    }

    .cart-icon-btn.cart-icon-bump {
        animation: none;
    }
}

/* Focus styles for keyboard navigation */
.cart-close:focus-visible,
.cart-qty-btn:focus-visible,
.cart-item-remove:focus-visible,
.cart-checkout-btn:focus-visible,
.cart-icon-btn:focus-visible {
    outline: 2px solid var(--primary-dark, #e8b4c4);
    outline-offset: 2px;
}
