/**
 * Billing on the website: the plan picker (signup form, Site Settings -> Plan), the Plan
 * tab, and the owner's grace / read-only banner. V3 tokens; logical properties (RTL);
 * dark mode below; works at 375px.
 *
 * @since 1.5.269
 */

/* ── Plan picker ─────────────────────────────────────────────────────────── */
.necudah-billing-plans {
    margin: 0 0 1.25rem;
}
/* Inside a signup form group the group's own gap is enough. */
.necudah-form-group > .necudah-billing-plans {
    margin-bottom: 0;
}
.necudah-billing-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.necudah-billing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 44px;
    padding: 14px 14px 12px;
    border: 2px solid var(--v3-border, rgba(99, 102, 241, 0.14));
    border-radius: 12px;
    background: var(--v3-glass, rgba(255, 255, 255, 0.55));
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
    text-align: start;
}
.necudah-billing-card input {
    position: absolute;
    opacity: 0;
    inset-inline-start: 0;
    inset-block-start: 0;
    width: 1px;
    height: 1px;
}
.necudah-billing-card:has(input:focus-visible) {
    outline: 2px solid var(--v3-accent, #585ce8);
    outline-offset: 2px;
}
.necudah-billing-card.is-selected {
    border-color: var(--v3-accent, #585ce8);
    background: var(--v3-icon-tint, rgba(99, 102, 241, 0.10));
}
.necudah-billing-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-card-price {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--v3-accent, #585ce8);
}
.necudah-billing-card-price small {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-card-who {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--v3-muted, #6b7280);
}

.necudah-billing-school {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--v3-border, rgba(99, 102, 241, 0.14));
    border-radius: 12px;
}
.necudah-billing-school[hidden] {
    display: none;
}
.necudah-billing-plans .necudah-billing-count label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-stepper {
    display: flex;
    align-items: stretch;
    max-width: 220px;
    border: 1px solid var(--v3-border, rgba(99, 102, 241, 0.18));
    border-radius: var(--v3-radius-btn, 11px);
    overflow: hidden;
    background: var(--v3-input-bg, rgba(255, 255, 255, 0.55));
}
.necudah-billing-step {
    flex: 0 0 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--v3-accent, #585ce8);
    cursor: pointer;
}
.necudah-billing-step:hover {
    background: var(--v3-icon-tint, rgba(99, 102, 241, 0.10));
}
.necudah-billing-step:focus-visible {
    outline: 2px solid var(--v3-accent, #585ce8);
    outline-offset: -2px;
}
.necudah-billing-stepper:focus-within {
    border-color: var(--v3-accent, #585ce8);
    box-shadow: 0 0 0 3px var(--v3-icon-tint, rgba(99, 102, 241, 0.10));
}
.necudah-billing-stepper input:focus {
    outline: none;
}
.necudah-billing-stepper input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    border-inline: 1px solid var(--v3-border, rgba(99, 102, 241, 0.14));
    background: transparent;
    text-align: center;
    /* 16px: smaller makes iPhone zoom the page on focus. */
    font-size: 16px;
    font-weight: 600;
    color: var(--v3-fg, #1e1b4b);
    -moz-appearance: textfield;
}
.necudah-billing-stepper input::-webkit-outer-spin-button,
.necudah-billing-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.necudah-billing-hint {
    margin-top: 6px;
    font-size: 0.74rem;
    line-height: 1.4;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-total {
    margin: 12px 0 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--v3-fg, #1e1b4b);
}

/* A plan fixed by an invitation (signup form). */
.necudah-billing-fixed {
    padding: 12px 14px;
    border: 1px solid var(--v3-border, rgba(99, 102, 241, 0.14));
    border-radius: 12px;
    background: var(--v3-icon-tint, rgba(99, 102, 241, 0.06));
    font-size: 0.9rem;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-fixed span {
    display: block;
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--v3-muted, #6b7280);
}

/* ── Site Settings -> Plan ──────────────────────────────────────────────── */
.necudah-billing-tab {
    max-width: 720px;
}
.necudah-billing-summary {
    margin: 0 0 1.25rem;
    padding: 14px 16px;
    border: 1px solid var(--v3-border, rgba(99, 102, 241, 0.14));
    border-radius: var(--v3-radius-card, 16px);
    background: var(--v3-glass, rgba(255, 255, 255, 0.55));
}
.necudah-billing-summary-plan {
    font-size: 1rem;
    font-weight: 700;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-summary .necudah-capacity-line {
    margin: 4px 0 0;
}
.necudah-billing-summary-line {
    margin-top: 4px;
    font-size: 0.84rem;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-summary-line.is-pending {
    color: var(--v3-fg-2, #312e81);
}
.necudah-billing-h {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-note,
.necudah-billing-fine {
    margin: 0 0 12px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-fine {
    margin-top: 14px;
}
.necudah-billing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.necudah-billing-actions .necudah-btn {
    min-height: 44px;
}
.necudah-billing-actions .necudah-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.necudah-billing-msg {
    min-height: 1.2em;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--v3-fg-2, #312e81);
}

/* ── Notices and the owner's banner ─────────────────────────────────────── */
.necudah-billing-notice {
    margin: 0 0 1rem;
    padding: 12px 14px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.08);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-notice.is-ok {
    border-color: rgba(5, 150, 105, 0.3);
    background: rgba(16, 185, 129, 0.10);
}
.necudah-billing-notice.is-warn {
    border-color: rgba(217, 119, 6, 0.35);
    background: rgba(245, 158, 11, 0.12);
}
.necudah-billing-notice.is-stop {
    border-color: rgba(220, 38, 38, 0.3);
    background: rgba(239, 68, 68, 0.10);
}
.necudah-billing-notice a {
    font-weight: 700;
    color: var(--v3-accent, #585ce8);
    white-space: nowrap;
}
.necudah-billing-banner {
    margin: 0 0 16px;
}
.necudah-billing-banner .necudah-billing-notice {
    margin: 0;
}

/* ── The signup page's wait after Stripe, and "Continue to payment" ────────── */
.necudah-billing-wait {
    padding: 28px 8px 12px;
    text-align: center;
}
.necudah-billing-wait .spinner {
    margin: 0 auto 12px;
    color: var(--v3-accent, #585ce8);
    animation: necudah-billing-spin 0.9s linear infinite;
}
@keyframes necudah-billing-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .necudah-billing-wait .spinner { animation: none; }
}
.necudah-billing-wait-title {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--v3-fg, #1e1b4b);
}
.necudah-billing-wait-text {
    max-width: 38ch;
    margin: 0 auto 18px;
    line-height: 1.55;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-resume-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.necudah-billing-aside {
    font-size: 0.8rem;
    color: var(--v3-muted, #6b7280);
}
.necudah-billing-gift {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--v3-muted, #6b7280);
}

/* ── Dark ───────────────────────────────────────────────────────────────── */
[data-theme="dark"] .necudah-billing-notice {
    color: var(--v3-fg, #f1f5f9);
}
[data-theme="dark"] .necudah-billing-notice.is-warn {
    background: rgba(245, 158, 11, 0.16);
}
[data-theme="dark"] .necudah-billing-notice.is-stop {
    background: rgba(239, 68, 68, 0.16);
}
[data-theme="dark"] .necudah-billing-summary-line.is-pending,
[data-theme="dark"] .necudah-billing-msg {
    color: var(--v3-fg-2, #c7d2fe);
}

/* ── Phone ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .necudah-billing-cards {
        grid-template-columns: 1fr;
    }
    .necudah-billing-school {
        grid-template-columns: 1fr;
    }
    .necudah-billing-stepper {
        max-width: none;
    }
    .necudah-billing-actions .necudah-btn,
    .necudah-billing-resume-row .necudah-btn {
        flex: 1 1 100%;
    }
}
