/* ============================================================
   CHECKOUT MODAL – AI's Top Sports Picks
   Supports Stripe Payment Element (Affirm / Klarna / Cards)
   ============================================================ */

/* ── Overlay ── */
#checkoutOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayFadeIn 0.25s ease;
}
#checkoutOverlay.open {
    display: flex;
}
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal Box ── */
.checkout-modal {
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px rgba(212,175,55,0.08);
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Modal Header ── */
.checkout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.checkout-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.checkout-header-logo {
    height: 38px;
    width: auto;
}
.checkout-header-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.checkout-header-title span {
    font-size: 0.75rem;
    color: #d4af37;
    font-weight: 500;
    display: block;
}
.checkout-close-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    color: #aaa;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.checkout-close-btn:hover {
    background: rgba(212,175,55,0.2);
    color: #d4af37;
}

/* ── Plan Summary Card ── */
.checkout-plan-summary {
    margin: 20px 28px 0;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.checkout-plan-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}
.checkout-plan-cycle {
    font-size: 0.78rem;
    color: #aaa;
    margin-top: 3px;
}
.checkout-plan-price {
    text-align: right;
    flex-shrink: 0;
}
.checkout-plan-price .amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: #d4af37;
    line-height: 1;
}
.checkout-plan-price .period {
    font-size: 0.72rem;
    color: #888;
}
.checkout-plan-price .original {
    font-size: 0.78rem;
    color: #666;
    text-decoration: line-through;
    display: block;
    margin-bottom: 2px;
}

/* ── BNPL Badges ── */
.checkout-bnpl {
    margin: 14px 28px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.checkout-bnpl-label {
    font-size: 0.72rem;
    color: #888;
    white-space: nowrap;
}
.bnpl-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #ccc;
    white-space: nowrap;
    transition: border-color 0.2s;
}
.bnpl-badge:hover { border-color: rgba(212,175,55,0.4); }
.bnpl-badge.affirm  { color: #4a4af4; border-color: rgba(74,74,244,0.3); }
.bnpl-badge.klarna  { color: #e94a8b; border-color: rgba(233,74,139,0.3); }
.bnpl-badge.card    { color: #6cbc8c; border-color: rgba(108,188,140,0.3); }

/* ── Stripe Payment Element Container ── */
.checkout-form-wrap {
    padding: 20px 28px 24px;
}
.checkout-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 12px;
    margin-top: 6px;
}

/* Stripe mount target */
#stripe-payment-element {
    min-height: 160px;
}

/* Email field */
.checkout-email-field {
    margin-bottom: 16px;
}
.checkout-email-field label {
    display: block;
    font-size: 0.78rem;
    color: #aaa;
    margin-bottom: 6px;
    font-weight: 500;
}
.checkout-email-field input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.checkout-email-field input:focus {
    border-color: rgba(212,175,55,0.6);
}
.checkout-email-field input::placeholder { color: #666; }

/* ── Submit Button ── */
.checkout-submit-btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #d4af37, #f5d060, #b8962e);
    color: #000;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.03em;
    margin-top: 20px;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}
.checkout-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(212,175,55,0.45);
}
.checkout-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}
.checkout-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.checkout-submit-btn .spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(0,0,0,0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}
.checkout-submit-btn.loading .spinner { display: block; }
.checkout-submit-btn.loading .btn-text-inner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error Message ── */
#checkout-error {
    color: #ff6b6b;
    font-size: 0.82rem;
    margin-top: 10px;
    min-height: 18px;
    display: none;
}
#checkout-error.visible { display: block; }

/* ── Success State ── */
.checkout-success {
    display: none;
    padding: 40px 28px;
    text-align: center;
}
.checkout-success.visible { display: block; }
.checkout-success-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}
.checkout-success h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #d4af37;
    margin-bottom: 10px;
}
.checkout-success p {
    color: #aaa;
    font-size: 0.92rem;
    line-height: 1.6;
}
.checkout-success .download-cta {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.checkout-success .store-badge {
    height: 42px;
    width: auto;
    border-radius: 8px;
    transition: transform 0.2s;
}
.checkout-success .store-badge:hover {
    transform: translateY(-2px);
}

/* ── Security Badge ── */
.checkout-security-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.7rem;
    color: #666;
    margin-top: 14px;
}
.checkout-security-note svg { flex-shrink: 0; }

/* ── Demo Mode Banner (remove when live) ── */
.checkout-demo-banner {
    background: rgba(212,175,55,0.12);
    border: 1px dashed rgba(212,175,55,0.4);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 0 28px 16px;
    font-size: 0.75rem;
    color: #d4af37;
    text-align: center;
    line-height: 1.5;
}
.checkout-demo-banner strong { color: #f5d060; }

/* ── Scrollbar ── */
.checkout-modal::-webkit-scrollbar { width: 5px; }
.checkout-modal::-webkit-scrollbar-track { background: transparent; }
.checkout-modal::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.3); border-radius: 10px; }

/* ── Promo Code ── */
.checkout-promo-row {
    margin-bottom: 16px;
}
.promo-toggle-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    color: #d4af37;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(212,175,55,0.4);
    transition: color 0.2s, text-decoration-color 0.2s;
}
.promo-toggle-link:hover {
    color: #f5d060;
    text-decoration-color: rgba(245,208,96,0.6);
}
.promo-input-wrap {
    display: none;
    margin-top: 10px;
    animation: promoSlideDown 0.22s ease;
}
.promo-input-wrap.open {
    display: block;
}
@keyframes promoSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.promo-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.promo-input-row input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-sizing: border-box;
}
.promo-input-row input:focus {
    border-color: rgba(212,175,55,0.6);
}
.promo-input-row input::placeholder {
    color: #555;
    text-transform: none;
    letter-spacing: 0;
}
.promo-input-row input.valid {
    border-color: rgba(108,188,140,0.7);
    background: rgba(108,188,140,0.08);
}
.promo-input-row input.invalid {
    border-color: rgba(255,107,107,0.6);
    background: rgba(255,107,107,0.06);
}
.promo-apply-btn {
    background: rgba(212,175,55,0.15);
    border: 1px solid rgba(212,175,55,0.4);
    color: #d4af37;
    border-radius: 10px;
    padding: 11px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.promo-apply-btn:hover {
    background: rgba(212,175,55,0.25);
    border-color: rgba(212,175,55,0.7);
    transform: translateY(-1px);
}
.promo-apply-btn:active {
    transform: translateY(0);
}
.promo-apply-btn.applied {
    background: rgba(108,188,140,0.2);
    border-color: rgba(108,188,140,0.5);
    color: #6cbc8c;
    cursor: default;
}
.promo-feedback {
    min-height: 18px;
    font-size: 0.78rem;
    margin-top: 6px;
    line-height: 1.4;
}
.promo-feedback.success {
    color: #6cbc8c;
}
.promo-feedback.error {
    color: #ff6b6b;
}

/* ── Promo Discount Badge (on plan summary) ── */
.promo-discount-badge {
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(108,188,140,0.15);
    border: 1px solid rgba(108,188,140,0.4);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #6cbc8c;
    letter-spacing: 0.04em;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes badgePop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .checkout-header { padding: 18px 18px 16px; }
    .checkout-plan-summary { margin: 16px 18px 0; }
    .checkout-bnpl { margin: 12px 18px 0; }
    .checkout-form-wrap { padding: 16px 18px 20px; }
    .checkout-demo-banner { margin: 0 18px 14px; }
    .checkout-plan-price .amount { font-size: 1.25rem; }
}

