/* ============================================================
   Custom Product Checkout — style.css
   ============================================================ */

/* ── Reset / base ────────────────────────────────────────── */
.cpc-wrapper *,
.cpc-wrapper *::before,
.cpc-wrapper *::after {
    box-sizing: border-box;
}

.cpc-wrapper {
    --cpc-primary:      #1a6b5e;
    --cpc-primary-dark: #134f46;
    --cpc-accent:       #e6f4f1;
    --cpc-border:       #e4e8ec;
    --cpc-radius:       14px;
    --cpc-shadow:       0 2px 16px rgba(0,0,0,.07);
    --cpc-text:         #1a1f2e;
    --cpc-muted:        #6b7280;
    --cpc-error:        #d93025;
    --cpc-success:      #1a6b5e;

    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 32px;
    align-items: start;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--cpc-text);
    padding: 24px 0;
}

/* ── Section title ────────────────────────────────────────── */
.cpc-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--cpc-text);
}

/* ── Cards ────────────────────────────────────────────────── */
.cpc-card {
    background: #fff;
    border: 1px solid var(--cpc-border);
    border-radius: var(--cpc-radius);
    padding: 24px;
    box-shadow: var(--cpc-shadow);
    margin-bottom: 16px;
    transition: box-shadow .2s;
}
.cpc-card:hover {
    box-shadow: 0 4px 24px rgba(0,0,0,.1);
}
.cpc-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 18px;
    color: var(--cpc-text);
}

/* ── Product cards ────────────────────────────────────────── */
.cpc-product-card {
    background: #fff;
    border-radius: var(--cpc-radius);
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: var(--cpc-shadow);
    transition: box-shadow .3s ease, transform .3s ease, background .3s ease;
    will-change: transform;
    position: relative;
    overflow: hidden;
}

/* Shine sweep on hover */
.cpc-product-card::before {
    content: '';
    position: absolute;
    top: 0; left: -75%;
    width: 50%; height: 100%;
    background: linear-gradient(
        120deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.45) 50%,
        rgba(255,255,255,0) 100%
    );
    transform: skewX(-20deg);
    transition: left .55s ease;
    pointer-events: none;
    z-index: 1;
}
.cpc-product-card:hover::before {
    left: 130%;
}

.cpc-product-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 8px 32px rgba(26,107,94,.18), 0 2px 8px rgba(0,0,0,.06);
}

.cpc-product-card--active {
    outline: 2px solid var(--cpc-primary);
    background: linear-gradient(135deg, #f0faf8 0%, #ffffff 60%);
    box-shadow: 0 4px 24px rgba(26,107,94,.15);
}

.cpc-product-card--active:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 10px 36px rgba(26,107,94,.22), 0 2px 8px rgba(0,0,0,.06);
}

.cpc-product-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}
.cpc-product-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}
.cpc-product-desc {
    font-size: .875rem;
    color: var(--cpc-muted);
    margin: 0 0 14px;
    line-height: 1.5;
}

/* ── Badges ──────────────────────────────────────────────── */
.cpc-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.cpc-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 10px;
}
.cpc-badge--purity {
    background: #e6f4f1;
    color: var(--cpc-primary);
    border: 1px solid #b2dfd6;
}
.cpc-badge--popular {
    background: var(--cpc-primary);
    color: #fff;
}

/* ── Form fields ─────────────────────────────────────────── */
.cpc-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 140px;
}
.cpc-field label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--cpc-text);
}
.cpc-field label span {
    color: var(--cpc-error);
}
.cpc-field input,
.cpc-field select,
.cpc-select-wrap select {
    height: 42px;
    border: 1.5px solid var(--cpc-border);
    border-radius: 8px;
    padding: 0 12px;
    font-size: .875rem;
    color: var(--cpc-text);
    background: #fff;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
    appearance: none;
}
.cpc-field input:focus,
.cpc-field select:focus,
.cpc-select-wrap select:focus {
    border-color: var(--cpc-primary);
    box-shadow: 0 0 0 3px rgba(26,107,94,.12);
}
.cpc-field input.cpc-invalid {
    border-color: var(--cpc-error);
}
.cpc-field--full {
    flex: 1 1 100%;
}
.cpc-form-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.cpc-field { margin-bottom: 0; }

