/* ============================================
   COMPOXER SUBSCRIPTION PAGE  v3
   Two-view dynamic flow
   ============================================ */

html:has(.subscription-page),
html:has(.subscription-page) body {
    height: auto !important;
    overflow: auto !important;
    overflow-x: hidden !important;
}

.subscription-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
}

.subscription-page .brand-header {
    left: 0 !important;
    z-index: 300;
}

.subscription-main {
    flex: 1;
    padding-top: 96px;
    padding-bottom: 80px;
}

/* ─── View transitions ──────────────────────── */
.sub-view {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sub-view--hidden {
    display: none;
}

.sub-view--exit {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.sub-view--enter {
    opacity: 0;
    transform: translateY(10px);
}

/* ─── No-plan hero ──────────────────────────── */
.sub-noplan {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 24px;
    text-align: center;
}

.sub-noplan.hidden { display: none; }

.sub-noplan-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: rgba(255, 255, 255, 0.5);
}

.sub-noplan-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.sub-noplan-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.6;
    margin: 0 0 32px;
}

.sub-noplan-hint {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.3);
    margin: 12px 0 0;
}

/* ─── Primary CTA button ────────────────────── */
.sub-cta-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(10, 132, 255, 0.25);
}

.sub-cta-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(10, 132, 255, 0.35);
}

.sub-cta-primary:active { transform: translateY(0); }

.sub-cta-change {
    width: 100%;
    justify-content: center;
    margin-top: 24px;
    padding: 13px 24px;
    font-size: 0.9rem;
}

/* ─── Current plan card ─────────────────────── */
.sub-current {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 24px;
}

.sub-current.hidden { display: none; }

.sub-current-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 28px 28px 24px;
}

.sub-current-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.sub-current-label {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    display: block;
    margin-bottom: 4px;
}

.sub-current-plan-name {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.sub-current-badge {
    padding: 5px 13px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #34c759;
    background: rgba(52, 199, 89, 0.12);
    border: 1px solid rgba(52, 199, 89, 0.25);
    border-radius: 100px;
}

/* ─── Usage bar ─────────────────────────────── */
.sub-usage { margin-bottom: 20px; }

.sub-usage-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.sub-usage-label {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.5);
}

.sub-usage-count {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 500;
    color: #ffffff;
}

.sub-usage-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    overflow: hidden;
}

.sub-usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #34c759 0%, #30d158 100%);
    border-radius: 100px;
    transition: width 0.8s ease;
}

.sub-usage-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

.sub-usage-remaining {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
}

.sub-usage-resets {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.3);
}

/* ─── Current plan details ──────────────────── */
.sub-current-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 14px;
}

.sub-detail-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.65);
}

.sub-detail-item svg { color: #34c759; flex-shrink: 0; }

.sub-current-note {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.3);
    margin: 0 0 18px;
    line-height: 1.5;
}

/* ─── Auto-renew toggle ─────────────────────── */
.sub-autorenew {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sub-autorenew-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sub-autorenew-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.sub-autorenew-desc {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.38);
    line-height: 1.4;
}

.sub-autorenew-desc--off { color: rgba(255, 149, 0, 0.7); }

.sub-autorenew-toggle {
    flex-shrink: 0;
    position: relative;
    width: 44px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    padding: 0;
}

.sub-autorenew-toggle.active {
    background: #34c759;
    border-color: #34c759;
}

.sub-autorenew-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.sub-autorenew-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.sub-autorenew-toggle.active .sub-autorenew-toggle-knob { transform: translateX(18px); }

/* ─── Plans view header ─────────────────────── */
.sub-plans-header {
    max-width: 1000px;
    margin: 0 auto 36px;
    padding: 0 24px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.sub-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-family: var(--font-primary);
    font-size: 0.84rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 4px;
}

.sub-back-btn:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.07);
}

.sub-plans-heading { flex: 1; }

.sub-plans-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.sub-plans-subtitle {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    line-height: 1.5;
}

/* ─── Plans grid ────────────────────────────── */
.sub-plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ─── Plan card ─────────────────────────────── */
.sub-plan-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.sub-plan-card:hover {
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
}

.sub-plan-featured {
    background: linear-gradient(135deg, rgba(10,132,255,0.08) 0%, rgba(94,92,230,0.06) 100%);
    border-color: rgba(10, 132, 255, 0.25);
}

.sub-plan-featured:hover { border-color: rgba(10, 132, 255, 0.4); }

.sub-plan-current {
    border-color: rgba(52, 199, 89, 0.4);
    background: rgba(52, 199, 89, 0.04);
}

.sub-plan-upgrade { border-color: rgba(10, 132, 255, 0.2); }
.sub-plan-upgrade:hover { border-color: rgba(10, 132, 255, 0.4); }

.sub-plan-locked {
    opacity: 0.38;
    pointer-events: none;
}

.sub-plan-locked:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.08);
}

.sub-plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 14px;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0a84ff;
    background: rgba(10, 132, 255, 0.15);
    border: 1px solid rgba(10, 132, 255, 0.3);
    border-radius: 100px;
    white-space: nowrap;
}

