/**
 * Billing Component Styles
 * Shared CSS for EchoBillingManager (client + admin contexts).
 * Extracted from app/billing.html inline styles + admin v2 additions.
 */

/* ==================== BILLING STATUS CARD ==================== */
.billing-status-card {
    padding: var(--v2-space-6);
}

.billing-plan {
    display: flex;
    align-items: center;
    gap: var(--v2-space-3);
    margin-bottom: var(--v2-space-5);
}

.billing-plan-name {
    font-size: var(--v2-text-xl);
    font-weight: 600;
    color: var(--v2-fg);
}

.billing-status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--v2-space-1);
    padding: 3px 10px;
    font-size: var(--v2-text-xs);
    font-weight: 500;
    border-radius: var(--v2-radius-full);
}

.billing-status-badge.status-active,
.billing-status-badge.status-trialing {
    background: var(--v2-success-bg);
    color: var(--v2-success-text);
}

.billing-status-badge.status-past_due {
    background: var(--v2-warning-bg);
    color: var(--v2-warning-text);
}

.billing-status-badge.status-canceled,
.billing-status-badge.status-unpaid {
    background: var(--v2-error-bg);
    color: var(--v2-error-text);
}

.billing-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--v2-space-4);
}

.billing-detail-label {
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
    margin-bottom: var(--v2-space-1);
}

.billing-detail-value {
    font-size: var(--v2-text-base);
    font-weight: 500;
    color: var(--v2-fg);
}

.billing-actions {
    display: flex;
    gap: var(--v2-space-3);
    padding: var(--v2-space-5) var(--v2-space-6);
    border-top: 1px solid var(--v2-border);
}

.billing-cancel-notice {
    background: var(--v2-warning-bg);
    border: 1px solid var(--v2-warning);
    color: var(--v2-warning-text);
    padding: var(--v2-space-3) var(--v2-space-4);
    border-radius: var(--v2-radius-md);
    margin: 0 var(--v2-space-6) var(--v2-space-4);
    font-size: var(--v2-text-sm);
}

.billing-payment-notice {
    background: var(--v2-error-bg);
    border: 1px solid var(--v2-error);
    color: var(--v2-error-text);
    padding: var(--v2-space-4);
    border-radius: var(--v2-radius-md);
    margin: 0 var(--v2-space-6) var(--v2-space-4);
}

.billing-payment-notice-title {
    font-size: var(--v2-text-sm);
    font-weight: 700;
    margin-bottom: var(--v2-space-1);
}

.billing-payment-notice-copy {
    font-size: var(--v2-text-sm);
    line-height: 1.45;
}

.billing-payment-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--v2-space-2);
    margin-top: var(--v2-space-3);
}

/* ==================== TRIAL HEADER ==================== */
.trial-header {
    display: flex;
    align-items: flex-start;
    gap: var(--v2-space-4);
    margin-bottom: var(--v2-space-8);
    padding: var(--v2-space-6);
    background: var(--v2-bg-surface);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-xl);
}

/* D04: 2rem (32px) is a hero clock/icon glyph for the trial header — glyph-only per C01-Q04. */
.trial-header-icon { font-size: 2rem; line-height: 1; }

.trial-header-title {
    font-size: var(--v2-text-xl);
    font-weight: 600;
    color: var(--v2-fg);
    margin-bottom: var(--v2-space-2);
}

.trial-header-text {
    color: var(--v2-fg-muted);
    line-height: var(--v2-leading-normal);
    font-size: var(--v2-text-sm);
}

/* ==================== PRICING GRID ==================== */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--v2-space-6);
    margin-bottom: var(--v2-space-6);
}

.pricing-card {
    background: var(--v2-bg-surface);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-xl);
    padding: var(--v2-space-8) var(--v2-space-6);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
}

.pricing-card:hover {
    border-color: var(--v2-border-hover);
    transform: translateY(-4px);
}

.pricing-card.featured {
    border-color: var(--v2-accent);
    background: linear-gradient(180deg, var(--v2-accent-subtle) 0%, var(--v2-bg-surface) 100%);
}

