/**
 * cart-field.css
 *
 * Styles for the full cart field and the reusable line item component.
 * These styles apply to both the checkout cart field and the mini cart dropdown.
 *
 * BEM structure:
 *   .gf-cart-field-wrapper        Root wrapper (data-mounted by JS)
 *   .gf-cart-field__loading       Shown before JS mounts
 *   .gf-cart-field__empty         Empty state
 *   .gf-cart-field__items         List of line items
 *   .gf-cart-field__divider       HR above total
 *   .gf-cart-field__total-row     Grand total row
 *
 *   .gf-cart-item                 Single line item
 *   .gf-cart-item--compact        Compact variant (mini cart)
 *   .gf-cart-item--removing       Fade-out animation on delete
 *   .gf-cart-item__body           Flex row: info + controls
 *   .gf-cart-item__info           Product name + variant tags
 *   .gf-cart-item__name           Product name
 *   .gf-cart-item__variants       Variant tag container
 *   .gf-cart-item__variant-tag    Single variant pill
 *   .gf-cart-item__controls       Stepper + total + delete
 *   .gf-cart-item__stepper        Qty stepper group
 *   .gf-cart-item__stepper-btn    − / + buttons
 *   .gf-cart-item__qty            Quantity display
 *   .gf-cart-item__line-total     Line item total
 *   .gf-cart-item__delete         × remove button
 */

/* ── Reset ───────────────────────────────────────────────────────────────── */

.gf-cart-field-wrapper *,
.gf-cart-field-wrapper *::before,
.gf-cart-field-wrapper *::after {
    box-sizing: border-box;
}

/* ── Loading state ───────────────────────────────────────────────────────── */

.gf-cart-field__loading {
    padding: 24px 0;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.gf-cart-field__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 0;
    color: #6b7280;
}

.gf-cart-field__empty-icon {
    font-size: 32px;
    line-height: 1;
    opacity: 0.5;
}

.gf-cart-field__empty-text {
    margin: 0;
    font-size: 15px;
}

/* ── Items list ──────────────────────────────────────────────────────────── */

.gf-cart-field__items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */

.gf-cart-field__divider {
    margin: 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

/* ── Grand total ─────────────────────────────────────────────────────────── */

.gf-cart-field__total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f9fafb;
    border-radius: 0 0 6px 6px;
}

.gf-cart-field__total-label {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.gf-cart-field__total-value {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

/* ── Line item ───────────────────────────────────────────────────────────── */

.gf-cart-item {
    border-bottom: 1px solid #e5e7eb;
    padding: 14px 16px;
    background: #ffffff;
    transition: background 0.15s ease;
    animation: gfCartItemIn 0.2s ease;
}

.gf-cart-item:first-child {
    border-top: 1px solid #e5e7eb;
    border-radius: 6px 6px 0 0;
}

.gf-cart-item:hover {
    background: #fafafa;
}

@keyframes gfCartItemIn {
    from { opacity: 0; transform: translateY( -4px ); }
    to   { opacity: 1; transform: translateY( 0 ); }
}

/* ── Remove animation ────────────────────────────────────────────────────── */

.gf-cart-item--removing {
    animation: gfCartItemOut 0.25s ease forwards;
    pointer-events: none;
}

@keyframes gfCartItemOut {
    from { opacity: 1; max-height: 120px; }
    to   { opacity: 0; max-height: 0; padding: 0; overflow: hidden; }
}

/* ── Item body ───────────────────────────────────────────────────────────── */

.gf-cart-item__body {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── Item info ───────────────────────────────────────────────────────────── */

.gf-cart-item__info {
    flex: 1 1 160px;
    min-width: 0;
}

.gf-cart-item__name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Variant tags ────────────────────────────────────────────────────────── */

.gf-cart-item__variants {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.gf-cart-item__variant-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 12px;
    background: #e5e7eb;
    color: #374151;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

/* ── Controls ────────────────────────────────────────────────────────────── */

.gf-cart-item__controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ── Stepper ─────────────────────────────────────────────────────────────── */

.gf-cart-item__stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.gf-cart-item__stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 400;
    color: #374151;
    line-height: 1;
    transition: background 0.12s ease, color 0.12s ease;
    user-select: none;
}

.gf-cart-item__stepper-btn:hover:not(:disabled) {
    background: #f3f4f6;
    color: #111827;
}

.gf-cart-item__stepper-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.gf-cart-item__stepper-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
}

.gf-cart-item__qty {
    display: block;
    width: 32px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    border-left: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
    line-height: 30px;
}

/* ── Line total ──────────────────────────────────────────────────────────── */

.gf-cart-item__line-total {
    min-width: 60px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* ── Delete button ───────────────────────────────────────────────────────── */

.gf-cart-item__delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    color: #9ca3af;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.12s ease, background 0.12s ease;
    flex-shrink: 0;
}

.gf-cart-item__delete:hover {
    color: #dc2626;
    background: #fef2f2;
}

.gf-cart-item__delete:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

/* ── Compact variant (mini cart) ─────────────────────────────────────────── */

.gf-cart-item--compact {
    padding: 10px 12px;
}

.gf-cart-item--compact .gf-cart-item__name {
    font-size: 13px;
}

.gf-cart-item--compact .gf-cart-item__variant-tag {
    font-size: 10px;
    padding: 1px 6px;
}

.gf-cart-item--compact .gf-cart-item__stepper-btn {
    width: 26px;
    height: 26px;
    font-size: 14px;
}

.gf-cart-item--compact .gf-cart-item__qty {
    width: 26px;
    font-size: 13px;
    line-height: 26px;
}

.gf-cart-item--compact .gf-cart-item__line-total {
    font-size: 13px;
    min-width: 50px;
}

/* ── Hidden slot fields ──────────────────────────────────────────────────── */

.gf-cart-slot--hidden,
.gfield.gf-cart-slot--hidden {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media ( max-width: 480px ) {
    .gf-cart-item__body {
        flex-wrap: wrap;
    }

    .gf-cart-item__info {
        flex: 1 1 100%;
    }

    .gf-cart-item__controls {
        width: 100%;
        justify-content: flex-end;
    }
}
