/**
 * BPCO Product Controls — Styles
 * [bpco_qty] | [bpco_variations] | [bpco_add_to_cart]
 *
 * @package BP_Hybrid_Checkout
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CSS VARIABLES — easy to override from theme
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --bpco-primary: #01696f;
    --bpco-primary-hover: #0c4e54;
    --bpco-primary-active: #0f3638;
    --bpco-primary-light: #cedcd8;
    --bpco-success: #437a22;
    --bpco-error: #a12c2c;
    --bpco-error-bg: #fef2f2;
    --bpco-text: #28251d;
    --bpco-text-muted: #7a7974;
    --bpco-text-faint: #bab9b4;
    --bpco-border: rgba(40, 37, 29, 0.15);
    --bpco-border-focus: #01696f;
    --bpco-surface: #f9f8f5;
    --bpco-surface-hover: #f3f0ec;
    --bpco-radius-sm: 0.375rem;
    --bpco-radius-md: 0.5rem;
    --bpco-radius-lg: 0.75rem;
    --bpco-radius-full: 9999px;
    --bpco-transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
    --bpco-shadow-sm: 0 1px 2px rgba(40, 37, 29, 0.06);
    --bpco-shadow-md: 0 4px 12px rgba(40, 37, 29, 0.10);
    --bpco-font: inherit;
}

/* ═══════════════════════════════════════════════════════════════════════════
   QUANTITY SELECTOR — [bpco_qty]
   ═══════════════════════════════════════════════════════════════════════════ */

.bpco-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1.5px solid var(--bpco-border);
    border-radius: var(--bpco-radius-md);
    background: #fff;
    overflow: hidden;
    transition: border-color var(--bpco-transition),
        box-shadow var(--bpco-transition);
    height: 44px;
}

.bpco-qty:focus-within {
    border-color: var(--bpco-border-focus);
    box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.15);
    outline: none;
}

/* +/- Buttons */
.bpco-qty__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--bpco-text);
    transition: background var(--bpco-transition),
        color var(--bpco-transition);
    flex-shrink: 0;
    font-family: var(--bpco-font);
    -webkit-tap-highlight-color: transparent;
}

.bpco-qty__btn:hover:not(:disabled) {
    background: var(--bpco-surface-hover);
    color: var(--bpco-primary);
}

.bpco-qty__btn:active:not(:disabled) {
    background: var(--bpco-primary-light);
}

.bpco-qty__btn:disabled {
    color: var(--bpco-text-faint);
    cursor: not-allowed;
}

/* Dividers between button and input */
.bpco-qty__minus {
    border-right: 1.5px solid var(--bpco-border);
}

.bpco-qty__plus {
    border-left: 1.5px solid var(--bpco-border);
}

/* Number input */
.bpco-qty__input {
    width: 52px;
    height: 100%;
    border: none;
    outline: none;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--bpco-font);
    color: var(--bpco-text);
    background: transparent;
    padding: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.bpco-qty__input::-webkit-outer-spin-button,
.bpco-qty__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VARIATION SELECTOR — [bpco_variations]
   ═══════════════════════════════════════════════════════════════════════════ */

.bpco-variations {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    font-family: var(--bpco-font);
}

/* Single attribute group */
.bpco-variation-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* Label row */
.bpco-variation-group__label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.bpco-variation-group__name {
    font-weight: 600;
    color: var(--bpco-text);
    text-transform: capitalize;
}

.bpco-variation-group__selected {
    color: var(--bpco-text-muted);
    font-weight: 400;
    transition: color var(--bpco-transition);
}

/* Options row */
.bpco-variation-group__options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ── Variation Buttons ── */
.bpco-variation-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.875rem;
    min-width: 44px;
    min-height: 40px;
    border: 1.5px solid var(--bpco-border);
    border-radius: var(--bpco-radius-md);
    background: #fff;
    color: var(--bpco-text);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--bpco-font);
    cursor: pointer;
    transition: border-color var(--bpco-transition),
        background var(--bpco-transition),
        color var(--bpco-transition),
        box-shadow var(--bpco-transition),
        transform var(--bpco-transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    line-height: 1;
}

.bpco-variation-btn:hover:not(:disabled) {
    border-color: var(--bpco-primary);
    color: var(--bpco-primary);
    background: rgba(1, 105, 111, 0.04);
}

.bpco-variation-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.bpco-variation-btn.is-selected {
    border-color: var(--bpco-primary);
    background: var(--bpco-primary);
    color: #fff;
    box-shadow: var(--bpco-shadow-sm);
}

.bpco-variation-btn.is-selected:hover {
    background: var(--bpco-primary-hover);
    border-color: var(--bpco-primary-hover);
    color: #fff;
}

/* Disabled / out-of-stock variation */
.bpco-variation-btn.is-disabled,
.bpco-variation-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
    pointer-events: none;
}

/* Focus ring */
.bpco-variation-btn:focus-visible {
    outline: 2px solid var(--bpco-primary);
    outline-offset: 2px;
}

/* ── Color Swatches ── */
.bpco-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--bpco-radius-full);
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--bpco-font);
    background: var(--bpco-surface);
    color: var(--bpco-text);
    transition: border-color var(--bpco-transition),
        box-shadow var(--bpco-transition),
        transform var(--bpco-transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 0 1.5px var(--bpco-border);
}