.pricing-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 6px 16px;
    background: var(--v2-accent);
    border-radius: var(--v2-radius-full);
    font-size: var(--v2-text-xs);
    font-weight: 700;
    color: var(--v2-fg-on-accent);
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
    white-space: nowrap;
    z-index: 1;
}

.plan-name {
    font-size: var(--v2-text-lg);
    font-weight: 600;
    color: var(--v2-fg);
    margin-bottom: 4px;
}

.plan-calls {
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
    margin-bottom: var(--v2-space-6);
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    margin-bottom: var(--v2-space-2);
}

.plan-price-currency {
    font-size: var(--v2-text-lg);
    font-weight: 600;
    color: var(--v2-fg);
}

.plan-price-amount {
    font-size: var(--v2-text-3xl);
    font-weight: 700;
    color: var(--v2-fg);
    letter-spacing: var(--v2-tracking-tight);
    line-height: 1;
}

.plan-price-period {
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
    margin-left: 4px;
}

/* "Billed annually — $X" note shown only when annual interval is active.
   Sits directly under the price block. Matches the public pricing renderer's
   .vp-plan-annual-note. Trial card only renders this div when showAnnual
   is true, so no [hidden] variant is needed here. */
.plan-annual-note {
    font-size: 12px;
    font-weight: 500;
    color: var(--v2-fg-muted);
    margin-top: 0;
    margin-bottom: var(--v2-space-4);
    line-height: 1.4;
}

.plan-overage {
    /* D04: 13px = mid-step text between --v2-text-xs (12px) and --v2-text-sm (14px); kept for
       overage line readability on dense pricing card. */
    font-size: 13px;
    color: var(--v2-fg-muted);
    padding-bottom: var(--v2-space-4);
    margin-bottom: var(--v2-space-4);
    border-bottom: 1px solid var(--v2-border);
}

.plan-overage-price {
    color: var(--v2-success);
    font-weight: 500;
}

.plan-cta {
    width: 100%;
    margin-bottom: var(--v2-space-5);
}

.plan-features { flex: 1; }

.plan-feature {
    display: flex;
    align-items: flex-start;
    gap: var(--v2-space-3);
    padding: 5px 0;
    /* D04: 13px = mid-step text between --v2-text-xs (12px) and --v2-text-sm (14px); kept for
       pricing card feature list density. */
    font-size: 13px;
    color: var(--v2-fg-muted);
}

.plan-feature-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--v2-success);
    margin-top: 1px;
}

.plan-shared-features {
    display: none;
}

.plan-shared-title {
    font-size: var(--v2-text-sm);
    font-weight: 600;
    color: var(--v2-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
    margin-bottom: var(--v2-space-4);
}

.pricing-guarantee {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--v2-space-2);
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
    padding: var(--v2-space-4) 0;
}

.pricing-guarantee svg {
    width: 16px;
    height: 16px;
    color: var(--v2-success);
}

/* Loading skeleton for plans */
.plan-skeleton {
    background: var(--v2-bg-surface);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-xl);
    padding: var(--v2-space-8);
    min-height: 400px;
}

/* ==================== PLAN CHANGE MODAL (CLIENT) ==================== */

/* Monthly / Annual interval toggle — shared with admin PageKit modal styling
   contract (.pcm-interval-toggle, .pcm-interval-btn, .pcm-interval-badge).
   Defined here so the client V2 modal is self-contained even on shells that
   don't load plan-change-modal.css. */
.pcm-interval-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--v2-surface);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-full);
    padding: 2px;
    margin-bottom: var(--v2-space-4);
    gap: 2px;
}

.pcm-interval-toggle[data-trial-interval-toggle] {
    display: flex;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.pcm-interval-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--v2-fg-muted);
    font-size: var(--v2-text-sm);
    font-weight: 500;
    padding: var(--v2-space-1) var(--v2-space-3);
    border-radius: var(--v2-radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--v2-space-2);
    transition: background 0.15s, color 0.15s;
}

.pcm-interval-btn:hover:not(.is-active) {
    color: var(--v2-fg);
}

.pcm-interval-btn.is-active {
    background: var(--v2-bg-surface);
    color: var(--v2-fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.pcm-interval-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--v2-success-text);
    background: var(--v2-success-bg);
    border-radius: var(--v2-radius-sm);
    padding: 1px 6px;
    letter-spacing: var(--v2-tracking-wide);
    text-transform: uppercase;
}

