/**
 * SJ CRM Stripe Billing Styles
 *
 * Styles for pricing, checkout, and subscription management
 */

/* =========================================
   CSS Variables
   ========================================= */
:root {
    --stripe-primary: #635bff;
    --stripe-primary-dark: #5046e5;
    --stripe-success: #10b981;
    --stripe-warning: #f59e0b;
    --stripe-error: #ef4444;
    --stripe-text: #1a1f36;
    --stripe-text-secondary: #697386;
    --stripe-border: #e3e8ee;
    --stripe-bg: #f7f8fa;
    --stripe-white: #ffffff;
    --stripe-radius: 8px;
    --stripe-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --stripe-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --stripe-text: #ffffff;
        --stripe-text-secondary: #a0aec0;
        --stripe-border: #2d3748;
        --stripe-bg: #1a202c;
        --stripe-white: #2d3748;
    }
}

/* =========================================
   Pricing Section
   ========================================= */
.sj-crm-pricing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Billing Toggle */
.pricing-billing-toggle {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 40px;
    background: var(--stripe-bg);
    padding: 6px;
    border-radius: 30px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.billing-toggle-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--stripe-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.billing-toggle-btn:hover {
    color: var(--stripe-text);
}

.billing-toggle-btn.active {
    background: var(--stripe-white);
    color: var(--stripe-text);
    box-shadow: var(--stripe-shadow);
}

.save-badge {
    background: var(--stripe-success);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Plans Grid */
.pricing-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    align-items: stretch;
}

/* Plan Card */
.pricing-plan-card {
    background: var(--stripe-white);
    border: 2px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    padding: 32px;
    position: relative;
    transition: all 0.3s ease;
}

.pricing-plan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--stripe-shadow-lg);
}

.pricing-plan-card.popular {
    border-color: var(--stripe-primary);
    transform: scale(1.02);
}

.pricing-plan-card.popular:hover {
    transform: scale(1.02) translateY(-4px);
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--stripe-primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 16px;
    border-radius: 16px;
    white-space: nowrap;
}

/* Plan Header */
.plan-header {
    margin-bottom: 24px;
}

.plan-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--stripe-text);
    margin: 0 0 8px 0;
}

.plan-description {
    font-size: 14px;
    color: var(--stripe-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Plan Price */
.plan-price {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--stripe-border);
}

.plan-price .currency {
    font-size: 24px;
    font-weight: 600;
    color: var(--stripe-text);
    vertical-align: top;
}

.plan-price .amount {
    font-size: 48px;
    font-weight: 700;
    color: var(--stripe-text);
    line-height: 1;
}

.plan-price .period {
    font-size: 16px;
    color: var(--stripe-text-secondary);
}

/* Trial Badge */
.trial-badge {
    display: inline-block;
    background: rgba(99, 91, 255, 0.1);
    color: var(--stripe-primary);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 16px;
    margin-bottom: 20px;
}

/* Plan Features */
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.plan-features li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--stripe-text-secondary);
}

.plan-features .check-icon {
    width: 20px;
    height: 20px;
    color: var(--stripe-success);
    flex-shrink: 0;
    margin-top: 1px;
}

/* Plan Footer */
.plan-footer {
    margin-top: auto;
}

.plan-cta-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    background: var(--stripe-primary);
    color: white;
    text-align: center;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--stripe-radius);
    transition: all 0.2s ease;
}

.plan-cta-btn:hover {
    background: var(--stripe-primary-dark);
    color: white;
    transform: translateY(-1px);
}

.pricing-plan-card:not(.popular) .plan-cta-btn {
    background: transparent;
    color: var(--stripe-primary);
    border: 2px solid var(--stripe-primary);
}

.pricing-plan-card:not(.popular) .plan-cta-btn:hover {
    background: var(--stripe-primary);
    color: white;
}

/* Current Plan Styles */
.current-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.pricing-plan-card.current-plan {
    border-color: #10b981;
}

.plan-cta-btn.disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}

.plan-cta-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

button.plan-cta-btn {
    cursor: pointer;
}

/* =========================================
   Checkout Section
   ========================================= */
.sj-crm-checkout {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Checkout Summary */
.checkout-summary {
    background: var(--stripe-white);
    border: 1px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    padding: 24px;
    margin-bottom: 24px;
}

.checkout-summary h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--stripe-text);
    margin: 0 0 16px 0;
}

.selected-plan {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--stripe-border);
    margin-bottom: 16px;
}

.selected-plan .plan-name {
    font-weight: 500;
    color: var(--stripe-text);
}

.selected-plan .plan-price {
    font-weight: 600;
    color: var(--stripe-text);
    margin: 0;
    padding: 0;
    border: none;
}

/* Billing Selector */
.billing-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.billing-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.billing-option:hover {
    border-color: var(--stripe-primary);
}

.billing-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--stripe-primary);
}

