/**
 * ProRank Design System - Stats & Metrics Components
 * 
 * Statistical displays, metrics cards, progress bars, and charts.
 * Ensures consistent data visualization across the plugin.
 * 
 * @module components/stats
 * @since 3.0.0
 */

/* ============================================
   STAT CARDS
   Basic stat display cards
   ============================================ */

.prorank-stat-card {
  background: white;
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm);
  padding: 20px;
  box-shadow: var(--prorank-shadow-sm);
  transition: var(--prorank-transition);
}

.prorank-stat-card:hover {
  box-shadow: var(--prorank-shadow);
  transform: translateY(-2px);
}

/* Stat Card Variants */
.prorank-stat-card--compact {
  padding: 12px 16px;
}

.prorank-stat-card--featured {
  background: var(--prorank-gradient);
  color: white;
  border: none;
}

.prorank-stat-card--featured .prorank-stat-value,
.prorank-stat-card--featured .prorank-stat-label {
  color: white;
}

/* ============================================
   STAT VALUES & LABELS
   Core stat display elements
   ============================================ */

.prorank-stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--prorank-primary);
  line-height: 1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.prorank-stat-value--large {
  font-size: 48px;
}

.prorank-stat-value--small {
  font-size: 24px;
}

.prorank-stat-label {
  font-size: 14px;
  color: var(--prorank-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Stat Status Colors */
.prorank-stat--success .prorank-stat-value {
  color: var(--prorank-success);
}

.prorank-stat--warning .prorank-stat-value {
  color: var(--prorank-warning);
}

.prorank-stat--error .prorank-stat-value,
.prorank-stat--critical .prorank-stat-value {
  color: var(--prorank-error);
}

/* ============================================
   STAT ITEMS
   Individual stat display items
   ============================================ */

.prorank-stat-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: var(--prorank-radius-sm);
  transition: var(--prorank-transition);
}

.prorank-stat-item:hover {
  background: var(--prorank-bg-secondary);
}

.prorank-stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--prorank-bg-tertiary);
  border-radius: 12px;
  font-size: 24px;
  color: var(--prorank-primary);
  flex-shrink: 0;
}

.prorank-stat-icon--gradient {
  background: var(--prorank-gradient);
  color: white;
}

.prorank-stat-content {
  flex: 1;
}

.prorank-stat-item .prorank-stat-value {
  font-size: 24px;
  margin-bottom: 4px;
}

.prorank-stat-item .prorank-stat-label {
  font-size: 13px;
}

/* ============================================
   METRICS GRID
   Grid layout for metrics
   ============================================ */

.prorank-metrics-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

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

.prorank-metrics-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.prorank-metrics-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   METRIC CARDS
   Advanced metric display cards
   ============================================ */

.prorank-metric-card {
  background: white;
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm);
  padding: 20px;
  position: relative;
  transition: var(--prorank-transition);
}

.prorank-metric-card:hover {
  box-shadow: var(--prorank-shadow);
  border-color: var(--prorank-primary);
}

/* Metric Card Headers */
.prorank-metric-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.prorank-metric-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--prorank-bg-tertiary);
  border-radius: 8px;
  font-size: 16px;
}

.prorank-metric-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--prorank-text-secondary);
  flex: 1;
}

/* Metric Values */
.prorank-metric-value-container {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.prorank-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--prorank-text);
  font-variant-numeric: tabular-nums;
}

.prorank-metric-unit {
  font-size: 14px;
  color: var(--prorank-text-secondary);
}

/* Metric Trends */
.prorank-metric-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.prorank-metric-trend--up {
  background: rgba(16, 185, 129, 0.1);
  color: var(--prorank-success);
}

.prorank-metric-trend--up::before {
  content: '↑';
}

.prorank-metric-trend--down {
  background: rgba(239, 68, 68, 0.1);
  color: var(--prorank-error);
}

.prorank-metric-trend--down::before {
  content: '↓';
}

.prorank-metric-trend--stable {
  background: var(--prorank-bg-tertiary);
  color: var(--prorank-text-secondary);
}

.prorank-metric-trend--stable::before {
  content: '→';
}