.pcm-card-annual-note {
    font-size: var(--v2-text-xs);
    color: var(--v2-fg-muted);
    margin-top: 2px;
}

.pcm-card-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pcm-plan-list {
    display: flex;
    flex-direction: column;
    gap: var(--v2-space-2);
    margin-bottom: var(--v2-space-5);
}

.pcm-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--v2-space-4) var(--v2-space-5);
    background: var(--v2-surface);
    border: 2px solid var(--v2-border);
    border-radius: var(--v2-radius-lg);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.pcm-card:hover:not(.pcm-card-current) {
    border-color: var(--v2-fg-muted);
}

.pcm-card-selected {
    border-color: var(--v2-accent) !important;
    background: var(--v2-accent-subtle);
}

.pcm-card-current {
    opacity: 0.5;
    cursor: default;
}

.pcm-card-top {
    display: flex;
    align-items: center;
    gap: var(--v2-space-2);
}

.pcm-card-name {
    font-weight: 600;
    color: var(--v2-fg);
}

.pcm-badge {
    padding: 2px 8px;
    /* D04: 10px = micro badge text on plan-card row, intentionally small to not compete
       with plan name. Glyph-class per C01-Q04. */
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--v2-radius-full);
    text-transform: uppercase;
    letter-spacing: var(--v2-tracking-wide);
}

.pcm-badge-current {
    background: var(--v2-surface-hover);
    color: var(--v2-fg-muted);
}

.pcm-badge-upgrade {
    background: var(--v2-success-bg);
    color: var(--v2-success-text);
}

.pcm-badge-downgrade {
    background: var(--v2-warning-bg);
    color: var(--v2-warning-text);
}

.pcm-card-price {
    font-size: var(--v2-text-lg);
    font-weight: 600;
    color: var(--v2-fg);
}

.pcm-card-period {
    font-size: var(--v2-text-sm);
    font-weight: 400;
    color: var(--v2-fg-muted);
}

.pcm-card-calls {
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
}

.pcm-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--v2-space-3);
}

/* ==================== PRORATION PREVIEW ==================== */
.pcm-preview-box {
    background: var(--v2-surface);
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-lg);
    padding: var(--v2-space-4);
    margin-bottom: var(--v2-space-5);
}

.pcm-preview-title {
    font-size: var(--v2-text-sm);
    font-weight: 600;
    color: var(--v2-fg);
    margin-bottom: var(--v2-space-3);
}

.pcm-preview-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
}

.pcm-preview-row:not(:last-child) {
    border-bottom: 1px solid var(--v2-border);
}

.pcm-preview-row span:last-child {
    font-weight: 500;
    color: var(--v2-fg);
}

.pcm-preview-credit { color: var(--v2-success-text) !important; }
.pcm-preview-charge { color: var(--v2-warning-text) !important; }

.pcm-preview-total {
    border-top: 2px solid var(--v2-border) !important;
    margin-top: 4px;
    padding-top: 10px;
}

.pcm-preview-total span:first-child {
    font-weight: 600;
    color: var(--v2-fg);
}

.pcm-preview-total span:last-child {
    font-weight: 600;
    font-size: var(--v2-text-base);
}

/* ==================== ADMIN: INFO GRID (v2) ==================== */
.billing-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--v2-space-4);
}

.billing-info-item {}

.billing-info-label {
    font-size: var(--v2-text-sm);
    color: var(--v2-fg-muted);
    margin-bottom: var(--v2-space-1);
}

.billing-info-value {
    font-size: var(--v2-text-base);
    color: var(--v2-fg);
}

.billing-info-value code {
    font-family: var(--v2-font-mono, monospace);
    font-size: var(--v2-text-xs);
    background: var(--v2-surface);
    padding: 2px 6px;
    border-radius: var(--v2-radius-sm);
    border: 1px solid var(--v2-border);
}

/* ==================== ADMIN: USAGE BAR ==================== */
.billing-usage-bar-wrap {
    margin-top: var(--v2-space-4);
}

.billing-usage-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.billing-usage-bar-label {
    font-size: var(--v2-text-xs);
    color: var(--v2-fg-muted);
}