.bpco-swatch:hover:not(:disabled) {
    box-shadow: 0 0 0 2px var(--bpco-primary);
    transform: scale(1.08);
}

.bpco-swatch:active:not(:disabled) {
    transform: scale(0.95);
}

.bpco-swatch.is-selected {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--bpco-primary);
    transform: scale(1.05);
}

.bpco-swatch.is-disabled,
.bpco-swatch[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.bpco-swatch:focus-visible {
    outline: 2px solid var(--bpco-primary);
    outline-offset: 3px;
}

.bpco-swatch__label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1;
    pointer-events: none;
}

/* ── Variation Price ── */
.bpco-variation-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--bpco-text);
    margin-top: 0.25rem;
    display: none;
}

.bpco-variation-price ins {
    text-decoration: none;
    color: var(--bpco-primary);
}

.bpco-variation-price del {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--bpco-text-muted);
    margin-right: 0.375rem;
}

/* ── Stock Message ── */
.bpco-variation-stock {
    display: none;
}

.bpco-stock {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: var(--bpco-radius-full);
}

.bpco-stock--out {
    background: #fef2f2;
    color: var(--bpco-error);
}

.bpco-stock--in {
    background: #f0faf0;
    color: var(--bpco-success);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADD TO CART BUTTON — [bpco_add_to_cart]
   ═══════════════════════════════════════════════════════════════════════════ */

.bpco-atc-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bpco-atc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
    height: 48px;
    min-width: 160px;
    border: none;
    border-radius: var(--bpco-radius-md);
    background: var(--bpco-primary);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--bpco-font);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background var(--bpco-transition),
        box-shadow var(--bpco-transition),
        transform var(--bpco-transition),
        opacity var(--bpco-transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* Ripple effect on click */
.bpco-atc-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.bpco-atc-btn:active::after {
    background: rgba(255, 255, 255, 0.15);
}

.bpco-atc-btn:hover:not(:disabled):not(.is-loading) {
    background: var(--bpco-primary-hover);
    box-shadow: var(--bpco-shadow-md);
    transform: translateY(-1px);
}

.bpco-atc-btn:active:not(:disabled):not(.is-loading) {
    transform: translateY(0);
    box-shadow: var(--bpco-shadow-sm);
}

/* Disabled state */
.bpco-atc-btn.is-disabled,
.bpco-atc-btn[disabled]:not(.is-loading) {
    background: var(--bpco-text-faint);
    color: rgba(255, 255, 255, 0.7);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading state */
.bpco-atc-btn.is-loading {
    background: var(--bpco-primary-hover);
    cursor: wait;
    transform: none;
    pointer-events: none;
}

/* Added / success state */
.bpco-atc-btn.is-added {
    background: var(--bpco-success);
    cursor: default;
    pointer-events: none;
}

/* Focus ring */
.bpco-atc-btn:focus-visible {
    outline: 2px solid var(--bpco-primary);
    outline-offset: 3px;
}

/* ── Button inner elements ── */
.bpco-atc-btn__text {
    transition: opacity var(--bpco-transition);
    pointer-events: none;
}

.bpco-atc-btn__spinner,
.bpco-atc-btn__check {
    display: none;
    flex-shrink: 0;
    pointer-events: none;
}

.bpco-atc-btn.is-loading .bpco-atc-btn__spinner {
    display: flex;
}

.bpco-atc-btn.is-added .bpco-atc-btn__check {
    display: flex;
}

/* Spin animation for loading icon */
@keyframes bpco-spin {
    to {
        transform: rotate(360deg);
    }
}

.bpco-spin {
    animation: bpco-spin 0.7s linear infinite;
    display: block;
}

/* ── Notices ── */
.bpco-atc-notice {
    display: none;
    padding: 0.625rem 0.875rem;
    border-radius: var(--bpco-radius-md);
    font-size: 0.875rem;
    font-family: var(--bpco-font);
    font-weight: 500;
    line-height: 1.4;
}

.bpco-atc-notice.bpco-notice--error {
    background: var(--bpco-error-bg);
    color: var(--bpco-error);
    border: 1px solid rgba(161, 44, 44, 0.2);
}

.bpco-atc-notice.bpco-notice--success {
    background: #f0faf0;
    color: var(--bpco-success);
    border: 1px solid rgba(67, 122, 34, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile adjustments
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {

    .bpco-atc-btn {
        width: 100%;
        justify-content: center;
    }

    .bpco-qty {
        height: 48px;
    }

    .bpco-qty__btn {
        width: 48px;
    }

    .bpco-qty__input {
        width: 56px;
        font-size: 1rem;
    }

    .bpco-variation-group__options {
        gap: 0.5rem;
    }

    .bpco-variation-btn {
        min-height: 44px;
    }

    .bpco-swatch {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION — accessibility
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

    .bpco-qty,
    .bpco-qty__btn,
    .bpco-atc-btn,
    .bpco-variation-btn,
    .bpco-swatch {
        transition: none;
    }

    .bpco-spin {
        animation: none;
    }
}