/**
 * Platform Dashboard Styles
 * Admin-only dashboard for cross-tenant analytics
 */

/* Loading State */
.platform-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary, #6b7280);
}

.platform-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color, #e5e7eb);
  border-top-color: var(--primary, #ef4444);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Dashboard Container */
.platform-dashboard {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Section Styling */
.stats-section,
.plan-section,
.actions-section,
.tenants-section,
.usage-section {
  background: var(--surface, #ffffff);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--background, #f9fafb);
  border-radius: 10px;
  border: 1px solid var(--border-color, #e5e7eb);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.stat-icon.tenant-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-icon.active-icon { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.client-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.project-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.form-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.response-icon { background: linear-gradient(135deg, #ec4899, #db2777); }

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 4px 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin: 0;
}

/* Plan Breakdown */
.plan-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .plan-breakdown {
    grid-template-columns: 1fr;
  }
}

.plan-table-wrapper {
  overflow-x: auto;
}

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

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

.plan-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary, #6b7280);
  background: var(--background, #f9fafb);
}

.plan-table .count-cell,
.plan-table .percentage-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.status-trialing {
  background: #fef3c7;
  color: #92400e;
}

.status-active {
  background: #d1fae5;
  color: #065f46;
}

.status-past-due,
.status-past_due {
  background: #fee2e2;
  color: #991b1b;
}

.status-canceled {
  background: #f3f4f6;
  color: #4b5563;
}

.status-expired {
  background: #fecaca;
  color: #7f1d1d;
}

.status-unknown {
  background: #e5e7eb;
  color: #374151;
}

/* Status Bars */
.status-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.status-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-bar-label {
  width: 80px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
}

.status-bar-track {
  flex: 1;
  height: 8px;
  background: var(--background, #f3f4f6);
  border-radius: 4px;
  overflow: hidden;
}

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

.status-bar-fill.status-trialing { background: #f59e0b; }
.status-bar-fill.status-active { background: #10b981; }
.status-bar-fill.status-past-due { background: #ef4444; }
.status-bar-fill.status-canceled { background: #6b7280; }
.status-bar-fill.status-expired { background: #dc2626; }

.status-bar-value {
  width: 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background: var(--surface, #ffffff);
  color: var(--text-primary, #111827);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--background, #f9fafb);
  border-color: var(--primary, #ef4444);
  color: var(--primary, #ef4444);
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.action-btn i {
  font-size: 16px;
}

/* Hidden Section */
.hidden {
  display: none !important;
}

/* Tenants Section */
.tenants-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  background: var(--surface, #ffffff);
  color: var(--text-primary, #111827);
  font-size: 14px;
  cursor: pointer;
}

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

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

.tenants-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary, #6b7280);
  background: var(--background, #f9fafb);
}

.tenants-table .tenant-id {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
}

.pagination-info {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
  text-align: center;
}

/* Usage Section */
.usage-controls {
  margin-bottom: 16px;
}

.usage-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.usage-total-card {
  padding: 16px;
  background: var(--background, #f9fafb);
  border-radius: 8px;
  text-align: center;
}

.usage-total-card h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 8px 0;
}

.usage-total-card .usage-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin: 0;
}

.usage-chart-placeholder {
  padding: 16px;
  background: var(--background, #f9fafb);
  border-radius: 8px;
}

.usage-chart-placeholder h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin: 0 0 16px 0;
}

.data-points {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.data-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface, #ffffff);
  border-radius: 6px;
  border: 1px solid var(--border-color, #e5e7eb);
  min-width: 100px;
}

.data-point .date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  margin-bottom: 4px;
}

.data-point .values {
  font-size: 11px;
  color: var(--text-secondary, #6b7280);
  font-family: monospace;
}

/* Error Container */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.error-container .error-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.error-container .error-icon i {
  font-size: 36px;
  color: #ef4444;
}

.error-container h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin: 0 0 8px 0;
}

.error-container p {
  color: var(--text-secondary, #6b7280);
  margin: 0 0 8px 0;
}

.error-container .error-detail {
  font-size: 13px;
  font-family: monospace;
  color: var(--text-tertiary, #9ca3af);
  margin-bottom: 24px;
}

/* Loading and Empty States */
.loading,
.empty-state,
.error {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary, #6b7280);
}

.error {
  color: #ef4444;
}

/* Dark Mode */
.dark-mode .stat-card,
.dark-mode .plan-section,
.dark-mode .stats-section,
.dark-mode .actions-section,
.dark-mode .tenants-section,
.dark-mode .usage-section {
  background: var(--surface-dark, #1f2937);
  border-color: var(--border-dark, #374151);
}

.dark-mode .stat-card {
  background: var(--background-dark, #111827);
}

.dark-mode .plan-table th,
.dark-mode .tenants-table th {
  background: var(--background-dark, #111827);
}

.dark-mode .error-container .error-icon {
  background: rgba(239, 68, 68, 0.1);
}

.dark-mode .status-trialing {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.dark-mode .status-active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.dark-mode .status-past-due,
.dark-mode .status-past_due {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.dark-mode .status-canceled {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

.dark-mode .status-expired {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
}

.dark-mode .action-btn {
  background: var(--surface-dark, #1f2937);
  border-color: var(--border-dark, #374151);
  color: var(--text-light, #f9fafb);
}

.dark-mode .action-btn:hover {
  background: var(--background-dark, #111827);
}