.billing-usage-bar-track {
    height: 8px;
    background: var(--v2-border);
    border-radius: 4px;
    overflow: hidden;
}

.billing-usage-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.billing-usage-bar-fill.usage-success { background: var(--v2-success); }
.billing-usage-bar-fill.usage-warning { background: var(--v2-warning); }
.billing-usage-bar-fill.usage-error { background: var(--v2-error); }

/* ==================== ADMIN: STRIPE BADGE ==================== */
.billing-stripe-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--v2-space-1);
    padding: 2px 8px;
    font-size: var(--v2-text-xs);
    font-weight: 500;
    border-radius: var(--v2-radius-full);
}

.billing-stripe-badge.stripe-active { background: var(--v2-success-bg); color: var(--v2-success-text); }
.billing-stripe-badge.stripe-past_due { background: var(--v2-warning-bg); color: var(--v2-warning-text); }
.billing-stripe-badge.stripe-canceled { background: var(--v2-bg-surface); color: var(--v2-fg-muted); }
.billing-stripe-badge.stripe-incomplete { background: var(--v2-warning-bg); color: var(--v2-warning-text); }
.billing-stripe-badge.stripe-trialing { background: var(--v2-accent-subtle); color: var(--v2-accent); }
.billing-stripe-badge.stripe-unpaid { background: var(--v2-error-bg); color: var(--v2-error-text); }

/* ==================== ADMIN: BUTTON ROW ==================== */
.billing-btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: var(--v2-space-4);
}

/* ==================== RESPONSIVE ==================== */
/* ==================== USAGE STRIP (client billing) ==================== */
.billing-usage-strip {
    display: flex;
    flex-direction: column;
    gap: var(--v2-space-2);
}

.billing-usage-bar {
    height: 4px;
    background: var(--v2-surface-hover);
    border-radius: 9999px;
    overflow: hidden;
}

.billing-usage-bar-fill {
    height: 100%;
    background: var(--v2-accent);
    border-radius: 9999px;
    transition: width 0.3s ease-out;
}

.billing-usage-bar-fill--over {
    background: var(--v2-error-text);
}

.billing-usage-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--v2-space-3);
    flex-wrap: wrap;
}

.billing-usage-count {
    font-size: var(--v2-text-sm);
    font-weight: 600;
    color: var(--v2-fg);
}

.billing-usage-details {
    display: flex;
    align-items: center;
    gap: var(--v2-space-2);
    font-size: var(--v2-text-xs);
    color: var(--v2-fg-muted);
}

.billing-usage-dot {
    color: var(--v2-fg-faint, var(--v2-fg-muted));
    margin: 0 var(--v2-space-1);
}

.billing-usage-overage {
    font-size: var(--v2-text-xs);
    font-weight: 500;
    color: var(--v2-error-text);
}

@media (max-width: 1400px) {
    .pricing-grid { grid-template-columns: repeat(2, 1fr); }
    .pricing-card.featured { order: -1; }
}

@media (max-width: 768px) {
    .plan-shared-features {
        display: block;
        margin-bottom: var(--v2-space-6);
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
    .pricing-grid {
        display: flex;
        grid-template-columns: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: var(--v2-space-3);
        padding-top: var(--v2-space-4);
        padding-bottom: var(--v2-space-2);
        margin-left: calc(-1 * var(--v2-space-5));
        margin-right: calc(-1 * var(--v2-space-5));
        padding-left: var(--v2-space-5);
        padding-right: var(--v2-space-5);
        scrollbar-width: none;
    }
    .pricing-grid::-webkit-scrollbar { display: none; }
    .pricing-card {
        flex: 0 0 240px;
        scroll-snap-align: start;
        padding: var(--v2-space-6) var(--v2-space-5);
    }
    .pricing-card.featured { order: 0; }
    .pricing-card .plan-features { display: none; }
    .pricing-card .plan-cta { margin-bottom: 0; }
    .trial-header { flex-direction: column; align-items: center; text-align: center; }
    .billing-details { grid-template-columns: 1fr; }
    .billing-actions { flex-wrap: wrap; }
    .billing-info-grid { grid-template-columns: 1fr; }
}
