/* Billing page styles - external file for CSP compliance */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: #f1f5f9;
    line-height: 1.6;
    min-height: 100vh;
}

.billing-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Header */
.billing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.billing-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.header-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
}

.user-badge span {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: rgba(255,255,255,0.6);
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(10px);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-card-title {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon svg {
    width: 20px;
    height: 20px;
}

.stat-card-icon.purple {
    background: rgba(124, 58, 237, 0.2);
    color: #a78bfa;
}

.stat-card-icon.green {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.stat-card-icon.blue {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.stat-card-icon.orange {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.stat-subtitle {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
}

/* Progress bar */
.progress-container {
    margin-top: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

.progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.green {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.progress-fill.yellow {
    background: linear-gradient(90deg, #eab308, #facc15);
}

.progress-fill.red {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.progress-fill.purple {
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

/* Current Plan Section */
.plan-section {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
}

.plan-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.plan-info h2 {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.plan-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.plan-badge {
    font-size: 0.7rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-badge.active {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.plan-badge.grandfathered {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
}

/* Early Adopter badge - special styling for grandfathered users */
.plan-badge.early-adopter {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25) 0%, rgba(245, 158, 11, 0.25) 100%);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.early-adopter-star {
    color: #fbbf24;
    font-size: 1em;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}

.plan-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.plan-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
}

.plan-feature svg {
    width: 18px;
    height: 18px;
    color: #4ade80;
    flex-shrink: 0;
}

.plan-feature span {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
}

/* Pricing Section */
.pricing-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 24px;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.pricing-card {
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 32px;
    position: relative;
    transition: all 0.3s;
}

.pricing-card:hover {
    border-color: rgba(124, 58, 237, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.pricing-card.current {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
}

.pricing-card.recommended {
    border-color: #22c55e;
}

/* Enterprise tier styling */
.pricing-card.enterprise {
    border-color: rgba(147, 51, 234, 0.5);
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.2) 0%, rgba(30, 41, 59, 0.6) 100%);
}

.pricing-card.enterprise:hover {
    border-color: rgba(147, 51, 234, 0.8);
    box-shadow: 0 20px 40px rgba(147, 51, 234, 0.2);
}

.pricing-card-badge.enterprise-badge {
    background: linear-gradient(135deg, #9333ea, #7c3aed);
}

.pricing-card-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pricing-card-header {
    text-align: center;
    margin-bottom: 24px;
}

.pricing-card-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}

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

.pricing-card-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
}

.pricing-card-period {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.5);
}

.pricing-card-credits {
    text-align: center;
    padding: 16px;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 12px;
    margin-bottom: 24px;
}

.pricing-card-credits-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #a78bfa;
}

.pricing-card-credits-label {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

.pricing-card-features {
    list-style: none;
    margin-bottom: 24px;
}

.pricing-card-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.pricing-card-features li:last-child {
    border-bottom: none;
}

.pricing-card-features li svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.pricing-card-features li svg.check {
    color: #4ade80;
}

.pricing-card-features li svg.x {
    color: rgba(255,255,255,0.3);
}

.pricing-card-features li.disabled {
    color: rgba(255,255,255,0.4);
    text-decoration: line-through;
}

/* Alert */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.alert.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.alert.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: rgba(255,255,255,0.6);
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .billing-page {
        padding: 20px 16px;
    }

    .billing-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-nav {
        flex-wrap: wrap;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .pricing-grid {
        grid-template-columns: 1fr;
    }

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

/* ============================================================================
   Admin Section Styles
   ============================================================================ */

.admin-section {
    margin-top: 48px;
    padding-top: 48px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-section h2 {
    color: #f87171;
    margin-bottom: 24px;
}

.admin-search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.admin-search-input {
    flex: 1;
    max-width: 400px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
}

.admin-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.admin-search-input:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.admin-table-container {
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-customers-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.admin-customers-table th,
.admin-customers-table td {
    padding: 14px 16px;
    text-align: left;
}

.admin-customers-table th {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-customers-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

.admin-customers-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.admin-customers-table .action-buttons {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.badge-gold {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border-radius: 9999px;
    font-size: 0.7rem;
    margin-left: 8px;
    font-weight: 500;
}

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 28px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.modal-content p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

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

.modal-content .form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
}

.form-input:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.5);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.modal-confirm {
    max-width: 400px;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    transform: translateY(-1px);
}

/* Admin responsive */
@media (max-width: 768px) {
    .admin-search-container {
        flex-direction: column;
    }

    .admin-search-input {
        max-width: 100%;
    }

    .admin-customers-table .action-buttons {
        flex-direction: column;
    }

    .modal-content {
        margin: 20px;
        padding: 20px;
    }
}

/* ============================================================================
   Stripe Sync Status Styles
   ============================================================================ */

.admin-stripe-sync {
    margin-bottom: 32px;
}

.sync-status-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
}

.sync-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sync-status-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.sync-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sync-badge.loading {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.sync-badge.success {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.sync-badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.sync-badge.warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.sync-description {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.sync-details {
    margin-bottom: 16px;
}

.sync-tier-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.03);
}

.sync-tier-status.ok {
    border-left: 3px solid #4ade80;
}

.sync-tier-status.error {
    border-left: 3px solid #f87171;
}

.sync-tier-status.warning {
    border-left: 3px solid #fbbf24;
}

.sync-tier-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sync-tier-status.ok .sync-tier-icon {
    color: #4ade80;
}

.sync-tier-status.error .sync-tier-icon {
    color: #f87171;
}

.sync-tier-status.warning .sync-tier-icon {
    color: #fbbf24;
}

.sync-tier-name {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    min-width: 150px;
}

.sync-tier-message {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

.sync-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.sync-help-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sync-help-text code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.sync-warning,
.sync-error {
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.sync-warning {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.sync-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

/* ============================================================================
   Delete Customer Modal Styles
   ============================================================================ */

.modal-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-danger h3 {
    color: #f87171;
}

.delete-customer-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
}

.delete-customer-info p {
    margin: 4px 0;
    font-size: 0.9rem;
}

.danger-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fca5a5;
    font-size: 0.9rem;
    margin: 16px 0;
}

.danger-warning strong {
    color: #f87171;
}