.billing-option input[type="radio"]:checked + .option-label {
    color: var(--stripe-text);
}

.billing-option:has(input:checked) {
    border-color: var(--stripe-primary);
    background: rgba(99, 91, 255, 0.05);
}

.option-label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--stripe-text-secondary);
}

.option-price {
    font-weight: 600;
}

.save-tag {
    background: var(--stripe-success);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* Trial Notice */
.trial-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--stripe-radius);
    font-size: 13px;
    color: var(--stripe-success);
}

.trial-notice .info-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Checkout Form */
.checkout-form {
    background: var(--stripe-white);
    border: 1px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    padding: 24px;
}

.form-section {
    margin-bottom: 24px;
}

.form-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--stripe-text);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--stripe-text);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    font-size: 15px;
    color: var(--stripe-text);
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--stripe-primary);
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
}

/* Subdomain Input */
.subdomain-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    overflow: hidden;
    transition: all 0.2s ease;
}

.subdomain-input:focus-within {
    border-color: var(--stripe-primary);
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
}

.subdomain-input input {
    flex: 1;
    border: none !important;
    box-shadow: none !important;
}

.subdomain-input input:focus {
    border: none !important;
    box-shadow: none !important;
}

.domain-suffix {
    padding: 12px 16px;
    background: var(--stripe-bg);
    color: var(--stripe-text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

/* Subdomain Status */
.subdomain-status {
    display: block;
    margin-top: 6px;
    font-size: 12px;
}

.subdomain-status .status-info {
    color: var(--stripe-text-secondary);
}

.subdomain-status .status-checking {
    color: var(--stripe-warning);
}

.subdomain-status .status-available {
    color: var(--stripe-success);
}

.subdomain-status .status-taken {
    color: var(--stripe-error);
}

/* Form Actions */
.form-actions {
    margin-top: 24px;
}

.checkout-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--stripe-primary);
    color: white;
    border: none;
    border-radius: var(--stripe-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.checkout-btn:hover:not(:disabled) {
    background: var(--stripe-primary-dark);
    transform: translateY(-1px);
}

.checkout-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.spinner-circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 50;
    stroke-dashoffset: 25;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error Message */
.checkout-error {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--stripe-error);
    border-radius: var(--stripe-radius);
    color: var(--stripe-error);
    font-size: 14px;
}

/* Secure Notice */
.secure-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 12px;
    color: var(--stripe-text-secondary);
}

.secure-notice .lock-icon {
    width: 16px;
    height: 16px;
}

/* =========================================
   Customer Portal
   ========================================= */
.sj-crm-customer-portal {
    text-align: center;
    padding: 24px;
}

.portal-btn {
    padding: 14px 32px;
    background: var(--stripe-primary);
    color: white;
    border: none;
    border-radius: var(--stripe-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.portal-btn:hover:not(:disabled) {
    background: var(--stripe-primary-dark);
}

.portal-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.portal-info {
    margin-top: 12px;
    font-size: 13px;
    color: var(--stripe-text-secondary);
}

/* =========================================
   Subscription Status Widget
   ========================================= */
.sj-crm-subscription-status {
    background: var(--stripe-white);
    border: 1px solid var(--stripe-border);
    border-radius: var(--stripe-radius);
    padding: 20px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--stripe-border);
}

.status-row:last-child {
    border-bottom: none;
}

.status-label {
    color: var(--stripe-text-secondary);
    font-size: 14px;
}

.status-value {
    font-weight: 500;
    color: var(--stripe-text);
}

.status-value.active {
    color: var(--stripe-success);
}

.status-value.past_due,
.status-value.unpaid {
    color: var(--stripe-warning);
}

.status-value.canceled {
    color: var(--stripe-error);
}

.cancel-notice {
    margin-top: 12px;
    padding: 10px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: var(--stripe-radius);
    font-size: 13px;
    color: var(--stripe-warning);
    display: none;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
    .pricing-plans-grid {
        grid-template-columns: 1fr;
    }
    
    .pricing-plan-card.popular {
        transform: none;
        order: -1;
    }
    
    .pricing-plan-card.popular:hover {
        transform: translateY(-4px);
    }
    
    .plan-price .amount {
        font-size: 36px;
    }
    
    .billing-toggle-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .option-label {
        flex-wrap: wrap;
    }
    
    .save-tag {
        margin-left: 0;
        margin-top: 4px;
    }
}

/* Agreement Checkbox */
.sj-crm-agreement {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.agreement-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.agreement-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #5850ec;
}

.agreement-text {
    font-size: 14px;
    line-height: 1.5;
    color: #4a5568;
}

.agreement-text a {
    color: #5850ec;
    text-decoration: underline;
}

.agreement-text a:hover {
    color: #4338ca;
}

@media (max-width: 600px) {
    .sj-crm-agreement {
        padding: 12px;
    }
    
    .agreement-text {
        font-size: 13px;
    }
}