/* Select wrapper with arrow */
.cpc-select-wrap {
    position: relative;
    margin-bottom: 14px;
}
.cpc-select-wrap::after {
    content: "";
    pointer-events: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-top-color: var(--cpc-muted);
    border-bottom: none;
    margin-top: 3px;
}
.cpc-select-wrap select { padding-right: 32px; }

/* ── Quantity controls ───────────────────────────────────── */
.cpc-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
}
.cpc-qty-ctrl {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--cpc-border);
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}
.cpc-qty-btn {
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--cpc-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
    user-select: none;
}
.cpc-qty-btn:hover {
    background: var(--cpc-accent);
    color: var(--cpc-primary);
}
.cpc-qty-btn:active {
    transform: scale(.9);
}
.cpc-qty-input {
    width: 48px;
    text-align: center;
    border: none;
    border-left: 1.5px solid var(--cpc-border);
    border-right: 1.5px solid var(--cpc-border);
    background: #fff;
    font-size: .95rem;
    font-weight: 700;
    outline: none;
    height: 38px;
    -moz-appearance: textfield;
}
.cpc-qty-input::-webkit-inner-spin-button,
.cpc-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.cpc-product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cpc-primary);
}

/* ── Qty animate ─────────────────────────────────────────── */
@keyframes cpc-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}
.cpc-qty-pop {
    animation: cpc-pop .25s ease;
}

@keyframes cpc-card-activate {
    0%   { box-shadow: 0 0 0 0 rgba(26,107,94,.4); }
    70%  { box-shadow: 0 0 0 10px rgba(26,107,94,0); }
    100% { box-shadow: 0 4px 24px rgba(26,107,94,.15); }
}
.cpc-product-card--active {
    animation: cpc-card-activate .5s ease forwards;
}

/* ── Order Summary ───────────────────────────────────────── */
.cpc-empty-msg {
    color: var(--cpc-muted);
    font-size: .875rem;
    margin: 0;
    padding: 6px 0;
}
.cpc-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--cpc-border);
    font-size: .875rem;
    animation: cpc-fade-in .3s ease;
}
.cpc-summary-item:last-child { border-bottom: none; }
.cpc-summary-item__name {
    flex: 1;
    font-weight: 600;
    line-height: 1.4;
}
.cpc-summary-item__meta {
    color: var(--cpc-muted);
    font-size: .8rem;
}
.cpc-summary-item__price {
    font-weight: 700;
    white-space: nowrap;
    color: var(--cpc-primary);
}

.cpc-total {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
    padding-top: 14px;
    margin-top: 4px;
    border-top: 2px solid var(--cpc-border);
}

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

/* ── Buttons ─────────────────────────────────────────────── */
.cpc-btn {
    width: 100%;
    height: 50px;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .2s, opacity .2s, transform .1s;
    margin-top: 16px;
}
.cpc-btn:active { transform: scale(.98); }

.cpc-btn--primary {
    background: var(--cpc-primary);
    color: #fff;
}
.cpc-btn--primary:hover {
    background: var(--cpc-primary-dark);
}
.cpc-btn--primary:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.cpc-btn--ghost {
    background: transparent;
    color: var(--cpc-text);
    border: none;
    margin-top: 10px;
    text-decoration: none !important;
    cursor: pointer;
}
.cpc-btn--ghost:hover {
    background: #BBFAFA;
    text-decoration: none !important;
}

/* ── Spinner ─────────────────────────────────────────────── */
@keyframes cpc-spin {
    to { transform: rotate(360deg); }
}
.cpc-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cpc-spin .7s linear infinite;
}

/* ── Error message ───────────────────────────────────────── */
.cpc-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--cpc-error);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .875rem;
    margin-top: 10px;
}

/* ── Cart loading state ──────────────────────────────────── */
.cpc-cart-loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity .2s;
}

/* ── Right panel ─────────────────────────────────────────── */
.cpc-panel {
    position: sticky;
    top: 24px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
    .cpc-wrapper {
        grid-template-columns: 1fr;
    }
    .cpc-panel {
        position: static;
    }
}
@media (max-width: 480px) {
    .cpc-form-row {
        flex-direction: column;
    }
    .cpc-field { min-width: 100%; }
    .cpc-card { padding: 16px; }
    .cpc-product-card { padding: 16px; }
}

