/* ============================================
   Styles pour la page Statistiques
   ============================================ */

/* Onglets */
.stats-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: #f3f4f6;
  padding: 6px;
  border-radius: 12px;
}

.stats-tab {
  flex: 1;
  padding: 12px 24px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.stats-tab:hover {
  color: #374151;
  background: rgba(255, 255, 255, 0.5);
}

.stats-tab.active {
  background: white;
  color: #8b5cf6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Contenu des onglets */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cartes statistiques */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 12px;
}

.stat-content h3 {
  margin: 0;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-top: 4px;
}

.stat-sub {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 2px;
}

/* Cartes colorées */
.stat-card-green {
  border-left: 4px solid #10b981;
}

.stat-card-green .stat-icon {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.stat-card-blue {
  border-left: 4px solid #3b82f6;
}

.stat-card-blue .stat-icon {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.stat-card-orange {
  border-left: 4px solid #f59e0b;
}

.stat-card-orange .stat-icon {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.stat-card-red {
  border-left: 4px solid #ef4444;
}

.stat-card-red .stat-icon {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}

/* Section rentabilité */
.profitability-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.profit-card {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  border-radius: 16px;
  padding: 24px;
  color: white;
  text-align: center;
}

.profit-card h3 {
  margin: 0 0 12px 0;
  font-size: 1rem;
  opacity: 0.9;
}

.profit-value {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.profit-value.negative {
  color: #fca5a5;
}

.profit-value.positive {
  color: #a7f3d0;
}

.profit-detail {
  font-size: 0.9rem;
  opacity: 0.85;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profit-separator {
  font-size: 1.2rem;
}

/* Chart wrapper large */
.chart-wrapper-large {
  position: relative;
  height: 350px;
}

/* Grille statut paiements */
.payment-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.payment-status-item {
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.payment-status-item h4 {
  margin: 0 0 8px 0;
  font-size: 0.85rem;
  color: #6b7280;
}

.payment-status-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.payment-status-count {
  font-size: 0.85rem;
  color: #9ca3af;
  margin-top: 4px;
}

.status-paid { color: #10b981; }
.status-pending { color: #f59e0b; }
.status-overdue { color: #ef4444; }
.status-partial { color: #6366f1; }
.status-cancelled { color: #6b7280; }

/* Grille de graphiques */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.chart-container {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-container h2 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  color: #374151;
}

.chart-wrapper {
  position: relative;
  height: 300px;
}

/* Top catégories */
.top-categories {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-category-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 8px;
  transition: background 0.2s;
}

.top-category-item:hover {
  background: #f3f4f6;
}

.top-category-rank {
  font-size: 1.5rem;
  font-weight: 700;
  color: #8b5cf6;
  width: 40px;
  text-align: center;
}

.top-category-rank.gold { color: #f59e0b; }
.top-category-rank.silver { color: #9ca3af; }
.top-category-rank.bronze { color: #d97706; }

.top-category-info {
  flex: 1;
}

.top-category-name {
  font-weight: 600;
  color: #111827;
}

.top-category-count {
  font-size: 0.85rem;
  color: #6b7280;
}

.top-category-amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
}

.top-category-percent {
  font-size: 0.85rem;
  color: #6b7280;
  margin-left: 8px;
}

.top-category-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.top-category-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 100%);
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

/* Tableau mensuel */
#table-mensuel {
  width: 100%;
}

#table-mensuel th {
  background: #f9fafb;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
}

#table-mensuel td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.evolution-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.evolution-up {
  background: #fee2e2;
  color: #dc2626;
}

.evolution-down {
  background: #dcfce7;
  color: #16a34a;
}

.evolution-neutral {
  background: #f3f4f6;
  color: #6b7280;
}

/* Comparaison année précédente */
.comparison-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.comparison-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.comparison-card h4 {
  margin: 0 0 8px 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.comparison-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #111827;
}

.comparison-diff {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.comparison-diff.positive {
  color: #dc2626;
}

.comparison-diff.negative {
  color: #16a34a;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-card {
    flex-direction: column;
    text-align: center;
    padding: 16px;
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 2rem;
  }
  
  .stat-value {
    font-size: 1.2rem;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-wrapper {
    height: 250px;
  }
}

@media (max-width: 480px) {
  .stats-cards {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    flex-direction: row;
    text-align: left;
  }
}
