/* Subscriptions panel — responsive plan grid + PWA-friendly mobile sheet (Phase 1.5) */

.subscr-plans-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.subscr-plan-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#subscrPlanFeatures.subscr-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.subscr-setup-alert {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Org sections above Current Plan — My Account card style (scoped) */
#subscriptionsPanel #subscrOrgContextSection,
#subscriptionsPanel #subscrJoinOrgSection,
#subscriptionsPanel #subscrOrgInviteSection,
#subscriptionsPanel #subscrOrgStoresSection {
    border: 2px solid #f9d71c;
    border-radius: 12px;
    padding: 20px;
    background: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

#subscriptionsPanel #subscrOrgContextSection:hover,
#subscriptionsPanel #subscrJoinOrgSection:hover,
#subscriptionsPanel #subscrOrgInviteSection:hover,
#subscriptionsPanel #subscrOrgStoresSection:hover {
    box-shadow: 0 4px 20px rgba(249, 215, 28, 0.2);
}

#subscriptionsPanel #subscrOrgContextSection h3,
#subscriptionsPanel #subscrJoinOrgSection h3,
#subscriptionsPanel #subscrOrgInviteSection h3,
#subscriptionsPanel #subscrOrgStoresSection h3 {
    color: #212529 !important;
    border-bottom: 1px solid rgba(249, 215, 28, 0.35);
    padding-bottom: 0.75rem;
}

.subscr-setup-plan-option:hover {
    border-color: #ffc107 !important;
}

/* Wizard + panel actions — override hero/global button styles (white-on-white invisible buttons) */
#subscriptionsPanel .subscr-setup-form .btn,
#subscriptionsPanel .subscr-invite-row .btn,
#subscriptionsPanel #subscrJoinOrgSection .btn,
#subscriptionsPanel #subscrOrgInviteSection .btn,
#subscriptionsPanel #subscrOrgStoresSection .btn {
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 44px;
    padding: 0.65rem 1.25rem;
    opacity: 1;
    visibility: visible;
}

#subscriptionsPanel .subscr-setup-form .btn-primary,
#subscriptionsPanel .subscr-invite-row .btn-primary,
#subscriptionsPanel #subscrJoinOrgSection .btn-primary,
#subscriptionsPanel #subscrOrgInviteSection .btn-primary,
#subscriptionsPanel #subscrOrgStoresSection .btn-primary {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #333;
    border: 2px solid #e0a800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#subscriptionsPanel .subscr-setup-form .btn-primary:hover:not(:disabled),
#subscriptionsPanel .subscr-invite-row .btn-primary:hover:not(:disabled),
#subscriptionsPanel #subscrJoinOrgSection .btn-primary:hover:not(:disabled),
#subscriptionsPanel #subscrOrgInviteSection .btn-primary:hover:not(:disabled),
#subscriptionsPanel #subscrOrgStoresSection .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e0a800, #c99600);
    color: #222;
    border-color: #c99600;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

#subscriptionsPanel .subscr-setup-form .btn-secondary,
#subscriptionsPanel .subscr-invite-row .btn-secondary,
#subscriptionsPanel #subscrJoinOrgSection .btn-secondary,
#subscriptionsPanel #subscrOrgInviteSection .btn-secondary,
#subscriptionsPanel #subscrOrgStoresSection .btn-secondary {
    background: #fff;
    color: #333;
    border: 2px solid #ffc107;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#subscriptionsPanel .subscr-setup-form .btn-secondary:hover:not(:disabled),
#subscriptionsPanel .subscr-invite-row .btn-secondary:hover:not(:disabled),
#subscriptionsPanel #subscrJoinOrgSection .btn-secondary:hover:not(:disabled),
#subscriptionsPanel #subscrOrgInviteSection .btn-secondary:hover:not(:disabled),
#subscriptionsPanel #subscrOrgStoresSection .btn-secondary:hover:not(:disabled) {
    background: #fff8e1;
    color: #222;
    border-color: #e0a800;
}

#subscriptionsPanel .subscr-setup-form .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

#subscriptionsPanel .subscr-wizard-pick-store,
#subscriptionsPanel .subscr-wizard-pick-org {
    color: #333;
}

#subscriptionsPanel .subscr-wizard-pick-store:hover,
#subscriptionsPanel .subscr-wizard-pick-org:hover {
    border-color: #ffc107 !important;
    background: #fffef5 !important;
}

/* Upgrade wizard footer — keep CTA centered in the plan card */
#subscrWizardNavFooter {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

/* Org step: Back + Complete upgrade sit in section 3 */
#subscrWizardOrgNav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

/* Upgrade wizard step pills — match Back / Next button styling */
.subscr-wizard-steps {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    width: 100%;
    max-width: none; /* match full-width Join an Organization section */
}

.subscr-wizard-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    border: 2px solid transparent;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.subscr-wizard-step.is-active {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #333;
    border-color: #e0a800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.subscr-wizard-step.is-complete {
    background: #fff;
    color: #333;
    border-color: #ffc107;
}

.subscr-wizard-step.is-upcoming {
    background: #f8f9fa;
    color: #888;
    border-color: #dee2e6;
    box-shadow: none;
}

.subscr-wizard-step-sep {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.25rem;
    color: #ccc;
    font-size: 1.1rem;
    font-weight: 600;
    user-select: none;
}

.subscr-wizard-step-sep::before {
    content: '›';
}

