/* ==========================================================================
   LE41 PRO - STATISTIQUES & ANALYSES AVANCÉES
   Dynamic Charts, Bento Grid Analytics, Filter Pills & Metric Meters
   ========================================================================== */

/* Stats Header & Controls Bar */
.stats-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stats-header-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #10b981, #f59e0b);
}

.stats-controls-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Filter Pill Badges */
.filter-pills-wrap {
  display: flex;
  background: var(--bg-input);
  padding: 0.25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  gap: 0.2rem;
}

.filter-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-pill-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.filter-pill-btn.active {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* Category Filter Tabs */
.stats-category-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

.category-tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.category-tab-btn:hover {
  border-color: var(--color-primary);
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.category-tab-btn.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

/* Stats Bento Grid */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.stats-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stats-kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--color-primary));
  opacity: 0.8;
}

.stats-kpi-card.accent-emerald { --card-accent: #10b981; }
.stats-kpi-card.accent-blue { --card-accent: #3b82f6; }
.stats-kpi-card.accent-amber { --card-accent: #f59e0b; }
.stats-kpi-card.accent-purple { --card-accent: #8b5cf6; }
.stats-kpi-card.accent-rose { --card-accent: #f43f5e; }

.stats-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.stats-kpi-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.stats-kpi-value {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.stats-kpi-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stats-kpi-footer .badge-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
}

.badge-trend.up-good {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-trend.down-good {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-trend.up-bad {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Charts Grid Layout */
.stats-charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
}

.chart-box.col-8 {
  grid-column: span 8;
}

.chart-box.col-4 {
  grid-column: span 4;
}

.chart-box.col-6 {
  grid-column: span 6;
}

.chart-box.col-12 {
  grid-column: span 12;
}

@media (max-width: 1100px) {
  .chart-box.col-8, .chart-box.col-4, .chart-box.col-6 {
    grid-column: span 12;
  }
}

.chart-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}

.chart-box-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-box-title i {
  color: var(--color-primary);
}

.chart-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 270px;
  width: 100%;
}

.chart-canvas-wrap.doughnut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
}

/* Analytical Breakdown Table */
.stats-breakdown-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.stats-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meter-bar-wrap {
  width: 100%;
  max-width: 140px;
  height: 7px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.meter-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

.stats-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