.sub-plan-header {
    text-align: center;
    margin-bottom: 24px;
}

.sub-plan-name {
    font-family: var(--font-primary);
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 12px;
}

.sub-plan-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
}

.sub-plan-amount {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: #ffffff;
}

.sub-plan-period {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.4);
}

.sub-plan-credits {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

/* ─── Plan features ─────────────────────────── */
.sub-plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    flex: 1;
}

.sub-plan-features li {
    position: relative;
    padding-left: 20px;
    font-size: 0.83rem;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.5;
    margin-bottom: 9px;
}

.sub-plan-features li::before {
    content: '';
    position: absolute;
    left: 0; top: 5px;
    width: 12px; height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2334c759' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

.sub-plan-best {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    margin: 0 0 18px;
}

/* ─── Plan CTA ──────────────────────────────── */
.sub-plan-cta {
    width: 100%;
    padding: 13px 20px;
    font-family: var(--font-primary);
    font-size: 0.88rem;
    font-weight: 600;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sub-plan-cta:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.22);
}

.sub-plan-cta:disabled { opacity: 0.45; cursor: not-allowed; }

.sub-plan-cta-featured {
    background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
    border-color: transparent;
}

.sub-plan-cta-featured:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(10, 132, 255, 0.3);
}

/* ─── FAQ ───────────────────────────────────── */
.sub-faq {
    max-width: 800px;
    margin: 64px auto 0;
    padding: 0 24px;
}

.sub-faq-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    margin: 0 0 28px;
}

.sub-faq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.sub-faq-item {
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.sub-faq-item h4 {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 8px;
}

.sub-faq-item p {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.6;
    margin: 0;
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 900px) {
    .sub-plans-grid {
        grid-template-columns: 1fr;
        max-width: 420px;
    }
    .sub-plan-featured { order: -1; }
    .sub-plans-header {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .subscription-main {
        padding-top: 70px;
        padding-bottom: 60px;
        padding-bottom: max(60px, env(safe-area-inset-bottom));
    }

    .sub-noplan {
        padding: 24px 16px;
    }

    .sub-current {
        padding: 0 16px;
    }

    .sub-plans-grid {
        padding: 0 16px;
    }

    .sub-faq {
        padding: 0 16px;
        margin-top: 48px;
    }

    .sub-plan-cta {
        min-height: 48px;
        font-size: 0.9rem;
    }

    .sub-cta-primary {
        min-height: 48px;
        width: 100%;
        justify-content: center;
    }

    .sub-back-btn {
        display: none;
    }

    .sub-autorenew-toggle {
        width: 50px;
        height: 30px;
    }

    .sub-autorenew-toggle-knob {
        width: 22px;
        height: 22px;
    }

    .sub-autorenew-toggle.active .sub-autorenew-toggle-knob {
        transform: translateX(20px);
    }
}

@media (max-width: 640px) {
    .subscription-main {
        padding-top: 62px;
    }

    .sub-noplan-title { font-size: 1.5rem; }
    .sub-noplan-subtitle { font-size: 0.92rem; }
    .sub-current-card { padding: 20px 16px; }
    .sub-current-plan-name { font-size: 1.4rem; }
    .sub-faq-grid { grid-template-columns: 1fr; }
    .sub-plans-title { font-size: 1.3rem; }
    .sub-plans-subtitle { font-size: 0.85rem; }

    .sub-plan-card {
        padding: 24px 18px;
    }

    .sub-plan-amount {
        font-size: 1.8rem;
    }

    .sub-plan-features li {
        font-size: 0.82rem;
    }

    .sub-cta-primary {
        padding: 14px 24px;
        font-size: 0.9rem;
    }

    .sub-autorenew {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .sub-autorenew-toggle {
        align-self: flex-start;
    }

    .sub-detail-item {
        font-size: 0.78rem;
    }

    .sub-current-details {
        gap: 8px 16px;
    }

    .sub-faq-item {
        padding: 16px 18px;
    }

    .sub-faq-item h4 {
        font-size: 0.85rem;
    }

    .sub-faq-item p {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .sub-noplan-title {
        font-size: 1.35rem;
    }

    .sub-noplan-subtitle {
        font-size: 0.85rem;
    }

    .sub-current-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .sub-plan-card {
        padding: 20px 16px;
    }

    .sub-plan-amount {
        font-size: 1.6rem;
    }

    .sub-plan-features li {
        font-size: 0.8rem;
    }

    .sub-usage-count {
        font-size: 0.82rem;
    }

    .sub-faq-item {
        padding: 14px 14px;
    }
}

/* ── Early Access Modal ─────────────────────────────────────── */
.early-access-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.early-access-modal {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 400px;
    text-align: center;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.early-access-modal-icon {
    color: #fbbf24;
    margin-bottom: 20px;
}

.early-access-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
}

.early-access-modal-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 28px;
}

.early-access-modal-close {
    padding: 14px 32px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.early-access-modal-close:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.3);
}
