/* ═══════════════════════════════════════════════
   WC BOGOF - Product Page Form
   ═══════════════════════════════════════════════ */

.wc-bogof-form {
    margin: 1.5em 0;
    font-family: inherit;
}

/* ── Header ── */
.bogof-badge {
    display: inline-block;
    background: linear-gradient(135deg, #e65100, #ff9800);
    color: #fff;
    padding: 0.45em 1em;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.5em;
}

.bogof-subtitle {
    color: #666;
    font-size: 0.9em;
    margin: 0 0 1.2em;
}

/* ── Sections ── */
.bogof-section {
    margin-bottom: 1.2em;
}

.bogof-section-title {
    font-size: 0.95em;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.6em;
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.bogof-section-icon {
    font-size: 1.1em;
}

.bogof-section-free .bogof-section-title {
    color: #2e7d32;
}

/* ── Variation Rows ── */
.bogof-variations {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    margin-bottom: 0.75em;
}

.bogof-variation-row {
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 0.7em 0.85em;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 62px;
}

.bogof-variation-row.has-qty {
    border-color: #1976d2;
    background: #e3f2fd;
    box-shadow: 0 0 0 1px #1976d233;
}

.bogof-section-free .bogof-variation-row.has-qty {
    border-color: #4caf50;
    background: #f1f8e9;
    box-shadow: 0 0 0 1px #4caf5033;
}

.bogof-var-image {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.bogof-var-info {
    flex: 1;
    min-width: 0;
}

.bogof-var-label {
    font-weight: 600;
    font-size: 0.95em;
    margin: 0;
}

.bogof-var-meta {
    display: flex;
    gap: 0.75em;
    font-size: 0.8em;
    color: #888;
    margin-top: 0.1em;
}

.bogof-var-price {
    font-weight: 600;
    color: #333;
}

.bogof-var-free-label {
    font-weight: 700;
    color: #4caf50;
}

.bogof-var-sku {
    color: #aaa;
}

.bogof-var-subtotal {
    font-size: 0.8em;
    font-weight: 600;
    margin-top: 0.15em;
    visibility: hidden;
    height: 1.3em;
}

.bogof-section-paid .bogof-variation-row.has-qty .bogof-var-subtotal {
    visibility: visible;
    color: #1976d2;
}

.bogof-section-free .bogof-variation-row.has-qty .bogof-var-subtotal {
    visibility: visible;
    color: #4caf50;
}

/* ── Quantity Controls ── */
.bogof-qty-controls {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.bogof-qty-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: #333;
    user-select: none;
    line-height: 1;
    padding: 0;
}

.bogof-qty-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.bogof-qty-btn:active {
    background: #e0e0e0;
}

.bogof-qty-btn.minus {
    border-radius: 6px 0 0 6px;
}

.bogof-qty-btn.plus {
    border-radius: 0 6px 6px 0;
}

.bogof-qty-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.bogof-qty-input {
    width: 42px;
    height: 34px;
    border: 1px solid #ccc;
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 1em;
    font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
    margin: 0;
    padding: 0;
}

.bogof-qty-input::-webkit-outer-spin-button,
.bogof-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ── Progress Bars ── */
.bogof-progress {
    margin-bottom: 0.3em;
}

.progress-bar {
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.3em;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s;
    width: 0%;
}

.bogof-progress-paid .progress-fill {
    background: #ff9800;
}

.bogof-progress-paid .progress-fill.complete {
    background: #1976d2;
}

.bogof-progress-free .progress-fill {
    background: #ff9800;
}

.bogof-progress-free .progress-fill.complete {
    background: #4caf50;
}

.progress-fill.over {
    background: #f44336;
}

.progress-text {
    font-size: 0.8em;
    color: #666;
    text-align: right;
}

.progress-text .current-total {
    font-weight: 700;
    color: #333;
}

.progress-text.valid .current-total {
    color: #4caf50;
}

.progress-text.invalid .current-total {
    color: #f44336;
}

/* ── Footer ── */
.bogof-footer {
    border-top: 2px solid #eee;
    padding-top: 1em;
    margin-top: 0.5em;
}

.bogof-summary {
    margin-bottom: 1em;
}

.bogof-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    padding: 0.2em 0;
    color: #555;
}

.bogof-summary-free {
    color: #2e7d32;
    font-weight: 500;
}

/* ── Discount Breakdown ── */
.bogof-discount-block {
    margin: 0.5em 0;
    padding: 0.65em 0.75em;
    background: #f1f8e9;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
}

.bogof-discount-block .bogof-summary-row {
    font-size: 0.85em;
    padding: 0.15em 0;
}

.bogof-row-full .bogof-full-price {
    text-decoration: line-through;
    color: #999;
    font-weight: 400;
}

.bogof-row-savings {
    color: #2e7d32;
    font-weight: 600;
}

.bogof-row-perpiece {
    padding-top: 0.3em !important;
    margin-top: 0.2em;
    border-top: 1px dashed #c8e6c9;
}

.bogof-price-old {
    text-decoration: line-through;
    color: #999;
    font-weight: 400;
    margin-right: 0.4em;
}

.bogof-price-new {
    color: #2e7d32;
    font-weight: 700;
    font-size: 1.05em;
}

.bogof-summary-total {
    border-top: 1px solid #eee;
    padding-top: 0.5em;
    margin-top: 0.3em;
    font-size: 1.15em;
    font-weight: 700;
    color: #333;
}

/* ── Add to Cart Button ── */
#bogof-add-to-cart {
    width: 100%;
    padding: 0.85em;
    font-size: 1em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: opacity 0.2s, background-color 0.2s;
}

#bogof-add-to-cart.disabled,
#bogof-add-to-cart:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#bogof-add-to-cart.loading {
    pointer-events: none;
    position: relative;
}

#bogof-add-to-cart.loading::after {
    content: '';
    position: absolute;
    right: 1em;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bogof-spin 0.6s linear infinite;
}

@keyframes bogof-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ── Messages ── */
.bogof-message {
    margin-top: 0.75em;
    padding: 0.6em 0.85em;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
}

.bogof-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.bogof-message.error {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .bogof-variation-row {
        flex-wrap: wrap;
        gap: 0.5em;
    }

    .bogof-var-image {
        width: 40px;
        height: 40px;
    }

    .bogof-var-info {
        flex: 1 1 calc(100% - 56px);
    }

    .bogof-qty-controls {
        margin-left: auto;
    }
}
