/**
 * =============================================================================
 * 04-charts.css
 * =============================================================================
 * Estils per gràfiques Chart.js: canvas, wrappers, legends, tooltips i estats.
 *
 * @package    temperatura.viladrau.online
 * @author     Andreu Pujol <hola@andreupujol.dev>
 * @version    1.0.0
 * @created    2025-11-27
 * =============================================================================
 */

/* =============================================================================
   1. Chart card (container de gràfiques)
   ============================================================================= */
.chart-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 14px 50px rgba(15, 23, 42, 0.25);
  min-height: 320px;
  border: 1px solid rgba(226, 232, 240, 0.6);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Assegurar que els contenidors de gràfiques ocupin tot l'espai */
.chart-card > div[id$="Chart"] {
  flex: 1;
  min-height: 0;
}

.hourly-card {
  min-height: 360px;
}

/* =============================================================================
   2. Canvas styling
   ============================================================================= */
.chart-card canvas {
  width: 100% !important;
  font-family: var(--font-family-base);
  letter-spacing: 0.3px;
  display: block;
}

/* Canvas agregats amb altura específica */
#dailyChart,
#weeklyChart,
#monthlyChart,
#yearlyChart {
  width: 100% !important;
  height: 280px !important;
  max-height: 280px !important;
}

/* Altures específiques per gràfiques principals - Ocupen tot l'espai disponible */
#historicChart {
  height: 300px;
  width: 100% !important;
  flex: 0 0 300px; /* força l'alçada perquè no s'escurci amb flex */
}

#predictionChart {
  height: 300px !important;
  width: 100% !important;
  margin-top: 0;
  padding: 0;
}

/* Container per evitar que les icones quedin tallades */
#hourlyChartContainer {
  padding-top: 8px;
  padding-bottom: 4px;
}

/* =============================================================================
   3. Chart empty state
   ============================================================================= */
.chart-empty {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 6px;
}

/* =============================================================================
   4. Skeleton loading (estat de càrrega)
   ============================================================================= */
.chart-skeleton {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-header {
  width: 40%;
  height: 24px;
  background: linear-gradient(
    90deg,
    var(--color-slate-100) 25%,
    var(--border-color) 50%,
    var(--color-slate-100) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  flex: 1;
}

.skeleton-bar {
  flex: 1;
  background: linear-gradient(
    90deg,
    var(--color-slate-100) 25%,
    var(--border-color) 50%,
    var(--color-slate-100) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px 4px 0 0;
}

.skeleton-bar:nth-child(1) {
  height: 50%;
  animation-delay: 0s;
}

.skeleton-bar:nth-child(2) {
  height: 75%;
  animation-delay: 0.1s;
}

.skeleton-bar:nth-child(3) {
  height: 40%;
  animation-delay: 0.2s;
}

.skeleton-bar:nth-child(4) {
  height: 85%;
  animation-delay: 0.3s;
}

.skeleton-bar:nth-child(5) {
  height: 60%;
  animation-delay: 0.4s;
}

.skeleton-bar:nth-child(6) {
  height: 70%;
  animation-delay: 0.5s;
}

.skeleton-bar:nth-child(7) {
  height: 55%;
  animation-delay: 0.6s;
}

.skeleton-bar:nth-child(8) {
  height: 80%;
  animation-delay: 0.7s;
}

/* =============================================================================
   5. Chart loading states
   ============================================================================= */
.chart-loading {
  position: relative;
  overflow: hidden;
}

.chart-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--color-primary), 
    transparent
  );
  animation: loadingBar 1.5s ease-in-out infinite;
}

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

.chart-loaded {
  animation: fadeIn 0.4s ease-in;
}
