/* XFN Growth Dashboard */

.dashboard-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 24px;
  gap: 24px;
  overflow-y: auto;
}

/* ---- Header row ---- */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.dashboard-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-period-select {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}

.dashboard-refresh-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dashboard-refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-positive);
  animation: dashboard-pulse 2s ease-in-out infinite;
}

@keyframes dashboard-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ---- Hero Metrics Row ---- */
.dashboard-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  flex-shrink: 0;
}

.dashboard-metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 14px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dashboard-metric-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.dashboard-metric-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.dashboard-metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 6px;
}

.dashboard-metric-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.dashboard-metric-trend.up {
  color: var(--status-positive);
}

.dashboard-metric-trend.down {
  color: var(--status-critical);
}

.dashboard-metric-trend.neutral {
  color: var(--text-muted);
}

/* ---- Sections ---- */
.dashboard-section {
  flex-shrink: 0;
}

.dashboard-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ---- Chart Cards ---- */
.dashboard-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.dashboard-chart-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.dashboard-chart-canvas {
  width: 100% !important;
  max-height: 280px;
}

/* ---- Grid layouts ---- */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* ---- Engagement cards ---- */
.dashboard-engage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.dashboard-engage-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dashboard-engage-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
}

.dashboard-engage-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.dashboard-engage-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ---- Retention table ---- */
.dashboard-retention-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dashboard-retention-table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 11px;
  padding: 8px 10px;
  text-align: center;
  border-bottom: 2px solid var(--border);
}

.dashboard-retention-table th:first-child,
.dashboard-retention-table td:first-child {
  text-align: left;
}

.dashboard-retention-table td {
  padding: 6px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.dashboard-retention-table tr:last-child td {
  border-bottom: none;
}

.retention-cell {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-width: 48px;
}

.retention-cell.good {
  background: rgba(34, 197, 94, 0.15);
  color: var(--status-positive);
}

.retention-cell.ok {
  background: rgba(245, 158, 11, 0.15);
  color: var(--status-warning);
}

.retention-cell.low {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-critical);
}

.retention-cell.na {
  color: var(--text-muted);
  opacity: 0.5;
}

/* ---- Failure table ---- */
.dashboard-failure-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dashboard-failure-table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 11px;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.dashboard-failure-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.dashboard-failure-table tr:last-child td {
  border-bottom: none;
}

.failure-count {
  font-weight: 700;
  color: var(--status-critical);
}

/* ---- Social metric pills ---- */
.dashboard-social-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.dashboard-social-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
}

.dashboard-social-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.dashboard-social-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
}

/* ---- Empty / Loading states ---- */
.dashboard-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.dashboard-error {
  text-align: center;
  padding: 20px;
  color: var(--status-critical);
  font-size: 13px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .dashboard-grid-2,
  .dashboard-grid-3 {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-layout {
    padding: 12px 14px;
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .dashboard-hero {
    grid-template-columns: 1fr;
  }
}

/* ---- Public dashboard standalone header ---- */
.dashboard-public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dashboard-public-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.dashboard-public-brand img {
  border-radius: 6px;
}

.dashboard-public-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Pending data indicator */
.dashboard-pending {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Muted sub-stats (e.g. adhoc/batch breakdown) */
.dashboard-engage-stat.muted .dashboard-engage-stat-label,
.dashboard-engage-stat.muted .dashboard-engage-stat-value {
  font-size: 11px;
  color: var(--text-muted);
}