/* ============================================
   PROGRESS BARS
   Linear progress indicators
   ============================================ */

.prorank-progress {
  margin: 16px 0;
}

.prorank-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.prorank-progress-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--prorank-text);
}

.prorank-progress-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--prorank-primary);
}

.prorank-progress-bar {
  height: 8px;
  background: var(--prorank-bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.prorank-progress-fill {
  height: 100%;
  background: var(--prorank-gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
}

/* Animated progress */
.prorank-progress-fill--animated::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progressShine 2s linear infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Progress Bar Sizes */
.prorank-progress-bar--small {
  height: 4px;
}

.prorank-progress-bar--large {
  height: 12px;
}

/* Progress Bar Colors */
.prorank-progress--success .prorank-progress-fill {
  background: var(--prorank-success);
}

.prorank-progress--warning .prorank-progress-fill {
  background: var(--prorank-warning);
}

.prorank-progress--error .prorank-progress-fill {
  background: var(--prorank-error);
}

/* ============================================
   CIRCULAR PROGRESS
   Circular/donut progress indicators
   ============================================ */

.prorank-circular-progress {
  position: relative;
  width: 120px;
  height: 120px;
}

.prorank-circular-progress-svg {
  transform: rotate(-90deg);
}

.prorank-circular-progress-bg {
  fill: none;
  stroke: var(--prorank-bg-tertiary);
  stroke-width: 8;
}

.prorank-circular-progress-fill {
  fill: none;
  stroke: var(--prorank-primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

.prorank-circular-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.prorank-circular-progress-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--prorank-text);
  display: block;
}

.prorank-circular-progress-label {
  font-size: 12px;
  color: var(--prorank-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Circular Progress Sizes */
.prorank-circular-progress--small {
  width: 80px;
  height: 80px;
}

.prorank-circular-progress--small .prorank-circular-progress-value {
  font-size: 18px;
}

.prorank-circular-progress--large {
  width: 160px;
  height: 160px;
}

.prorank-circular-progress--large .prorank-circular-progress-value {
  font-size: 32px;
}

/* ============================================
   SPARKLINES
   Mini charts for trends
   ============================================ */

.prorank-sparkline {
  display: inline-block;
  width: 100px;
  height: 30px;
  vertical-align: middle;
}

.prorank-sparkline-path {
  fill: none;
  stroke: var(--prorank-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prorank-sparkline-area {
  fill: rgba(37, 99, 235, 0.1);
}

/* ============================================
   COMPARISON METRICS
   Side-by-side metric comparison
   ============================================ */

.prorank-metric-comparison {
  display: flex;
  gap: 20px;
  padding: 20px;
  background: white;
  border: 1px solid var(--prorank-border);
  border-radius: var(--prorank-radius-sm);
}

.prorank-metric-comparison-item {
  flex: 1;
  text-align: center;
  position: relative;
}

.prorank-metric-comparison-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 20%;
  height: 60%;
  width: 1px;
  background: var(--prorank-border);
}

.prorank-metric-comparison-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.prorank-metric-comparison-label {
  font-size: 13px;
  color: var(--prorank-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prorank-metric-comparison-change {
  margin-top: 8px;
  font-size: 12px;
}

/* ============================================
   LOADING STATES
   Skeleton loaders for metrics
   ============================================ */

.prorank-metric-skeleton {
  background: var(--prorank-bg-tertiary);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.prorank-metric-skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.prorank-metric-skeleton--value {
  width: 120px;
  height: 32px;
  margin-bottom: 8px;
}

.prorank-metric-skeleton--label {
  width: 80px;
  height: 16px;
}

/* ============================================
   RESPONSIVE DESIGN
   Mobile adjustments
   ============================================ */

@media (max-width: 768px) {
  .prorank-metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .prorank-metrics-grid--2,
  .prorank-metrics-grid--3,
  .prorank-metrics-grid--4 {
    grid-template-columns: 1fr;
  }
  
  .prorank-stat-value {
    font-size: 24px;
  }
  
  .prorank-metric-comparison {
    flex-direction: column;
    gap: 16px;
  }
  
  .prorank-metric-comparison-item::after {
    display: none;
  }
}