/* =======================================================
   AI Tracker (Emploi) Styles
   Adapted to LIFT design system
   ======================================================= */

/* Container */
.ai-tracker {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Hero KPIs section */
.ai-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .ai-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .ai-kpis { grid-template-columns: 1fr; }
}

.ai-kpi-card {
  background: var(--card, #FAFBFD);
  border: 1px solid var(--border, #D5DDE8);
  border-radius: var(--radius-lg, 0.8rem);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.ai-kpi-card::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 36%;
  background: linear-gradient(180deg, transparent, rgba(95, 132, 232, 0.06));
  z-index: 0;
  pointer-events: none;
}

.ai-kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.08));
}

.ai-kpi-card h4 {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy, #0E2A47);
  margin: 0 0 0.5rem 0;
  position: relative;
  z-index: 1;
}

.ai-kpi-card .kpi-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy, #0E2A47);
  margin: 0.25rem 0;
  position: relative;
  z-index: 1;
}

.ai-kpi-card .kpi-delta {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.8rem;
  color: var(--muted, #55657D);
  position: relative;
  z-index: 1;
}

/* Navigation tabs */
.ai-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.ai-nav-btn {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border, #D5DDE8);
  background: #fff;
  color: var(--navy, #0E2A47);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-nav-btn:hover {
  background: var(--bg-alt, #E6EBF2);
  border-color: var(--cornflower, #5F84E8);
  transform: translateY(-1px);
}

.ai-nav-btn.active {
  background: var(--navy, #0E2A47);
  color: #fff;
  border-color: var(--navy, #0E2A47);
}

/* Chart sections */
.ai-chart-section {
  background: var(--card, #FAFBFD);
  border: 1px solid var(--border, #D5DDE8);
  border-radius: var(--radius-lg, 0.8rem);
  box-shadow: var(--shadow, 0 10px 30px rgba(14, 42, 71, 0.08));
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.ai-chart-section:hover {
  box-shadow: 0 16px 34px rgba(14, 42, 71, 0.12);
}

.ai-chart-section h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy, #0E2A47);
  margin: 0 0 1rem 0;
  text-align: center;
}

/* Chart controls */
.ai-chart-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Download button */
.ai-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md, 0.6rem);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  background: var(--navy, #0E2A47);
  color: #fff;
  border: 1px solid var(--navy, #0E2A47);
  margin-left: auto;
}

.ai-download-btn:hover {
  background: var(--navy-700, #0A1E33);
  border-color: var(--navy-700, #0A1E33);
  transform: translateY(-1px);
}

.ai-download-btn svg {
  flex-shrink: 0;
}

/* Toggle button (slider style) */
.ai-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-toggle-btn {
  position: relative;
  width: 84px;
  height: 32px;
  border: none;
  border-radius: var(--radius-pill, 999px);
  background: var(--muted, #94a3b8);
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.12);
}

.ai-toggle-btn .slider {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.25s;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.ai-toggle-btn.active {
  background: var(--cornflower, #5F84E8);
}

.ai-toggle-btn.active .slider {
  left: 56px;
}

.ai-toggle-label {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #55657D);
  min-width: 100px;
}

/* Tri-state toggle (button group) */
.ai-tri-toggle {
  display: inline-flex;
  border-radius: var(--radius-md, 0.6rem);
  overflow: hidden;
  border: 1px solid var(--border, #D5DDE8);
}

.ai-tri-toggle .tri-btn {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border: none;
  border-right: 1px solid var(--border, #D5DDE8);
  background: #fff;
  color: var(--navy, #0E2A47);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-tri-toggle .tri-btn:last-child {
  border-right: none;
}

.ai-tri-toggle .tri-btn:hover {
  background: var(--bg-alt, #E6EBF2);
}

.ai-tri-toggle .tri-btn.active {
  background: var(--cornflower, #5F84E8);
  color: #fff;
}

/* Chart containers */
.ai-chart-container {
  width: 100%;
  margin: 0 auto;
}

.ai-chart-container canvas {
  max-width: 100%;
}

/* Specific chart heights */
#ai-offersChart { height: 400px; }
#ai-sectorsChart { height: 400px; }
#ai-sectorEvolChart { height: 400px; }
#ai-sizeChart {
  max-width: 350px;
  width: 100%;
  margin: 0 auto;
  display: block;
}

/* Wrapper for pie chart to constrain on mobile */
.ai-chart-container:has(#ai-sizeChart) {
  max-width: 350px;
  margin: 0 auto;
}
#ai-metierChart { height: 500px; }
#ai-skillsChart { height: 400px; }

/* Map row layout */
.ai-map-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

.ai-map-col-main {
  min-width: 0;
}

.ai-map-col-side {
  min-width: 0;
}

/* Map container */
.ai-map-container {
  width: 100%;
  height: 550px;
  margin: 0 auto;
}

.ai-map-container svg {
  width: 100%;
  height: 100%;
}

#ai-mapLegend {
  max-width: 100%;
  margin: 0.5rem auto 0;
}

#ai-mapLegend svg {
  filter: drop-shadow(0 4px 12px rgba(14, 42, 71, 0.12));
}

/* Top 10 chart */
.ai-top10-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy, #0E2A47);
  margin: 0 0 0.75rem 0;
  text-align: center;
}

.ai-top10-chart {
  width: 100%;
  height: 500px;
  background: var(--card, #FAFBFD);
  border: 1px solid var(--border, #D5DDE8);
  border-radius: var(--radius-md, 0.6rem);
}

/* Map tooltip */
.ai-map-tip {
  position: fixed;
  background: var(--card, #FAFBFD);
  color: var(--ink, #0E1320);
  border: 1px solid var(--border, #D5DDE8);
  border-radius: var(--radius-md, 0.6rem);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow, 0 10px 30px rgba(14, 42, 71, 0.08));
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ai-map-tip b {
  color: var(--navy, #0E2A47);
}

/* Map info panel */
.ai-map-info {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--card, #FAFBFD);
  border: 1px solid var(--border, #D5DDE8);
  border-radius: var(--radius-md, 0.6rem);
  min-height: 80px;
}

.ai-map-info-placeholder {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.9rem;
  color: var(--muted, #55657D);
  text-align: center;
  margin: 0;
  font-style: italic;
}

.ai-map-info-content h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy, #0E2A47);
  margin: 0 0 0.25rem 0;
}

.ai-map-info-code {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.8rem;
  color: var(--muted, #55657D);
  margin: 0 0 0.75rem 0;
}

.ai-map-info-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.ai-map-info-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ai-map-info-label {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.75rem;
  color: var(--muted, #55657D);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ai-map-info-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy, #0E2A47);
}

.ai-map-info-pct {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.8rem;
  color: var(--cornflower, #5F84E8);
}

@media (max-width: 600px) {
  .ai-map-info-stats {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Source note */
.ai-source {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-alt, #E6EBF2);
  border-radius: var(--radius-md, 0.6rem);
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.85rem;
  color: var(--muted, #55657D);
}

.ai-source strong {
  color: var(--ink, #0E1320);
}

.ai-source a {
  color: var(--cornflower, #5F84E8);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .ai-tracker {
    padding: 1rem;
  }

  .ai-chart-section {
    padding: 1rem;
  }

  .ai-chart-section h3 {
    font-size: 1.1rem;
  }

  .ai-nav-btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .ai-chart-controls {
    flex-direction: column;
    gap: 0.75rem;
  }

  #ai-offersChart,
  #ai-sectorsChart,
  #ai-sectorEvolChart,
  #ai-skillsChart {
    height: 350px;
  }

  #ai-metierChart {
    height: 400px;
  }

  .ai-map-row {
    grid-template-columns: 1fr;
  }

  .ai-map-container {
    height: 400px;
  }

  .ai-top10-chart {
    height: 350px;
  }

  #ai-sizeChart,
  .ai-chart-container:has(#ai-sizeChart) {
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  .ai-kpi-card .kpi-value {
    font-size: 1.4rem;
  }

  #ai-offersChart,
  #ai-sectorsChart,
  #ai-sectorEvolChart,
  #ai-skillsChart {
    height: 300px;
  }

  #ai-metierChart {
    height: 350px;
  }

  .ai-map-container {
    height: 350px;
  }

  #ai-sizeChart,
  .ai-chart-container:has(#ai-sizeChart) {
    max-width: 220px;
  }
}

/* Print styles */
@media print {
  .ai-nav,
  .ai-chart-controls {
    display: none;
  }

  .ai-chart-section {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* Animation for section reveal */
@keyframes ai-fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ai-chart-section {
  animation: ai-fadeUp 0.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .ai-chart-section {
    animation: none;
  }
}