@media (max-width: 640px) {
    .subscr-wizard-steps {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .subscr-wizard-step {
        flex: 1 1 100%;
        text-align: center;
    }

    .subscr-wizard-step-sep {
        display: none;
    }
}

/* Tablet — 2 plan cards per row */
@media (max-width: 1024px) {
    .subscr-plans-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
}

/* Phone — stack cards; full-width scrollable sheet (PWA reference pattern) */
@media (max-width: 768px) {
    #subscriptionsPanel.settings-panel {
        align-items: flex-end;
        justify-content: center;
        padding:
            env(safe-area-inset-top, 0px)
            env(safe-area-inset-right, 0px)
            env(safe-area-inset-bottom, 0px)
            env(safe-area-inset-left, 0px);
    }

    #subscriptionsPanel .settings-container {
        width: 100%;
        max-width: 100%;
        max-height: min(94dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 0.5rem));
        border-radius: 16px 16px 0 0;
        margin: 0;
    }

    #subscriptionsPanel .settings-header {
        padding: 1rem 1.25rem 0.75rem;
        position: sticky;
        top: 0;
        z-index: 2;
        background: #fff;
    }

    #subscriptionsPanel .settings-content {
        padding: 1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    #subscriptionsPanel .setting-group h3,
    #subscriptionsPanel #subscrCurrentPlanSection > h3,
    #subscriptionsPanel #subscrChoosePlanSection > h3 {
        font-size: 1.25rem !important;
        margin-bottom: 1rem !important;
    }

    #subscriptionsPanel #subscrCurrentPlanSection,
    #subscriptionsPanel #subscrChoosePlanSection,
    #subscriptionsPanel #subscrPlanFeaturesSection,
    #subscriptionsPanel #subscrBillingSection {
        margin-bottom: 1.5rem !important;
    }

    #subscriptionsPanel .subscription-info {
        padding: 1.25rem !important;
    }

    #subscriptionsPanel #subscrPlanName {
        font-size: 1.35rem !important;
    }

    #subscriptionsPanel #subscrPlanPrice {
        font-size: 1.1rem !important;
        margin-bottom: 1rem !important;
    }

    .subscr-plans-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .subscr-plan-card {
        padding: 1.25rem 1rem !important;
    }

    #subscrPlanFeatures.subscr-features-grid {
        grid-template-columns: 1fr;
    }

    #subscriptionsPanel .subscr-select-plan,
    #subscriptionsPanel .subscr-contact-sales {
        font-size: 1rem !important;
        padding: 0.75rem !important;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    #subscriptionsPanel .settings-container {
        max-height: min(96dvh, calc(100dvh - env(safe-area-inset-top, 0px)));
        border-radius: 12px 12px 0 0;
    }
}

/* Phase 1.8a — simulated Stripe checkout modal */
.billing-checkout-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.billing-checkout-overlay.is-open {
    display: flex;
}

.billing-checkout-sheet {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 92dvh;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    padding: 1.5rem 1.5rem 1.25rem;
}

.billing-checkout-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.billing-checkout-header {
    margin-bottom: 1.25rem;
    padding-right: 2rem;
}

.billing-checkout-stripe-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #635bff;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.billing-checkout-header h3 {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
    color: #1a1f36;
}

.billing-checkout-current-plan {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    color: #495057;
}

.billing-checkout-plan-line {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #28a745;
}

.billing-checkout-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.billing-checkout-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #3c4257;
}

.billing-checkout-field input {
    width: 100%;
    box-sizing: border-box;
    font-weight: 400;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e0e6ed;
    border-radius: 6px;
    font-size: 1rem;
    background: #f7fafc;
}

.billing-checkout-field input:focus {
    outline: none;
    border-color: #635bff;
    box-shadow: 0 0 0 2px rgba(99, 91, 255, 0.15);
    background: #fff;
}

.billing-checkout-row {
    display: grid;
    grid-template-columns: 1fr 0.75fr;
    gap: 0.65rem;
}

.billing-checkout-error {
    margin: 0;
    font-size: 0.85rem;
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
}

.billing-checkout-pay-btn {
    width: 100%;
    margin-top: 0.25rem;
    background: #635bff !important;
    border-color: #635bff !important;
    color: #fff !important;
}

.billing-checkout-pay-btn:hover:not(:disabled) {
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #fff !important;
}

/* Contact sales placeholder (STRIPE_CHECKOUT_ENABLED = false) */
.billing-checkout-sales {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.billing-checkout-sales-lead {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: #495057;
}

.billing-checkout-sales-card {
    text-align: center;
    padding: 1.25rem 1rem;
    border-radius: 10px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
}

.billing-checkout-sales-heading {
    margin: 0 0 0.65rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1f36;
}

.billing-checkout-sales-email {
    display: inline-block;
    font-size: 1rem;
    font-weight: 600;
    color: #635bff;
    text-decoration: none;
}

.billing-checkout-sales-email:hover {
    text-decoration: underline;
    color: #4f46e5;
}

.billing-checkout-sales-close-btn {
    width: 100%;
    background: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #333 !important;
    font-weight: 700;
}

.billing-checkout-sales-close-btn:hover {
    background: #e0a800 !important;
    border-color: #e0a800 !important;
    color: #fff !important;
}

.subscr-wizard-payment-ok {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: none;
}

.subscr-org-created-sheet .billing-checkout-pay-btn {
    background: linear-gradient(135deg, #28a745, #1e7e34) !important;
    border-color: #1e7e34 !important;
}

#subscrWizardCreateOrgFields .btn-primary {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #333;
    border: 2px solid #e0a800;
}

#subscrWizardCreateOrgFields .btn-primary:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .billing-checkout-row {
        grid-template-columns: 1fr 1fr;
    }
}
