/**
 * YourBeans Coffee - Per-Order Billing Styles
 * Extends design-system.css for Stripe-based per-order COGS charging UI
 * Version 2.0 - February 2026
 */

/* ============================================
   Per-Order Billing Widget
   ============================================ */

.credit-balance-widget.per-order-billing {
  background: linear-gradient(135deg, var(--color-accent-50, #f0fdf4) 0%, var(--color-accent-100, #dcfce7) 100%);
  border: 1px solid var(--color-accent-200, #bbf7d0);
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-6, 1.5rem);
  position: relative;
  overflow: hidden;
}

.credit-balance-widget.per-order-billing::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.credit-balance-widget.per-order-billing .balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5, 1.25rem);
  padding-bottom: var(--space-4, 1rem);
  border-bottom: 1px solid var(--color-accent-200, #bbf7d0);
  position: relative;
}

.credit-balance-widget.per-order-billing .balance-header h3 {
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: var(--font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent-700, #15803d);
  margin: 0;
}

/* ============================================
   Status Badge
   ============================================ */

.credit-balance-widget.per-order-billing .balance-status {
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: var(--font-weight-semibold, 600);
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-full, 9999px);
}

.balance-status.healthy {
  background: var(--color-success-light, #dcfce7);
  color: var(--color-success-dark, #15803d);
}

.balance-status.warning {
  background: var(--color-warning-light, #fef3c7);
  color: var(--color-warning-dark, #b45309);
}

.balance-status.critical {
  background: var(--color-error-light, #fee2e2);
  color: var(--color-error-dark, #b91c1c);
}

/* ============================================
   Setup Required Alert
   ============================================ */

.setup-required-alert {
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  background: var(--color-warning-light, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-4, 1rem);
  margin-bottom: var(--space-5, 1.25rem);
}

.setup-required-alert .alert-icon {
  font-size: var(--font-size-lg, 1.125rem);
  flex-shrink: 0;
}

.setup-required-alert span:last-child {
  color: var(--color-warning-dark, #b45309);
  font-size: var(--font-size-sm, 0.8125rem);
  font-weight: var(--font-weight-medium, 500);
}

/* ============================================
   Payment Method Section
   ============================================ */

.payment-method-section {
  background: var(--color-neutral-0, white);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-5, 1.25rem);
  margin-bottom: var(--space-5, 1.25rem);
  border: 1px solid var(--color-neutral-100, #f1f5f9);
}

.payment-method-section h4 {
  font-size: var(--font-size-sm, 0.8125rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-800, #1e293b);
  margin: 0 0 var(--space-4, 1rem) 0;
}

.saved-card {
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  padding: var(--space-4, 1rem);
  background: var(--color-neutral-50, #f8fafc);
  border: 1px solid var(--color-neutral-200, #e2e8f0);
  border-radius: var(--radius-lg, 0.75rem);
  margin-bottom: var(--space-4, 1rem);
}

.saved-card .card-icon {
  font-size: var(--font-size-2xl, 1.5rem);
  flex-shrink: 0;
}

.saved-card .card-details {
  flex: 1;
}

.saved-card .card-brand {
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-900, #0f172a);
}

.saved-card .card-last4 {
  font-family: var(--font-family-mono, 'JetBrains Mono', monospace);
  font-weight: var(--font-weight-semibold, 600);
}

.saved-card .card-expiry {
  color: var(--color-neutral-500, #64748b);
  font-size: var(--font-size-sm, 0.8125rem);
}

.payment-method-actions {
  display: flex;
  gap: var(--space-2, 0.5rem);
}

.no-payment-method {
  text-align: center;
  padding: var(--space-6, 1.5rem);
}

.no-payment-method p {
  color: var(--color-neutral-500, #64748b);
  margin: 0 0 var(--space-4, 1rem) 0;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
  background: var(--color-accent-600, #16a34a);
  color: var(--color-neutral-0, white);
  border: none;
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  border-radius: var(--radius-md, 0.5rem);
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--font-size-sm, 0.8125rem);
  cursor: pointer;
  transition: all var(--transition-fast, 150ms ease);
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgb(0 0 0 / 0.1));
}

.btn-primary:hover {
  background: var(--color-accent-700, #15803d);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--color-neutral-400, #94a3b8);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--color-neutral-0, white);
  color: var(--color-neutral-700, #334155);
  border: 1px solid var(--color-neutral-300, #cbd5e1);
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
  border-radius: var(--radius-md, 0.5rem);
  font-weight: var(--font-weight-medium, 500);
  font-size: var(--font-size-sm, 0.8125rem);
  cursor: pointer;
  transition: all var(--transition-fast, 150ms ease);
}

.btn-secondary:hover {
  background: var(--color-neutral-50, #f8fafc);
  border-color: var(--color-neutral-400, #94a3b8);
}

.btn-danger-outline {
  background: var(--color-neutral-0, white);
  color: var(--color-error, #ef4444);
  border: 1px solid var(--color-error-light, #fee2e2);
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
  border-radius: var(--radius-md, 0.5rem);
  font-weight: var(--font-weight-medium, 500);
  font-size: var(--font-size-sm, 0.8125rem);
  cursor: pointer;
  transition: all var(--transition-fast, 150ms ease);
}

.btn-danger-outline:hover {
  background: var(--color-error-light, #fee2e2);
  border-color: #fca5a5;
}

/* ============================================
   How It Works
   ============================================ */

.how-it-works {
  background: var(--color-info-light, #e0f2fe);
  border: 1px solid #7dd3fc;
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-5, 1.25rem);
  margin-bottom: var(--space-5, 1.25rem);
}

.how-it-works h4 {
  font-size: var(--font-size-sm, 0.8125rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-info-dark, #0369a1);
  margin: 0 0 var(--space-3, 0.75rem) 0;
}

.how-it-works ul {
  margin: 0;
  padding: 0 0 0 var(--space-5, 1.25rem);
}

.how-it-works li {
  color: #0c4a6e;
  font-size: var(--font-size-sm, 0.8125rem);
  line-height: var(--line-height-relaxed, 1.625);
  margin-bottom: var(--space-1, 0.25rem);
}

.how-it-works li:last-child {
  margin-bottom: 0;
}

/* ============================================
   Recent Charges
   ============================================ */

.recent-charges {
  margin-bottom: var(--space-5, 1.25rem);
}

.recent-charges h4 {
  font-size: var(--font-size-sm, 0.8125rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-800, #1e293b);
  margin: 0 0 var(--space-4, 1rem) 0;
}

.charges-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 0.5rem);
}

.charge-item {
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  background: var(--color-neutral-0, white);
  border: 1px solid var(--color-neutral-200, #e2e8f0);
  border-radius: var(--radius-md, 0.5rem);
  font-size: var(--font-size-sm, 0.8125rem);
  transition: background var(--transition-fast, 150ms ease);
}

.charge-item:hover {
  background: var(--color-neutral-50, #f8fafc);
}

.charge-item.success {
  border-left: 3px solid var(--color-success, #22c55e);
}

.charge-item.failed {
  border-left: 3px solid var(--color-error, #ef4444);
  background: var(--color-error-light, #fee2e2);
}

.charge-item.pending {
  border-left: 3px solid var(--color-warning, #f59e0b);
}

.charge-item .charge-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.charge-item.success .charge-icon {
  color: var(--color-success, #22c55e);
}

.charge-item.failed .charge-icon {
  color: var(--color-error, #ef4444);
}

.charge-item .charge-order {
  flex: 1;
  font-weight: var(--font-weight-medium, 500);
  color: var(--color-neutral-700, #334155);
}

.charge-item .charge-amount {
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-900, #0f172a);
  font-variant-numeric: tabular-nums;
}

.charge-item .charge-error {
  width: 100%;
  margin-top: var(--space-2, 0.5rem);
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-error-dark, #b91c1c);
}

.charges-summary {
  display: flex;
  gap: var(--space-4, 1rem);
  margin-top: var(--space-4, 1rem);
  padding-top: var(--space-4, 1rem);
  border-top: 1px solid var(--color-neutral-200, #e2e8f0);
  font-size: var(--font-size-sm, 0.8125rem);
  color: var(--color-neutral-500, #64748b);
}

.charges-summary .failed {
  color: var(--color-error, #ef4444);
}

.charges-summary .total {
  margin-left: auto;
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-900, #0f172a);
}

/* ============================================
   Billing Mode Switch
   ============================================ */

.billing-mode-switch {
  text-align: center;
  padding-top: var(--space-4, 1rem);
  border-top: 1px solid var(--color-accent-200, #bbf7d0);
}

.billing-mode-switch .switch-note {
  font-size: var(--font-size-sm, 0.8125rem);
  color: var(--color-neutral-500, #64748b);
  margin: 0;
}

.billing-mode-switch a {
  color: var(--color-info-dark, #0369a1);
  text-decoration: none;
  font-weight: var(--font-weight-medium, 500);
}

.billing-mode-switch a:hover {
  text-decoration: underline;
}

/* ============================================
   Failed Charges Alert (Prominent)
   ============================================ */

.failed-charges-alert {
  background: linear-gradient(135deg, #fef2f2 0%, var(--color-error-light, #fee2e2) 100%);
  border: 2px solid #fca5a5;
  border-radius: var(--radius-xl, 1rem);
  padding: var(--space-6, 1.5rem);
  margin-bottom: var(--space-6, 1.5rem);
}

.failed-charges-alert .alert-header {
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  margin-bottom: var(--space-4, 1rem);
}

.failed-charges-alert .alert-icon {
  font-size: var(--font-size-2xl, 1.5rem);
}

.failed-charges-alert .alert-title {
  font-size: var(--font-size-md, 1rem);
  font-weight: var(--font-weight-bold, 700);
  color: var(--color-error-dark, #b91c1c);
}

.failed-charges-alert .alert-message {
  color: #7f1d1d;
  font-size: var(--font-size-sm, 0.8125rem);
  margin: 0 0 var(--space-5, 1.25rem) 0;
  line-height: var(--line-height-relaxed, 1.625);
}

.failed-charges-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 1rem);
}

.failed-charge-item {
  background: var(--color-neutral-0, white);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-5, 1.25rem);
}

.failed-charge-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2, 0.5rem);
}

.failed-order-name {
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-neutral-900, #0f172a);
  font-size: var(--font-size-base, 0.875rem);
}

.failed-amount {
  font-weight: var(--font-weight-bold, 700);
  color: var(--color-error, #ef4444);
  font-size: var(--font-size-md, 1rem);
  font-variant-numeric: tabular-nums;
}

.failed-reason {
  font-size: var(--font-size-sm, 0.8125rem);
  color: var(--color-neutral-600, #475569);
  margin-bottom: var(--space-4, 1rem);
  padding: var(--space-3, 0.75rem);
  background: var(--color-neutral-50, #f8fafc);
  border-radius: var(--radius-md, 0.5rem);
}

.btn-retry {
  width: 100%;
  background: var(--color-accent-600, #16a34a);
  color: var(--color-neutral-0, white);
  border: none;
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  border-radius: var(--radius-md, 0.5rem);
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--font-size-sm, 0.8125rem);
  cursor: pointer;
  transition: all var(--transition-fast, 150ms ease);
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgb(0 0 0 / 0.1));
}

.btn-retry:hover {
  background: var(--color-accent-700, #15803d);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
}

.btn-retry:active {
  transform: translateY(0);
}

.btn-retry:disabled {
  background: var(--color-neutral-400, #94a3b8);
  cursor: not-allowed;
  transform: none;
}

.btn-retry-small {
  background: var(--color-accent-600, #16a34a);
  color: var(--color-neutral-0, white);
  border: none;
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-sm, 0.375rem);
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--font-size-xs, 0.75rem);
  cursor: pointer;
  transition: all var(--transition-fast, 150ms ease);
  margin-left: auto;
}

.btn-retry-small:hover {
  background: var(--color-accent-700, #15803d);
}

.btn-retry-small:disabled {
  background: var(--color-neutral-400, #94a3b8);
  cursor: not-allowed;
}