/* ── Summary items (name x qty on one line) ───────────────── */
.cpc-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: .9rem;
    animation: cpc-fade-in .3s ease;
}
.cpc-summary-item:not(:last-child) {
    border-bottom: 1px solid var(--cpc-border);
}
.cpc-summary-item__name {
    flex: 1;
    font-weight: 500;
    color: var(--cpc-text);
}
.cpc-summary-item__price {
    font-weight: 600;
    color: var(--cpc-text);
    white-space: nowrap;
    margin-left: 12px;
}

/* ── Totals breakdown ─────────────────────────────────────── */
#cpc-summary-totals {
    margin-top: 14px;
    border-top: 1px solid var(--cpc-border);
    padding-top: 10px;
}
.cpc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .875rem;
    padding: 6px 0;
    color: var(--cpc-text);
}
.cpc-total-row--subtotal {
    font-weight: 500;
}
.cpc-shipping-row {
    color: var(--cpc-text);
    font-size: .875rem;
}
.cpc-discount-row { color: #059669; }
.cpc-discount-value { font-weight: 700; }
.cpc-free-ship {
    color: #059669;
    font-weight: 700;
}
.cpc-total--final {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 1.05rem;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1.5px solid var(--cpc-border);
    color: var(--cpc-text);
}

/* ── Applied coupon tags ──────────────────────────────────── */
#cpc-applied-coupons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 2px;
}
.cpc-coupon-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--cpc-accent);
    border: 1px solid #b2dfd6;
    color: var(--cpc-primary);
    border-radius: 20px;
    padding: 3px 8px 3px 7px;
    font-size: .75rem;
    font-weight: 600;
    animation: cpc-fade-in .25s ease;
}
.cpc-coupon-tag__remove {
    background: none;
    border: none;
    color: var(--cpc-primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    opacity: .7;
    transition: opacity .15s;
}
.cpc-coupon-tag__remove:hover { opacity: 1; }

/* ── Free shipping progress bar (inline between rows) ─────── */
#cpc-free-shipping-bar {
    padding: 6px 0 4px;
}
.cpc-shipping-bar__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.cpc-shipping-bar__label {
    font-size: .78rem;
    color: var(--cpc-muted);
}
.cpc-shipping-bar__label--free {
    color: #059669;
    font-weight: 600;
}
.cpc-shipping-bar__remaining {
    font-size: .78rem;
    color: var(--cpc-muted);
}
.cpc-shipping-bar__track {
    height: 5px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}
.cpc-shipping-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cpc-primary), #34d399);
    border-radius: 10px;
    transition: width .5s cubic-bezier(.4,0,.2,1);
    min-width: 4px;
}

/* ── Coupon row at bottom ─────────────────────────────────── */
.cpc-coupon-wrap {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--cpc-border);
}
.cpc-coupon-row {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--cpc-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.cpc-coupon-row:focus-within {
    border-color: var(--cpc-primary);
    box-shadow: 0 0 0 3px rgba(26,107,94,.08);
}
.cpc-coupon-row input {
    flex: 1;
    height: 42px;
    border: none;
    padding: 0 14px;
    font-size: .875rem;
    color: var(--cpc-text);
    outline: none;
    background: transparent;
}
.cpc-coupon-row input::placeholder { color: #adb5bd; }
.cpc-coupon-row button {
    height: 42px;
    padding: 0 18px;
    background: transparent;
    color: var(--cpc-text);
    border: none;
    border-left: 1.5px solid var(--cpc-border);
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.cpc-coupon-row button:hover {
    background: var(--cpc-accent);
    color: var(--cpc-primary);
}
.cpc-coupon-row button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Coupon message ───────────────────────────────────────── */
.cpc-coupon-msg {
    font-size: .8rem;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 6px;
}
.cpc-coupon-msg--success { background: #ecfdf5; color: #065f46; }
.cpc-coupon-msg--error   { background: #fef2f2; color: var(--cpc-error); }
.cpc-coupon-msg--info    { background: #eff6ff; color: #1d4ed8; }
