/* Checkout Paid Trial — based on checkoutv4 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --ig-blue: #0095F6;
    --ig-blue-dark: #0081d6;
    --text-primary: #1C1C1E;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;
    --divider: #e5e5ea;
    --bg: #ffffff;
    --bg-secondary: #f2f2f7;
    --card-bg: #ffffff;
    --green: #34C759;
    --error: #ff3b30;
    --input-bg: #f2f2f7;
    --input-border: #e5e5ea;
    --input-focus: #0095F6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --trial-accent: #8B5CF6;
}

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: -apple-system, "SF Pro Display", "SF Pro Text", BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    line-height: 1.5;
}

.checkout-wrap {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.checkout-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}

.checkout-header .header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.trial-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.step.active {
    background: var(--ig-blue);
    border-color: var(--ig-blue);
    color: white;
}

.step.completed {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.step-divider {
    width: 24px;
    height: 2px;
    background: var(--divider);
    transition: background 0.2s ease;
}

.step-divider.completed {
    background: var(--green);
}

/* Highlight */
.highlight {
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Main */
.checkout-main {
    flex: 1;
    padding: 24px 20px 32px;
}

.step-container {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step-container.active {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-content { order: 0; }
.order-summary { order: 1; position: static; }

.step-header { margin-bottom: 20px; }

.step-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.step-header p {
    font-size: 15px;
    color: var(--text-secondary);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--ig-blue);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 12px;
    font-family: inherit;
    transition: opacity 0.15s ease;
}

.back-btn:hover { opacity: 0.8; }
.back-btn:active { opacity: 0.7; }

/* Form */
.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder { color: var(--text-tertiary); }

.form-group input:focus {
    outline: none;
    border-color: var(--ig-blue);
    box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.15);
}

.form-group.invalid input {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
}

.form-group.valid input {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.12);
}

.field-error {
    font-size: 13px;
    color: var(--error);
    line-height: 1.25;
    min-height: 0;
}

.input-wrapper {
    position: relative;
}

.input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.input-wrapper input {
    padding-left: 44px;
    padding-right: 40px;
}

/* Username validation status icon */
.username-status {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.username-status .spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid var(--divider);
    border-top-color: var(--ig-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Avatar swapped into the input prefix position */
img.ig-prefix-avatar {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--divider);
    pointer-events: none;
    /* subtle fade-in */
    animation: fadeIn 0.25s ease;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Profile Preview */
.profile-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(52, 199, 89, 0.07);
    border: 1px solid rgba(52, 199, 89, 0.3);
    border-radius: 10px;
    animation: fadeIn 0.3s ease;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--divider);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

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

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-handle {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-check {
    flex-shrink: 0;
}

/* Card inputs */
.card-input-wrapper {
    position: relative;
}

.card-input-wrapper input {
    padding-right: 56px;
}

.card-icons {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.card-icon {
    height: 18px;
    width: auto;
    object-fit: contain;
    opacity: 0.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s;
    border: none;
    text-decoration: none;
    position: relative;
}

.btn-primary {
    background: var(--ig-blue);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) { background: var(--ig-blue-dark); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-trial-pay {
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
}

.btn-trial-pay:hover:not(:disabled) {
    background: linear-gradient(135deg, #7C3AED 0%, #4F46E5 100%);
}

.btn-primary.loading span { opacity: 0; }

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.step1-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--divider);
}

.secure-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.secure-notice svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.trial-mini-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.terms-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 4px;
    line-height: 1.5;
}

.terms-text a {
    color: var(--ig-blue);
    text-decoration: none;
}

.terms-text a:hover { text-decoration: underline; }

/* Order Summary card */
.summary-card {
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.trial-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 20px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.summary-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
}

.package-details { margin-bottom: 12px; }

.package-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.package-username {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.package-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--trial-accent);
    margin-bottom: 2px;
}

.package-price .per-month {
    font-weight: 500;
    color: var(--text-tertiary);
    font-size: 0.75em;
}

.package-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.summary-divider {
    height: 1px;
    background: var(--divider);
    margin: 12px 0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.summary-row.total {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-primary);
}

.summary-row .price { color: var(--text-primary); }

.free-tag {
    color: var(--green) !important;
    font-weight: 700;
}

.features-list {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.feature svg { flex-shrink: 0; }

.rebill-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--divider);
    font-size: 12px;
    color: var(--text-tertiary);
}

.trial-bullets {
    list-style: none;
    padding-left: 0;
    margin-top: 16px;
    margin-bottom: 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trial-bullets li {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 3DS Modal */
.three-ds-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.three-ds-modal.active { display: flex; }

.three-ds-content {
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.three-ds-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
    color: var(--text-primary);
}

.three-ds-content iframe {
    width: 100%;
    height: 420px;
    border: none;
    border-radius: 10px;
    background: #fff;
}

/* ─── Success screen (same as checkouttrial) ─── */
.success-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    min-height: calc(100vh - 60px);
}

.success-screen.visible { display: flex; }

.success-icon {
    width: 80px;
    height: 80px;
    background: #f0fdf4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes successPop {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.success-icon svg {
    animation: checkDraw 0.4s ease 0.3s both;
}

@keyframes checkDraw {
    from { stroke-dashoffset: 60; opacity: 0; }
    to { stroke-dashoffset: 0; opacity: 1; }
}

.success-screen h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 10px;
}

.success-screen .success-sub {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 320px;
    margin: 0 auto 8px;
    line-height: 1.5;
}

.success-username-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    color: #16a34a;
    font-weight: 600;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 20px;
    margin: 12px 0 20px;
    border: 1px solid #bbf7d0;
}

.success-eta {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    max-width: 320px;
    border: 1px solid var(--divider);
}

.success-eta strong { color: var(--text-primary); }

.success-next {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 320px;
    margin: 0 auto 24px;
    line-height: 1.5;
}

.success-next strong { color: var(--text-primary); }
.success-next a { color: var(--trial-accent, var(--ig-blue)); text-decoration: none; }
.success-next a:hover { text-decoration: underline; }

.btn-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ig-blue);
    color: white;
    text-decoration: none;
    border-radius: 14px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s ease;
}

.btn-home:hover { background: var(--ig-blue-dark, #0081d6); }

/* Responsive */
@media (min-width: 640px) {
    .checkout-wrap { max-width: 900px; }

    .step-container.active {
        display: grid;
        grid-template-columns: 1fr 320px;
        gap: 32px;
        align-items: start;
    }

    .step-content { order: 0; }

    .order-summary {
        order: 0;
        position: sticky;
        top: 80px;
    }
}

@media (max-width: 480px) {
    .checkout-main { padding: 20px 16px 28px; }
    .step-header h1 { font-size: 22px; }
    .form-group input { font-size: 16px; }
    .step { width: 26px; height: 26px; font-size: 12px; }
    .step-divider { width: 18px; }
}
