/**
 * PQ Crypta - Billing & Subscription Styles
 * Modern, responsive billing interface
 */

:root {
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --secondary-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --success-color: #48bb78;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

/* Billing Tabs */
.billing-tabs {
    display: flex;
    gap: 8px;
    padding: 20px;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--surface-light);
    border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Tab Content */
.billing-content {
    padding: 30px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Override dashboard color variables */
.billing-content {
    --text-primary: var(--text);
    --text-secondary: var(--text-secondary);
    --bg-white: var(--surface);
    --bg-light: var(--surface-light);
    --border-color: var(--border);
}

/* Overview Cards */
.billing-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.overview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.overview-card:hover {
    box-shadow: var(--shadow-md);
}

.overview-card h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.plan-info {
    margin: 20px 0;
}

.plan-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.plan-status {
    display: inline-block;
    padding: 4px 12px;
    background: var(--success-color);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.usage-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

/* Billing Model Selector */
.billing-model-selector {
    text-align: center;
    margin-bottom: 40px;
}

.billing-model-selector h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.model-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.model-card {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.model-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.model-card.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.model-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.model-card h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.model-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.model-card.selected p {
    color: rgba(255, 255, 255, 0.9);
}

/* Pricing Plans */
.pricing-plans {
    margin-top: 40px;
}

.pricing-plans h2 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
}

.billing-period-toggle {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.period-btn {
    padding: 10px 24px;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.period-btn:hover {
    border-color: var(--primary-color);
}

.period-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.discount-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--success-color);
    color: white;
    border-radius: 8px;
    font-size: 11px;
    margin-left: 4px;
}

.plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.plan-card {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 28px;
    position: relative;
    transition: all 0.3s ease;
}

.plan-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.plan-card.featured {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.featured-badge {
    position: absolute;
    top: -12px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.plan-header {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.plan-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

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

.plan-price .price {
    font-size: 42px;
    font-weight: 700;
    color: var(--primary-color);
}

.plan-price .period {
    color: var(--text-secondary);
    font-size: 14px;
}

.plan-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.plan-features li {
    padding: 10px 0;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-subscribe {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-subscribe:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-subscribe.featured-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Usage-Based Pricing */
.usage-based-description {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.usage-pricing-table {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.pricing-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.pricing-row:last-child {
    border-bottom: none;
}

.pricing-row.header-row {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-primary);
}

.pricing-col {
    display: flex;
    align-items: center;
}

/* Usage Calculator */
.usage-calculator {
    background: var(--bg-white);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 600px;
    margin: 0 auto;
}

.usage-calculator h3 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.calculator-inputs {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.input-group input {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.calculator-result {
    background: var(--bg-light);
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 20px;
}

.calculator-result strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.calculator-result span {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Usage Charts */
.usage-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin: 32px 0;
}

.chart-container {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container canvas {
    max-height: 300px;
}

/* Usage Details Table */
.usage-details-table {
    margin-top: 32px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    overflow-x: auto;
}

.usage-details-table h3 {
    margin-bottom: 16px;
}

.usage-details-table table {
    width: 100%;
    border-collapse: collapse;
}

.usage-details-table th,
.usage-details-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.usage-details-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-primary);
}

/* Payment Methods */
.payment-methods-list {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.payment-method-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.payment-method-card.default {
    border-color: var(--primary-color);
}

.payment-method-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.payment-method-icon {
    font-size: 32px;
}

.payment-method-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.payment-method-type {
    font-weight: 600;
    color: var(--text-primary);
}

.payment-method-last4 {
    color: var(--text-secondary);
    font-size: 14px;
}

.payment-method-actions {
    display: flex;
    gap: 12px;
}

/* Invoices */
.invoices-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.invoices-filters input,
.invoices-filters select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

.invoices-filters input {
    flex: 1;
}

.invoices-table {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
}

.invoices-table table {
    width: 100%;
    border-collapse: collapse;
}

.invoices-table th,
.invoices-table td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.invoices-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-primary);
}

.invoice-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.invoice-status.paid {
    background: var(--success-color);
    color: white;
}

.invoice-status.pending {
    background: var(--warning-color);
    color: white;
}

.invoice-status.failed {
    background: var(--danger-color);
    color: white;
}

/* Settings */
.billing-settings {
    max-width: 800px;
}

.settings-section {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.notification-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.danger-zone {
    border-color: var(--danger-color);
}

.danger-zone h3 {
    color: var(--danger-color);
}

/* Buttons */
.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-light);
}

.btn-danger {
    padding: 12px 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-select-model {
    padding: 10px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-select-model:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Date Range Selector */
.date-range-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.date-range-selector label {
    font-weight: 600;
    color: var(--text-primary);
}

.date-range-selector select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

/* Hidden state classes */
.hidden {
    display: none;
}

.yearly-price.hidden {
    display: none;
}

/* Page notices: billing not configured, payment results */
.billing-notice {
    margin: 0 0 20px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    font-size: 14px;
}

.billing-notice.error {
    border-color: #e53e3e;
    background: rgba(229, 62, 62, 0.08);
}

.billing-notice.success {
    border-color: #38a169;
    background: rgba(56, 161, 105, 0.08);
}

.billing-notice.hidden {
    display: none;
}

/* Payment Element for a new subscription's first payment */
.subscription-payment {
    margin-top: 24px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.subscription-payment.hidden {
    display: none;
}

#subscription-payment-element {
    margin: 16px 0;
}

.btn-subscribe:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Responsive Design */
@media (max-width: 768px) {
    .billing-tabs {
        padding: 12px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .billing-content {
        padding: 16px;
    }

    .billing-overview {
        grid-template-columns: 1fr;
    }

    .plan-cards {
        grid-template-columns: 1fr;
    }

    .usage-charts {
        grid-template-columns: 1fr;
    }

    .pricing-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .invoices-filters {
        flex-direction: column;
    }
}
