/**
 * Design System — Démarche Croisée
 * Composants premium additifs (n'écrase pas components.css / dashboard.css).
 * Palette : dérivée du logo (bleu, cyan, violet, magenta, vert, jaune, orange, rouge).
 */

/* ---------- Typographie / utilitaires ---------- */
.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-lg);
}

.btn-gradient {
  background: var(--gradient-brand);
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-glow-blue);
}

.btn-gradient:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(10, 165, 224, 0.32);
}

.btn-gradient:active:not(:disabled) {
  transform: translateY(0);
}

/* ---------- Hero / bannière du Centre de Pilotage ---------- */
.control-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  padding: var(--sp-3xl);
  margin-bottom: var(--sp-2xl);
  background: var(--gradient-navy);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

.control-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-engine);
  opacity: 0.18;
  mix-blend-mode: screen;
  pointer-events: none;
}

.control-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #bfe9ff;
  margin-bottom: var(--sp-md);
}

.control-hero-eyebrow .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #33e08a;
  box-shadow: 0 0 0 3px rgba(51, 224, 138, 0.25);
  animation: pulseDot 1.8s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(51, 224, 138, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(51, 224, 138, 0.12); }
}

.control-hero h1 {
  position: relative;
  font-size: 1.7rem;
  margin-bottom: var(--sp-sm);
}

.control-hero p {
  position: relative;
  max-width: 640px;
  color: #cfe0f5;
  font-size: 0.95rem;
}

/* ---------- Cartes premium (grille du dashboard) ---------- */
.pilot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: var(--sp-2xl);
  margin-bottom: var(--sp-2xl);
}

.card-premium {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  padding: var(--sp-2xl);
  box-shadow: var(--shadow-xs);
  transition: var(--transition-smooth);
}

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

.card-premium-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.card-premium-header h3 {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* ---------- Opportunités détectées ---------- */
.opportunity-stats {
  display: grid;
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.stat-line {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.stat-line-value {
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 42px;
  text-align: center;
  border-radius: var(--radius-md);
  padding: 2px 6px;
  color: #fff;
}

.stat-line-label {
  color: var(--ink);
  font-size: 0.875rem;
}

/* Couleurs dégradées par ligne (reprend la palette du logo) */
.stat-line:nth-child(1) .stat-line-value { background: var(--brand-blue); }
.stat-line:nth-child(2) .stat-line-value { background: var(--brand-green); }
.stat-line:nth-child(3) .stat-line-value { background: var(--brand-purple); }
.stat-line:nth-child(4) .stat-line-value { background: var(--brand-orange); }
.stat-line:nth-child(5) .stat-line-value { background: var(--brand-magenta); }
.stat-line:nth-child(6) .stat-line-value { background: var(--brand-red); }

/* ---------- Machine IA (pipeline) ---------- */
.pipeline {
  display: grid;
  gap: var(--sp-sm);
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  transition: var(--transition-smooth);
}

.pipeline-step-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg);
}

.pipeline-step-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.pipeline-step-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pipeline-step[data-status="pending"] { opacity: 0.6; }
.pipeline-step[data-status="pending"] .pipeline-step-status { background: #f3f4f6; color: #6b7280; }
.pipeline-step[data-status="pending"] .pipeline-step-icon { background: #f3f4f6; }

.pipeline-step[data-status="running"] {
  border-color: rgba(10, 165, 224, 0.4);
  background: rgba(10, 165, 224, 0.05);
}
.pipeline-step[data-status="running"] .pipeline-step-status { background: #e0f2fe; color: #0369a1; }
.pipeline-step[data-status="running"] .pipeline-step-icon {
  background: var(--brand-blue);
  color: #fff;
  animation: spinIcon 1s linear infinite;
}

@keyframes spinIcon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pipeline-step[data-status="done"] { border-color: rgba(18, 159, 107, 0.35); }
.pipeline-step[data-status="done"] .pipeline-step-status { background: #dcfce7; color: #166534; }
.pipeline-step[data-status="done"] .pipeline-step-icon { background: var(--brand-green); color: #fff; }

.pipeline-step[data-status="error"] { border-color: rgba(229, 67, 46, 0.35); }
.pipeline-step[data-status="error"] .pipeline-step-status { background: #fee2e2; color: #b91c1c; }
.pipeline-step[data-status="error"] .pipeline-step-icon { background: var(--brand-red); color: #fff; }

/* ---------- Vente croisée (flux entre entités) ---------- */
.entity-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-sm);
}

.entity-flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--line);
  min-width: 120px;
  text-align: center;
}

.entity-flow-node strong {
  font-size: 0.85rem;
}

.entity-flow-node small {
  color: var(--muted);
  font-size: 0.72rem;
}

.entity-flow-node.entity-cqfd { border-top: 3px solid var(--brand-blue); }
.entity-flow-node.entity-unplus { border-top: 3px solid var(--brand-purple); }
.entity-flow-node.entity-jobco { border-top: 3px solid var(--brand-green); }

.entity-flow-arrow {
  color: var(--muted);
  font-size: 1.2rem;
}

/* ---------- Scores Démarche Croisée ---------- */
.score-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.score-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-lg);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1;
  cursor: default;
}

.score-chip small {
  font-weight: 700;
  font-size: 0.5rem;
  text-transform: uppercase;
  opacity: 0.85;
  margin-top: 2px;
}

.score-chip.chip-cqfd { background: var(--brand-blue); }
.score-chip.chip-unplus { background: var(--brand-purple); }
.score-chip.chip-jobco { background: var(--brand-green); }
.score-chip.chip-global {
  background: var(--gradient-brand);
  cursor: pointer;
  box-shadow: var(--shadow-glow-blue);
}
.score-chip.chip-global:hover { filter: brightness(1.08); }

.score-reasons {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--sp-sm);
}

.score-reasons li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  font-size: 0.85rem;
  color: var(--ink);
}

.score-reasons li::before {
  content: '✔';
  color: var(--brand-green);
  font-weight: 700;
}

/* ---------- Sources de données ---------- */
.sources-category {
  margin-bottom: var(--sp-2xl);
}

.sources-category-title {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 1rem;
  margin-bottom: var(--sp-lg);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-lg);
}

.source-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  transition: var(--transition-smooth);
}

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

.source-card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.source-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  flex-shrink: 0;
  overflow: hidden;
}

.source-logo img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.source-logo.source-logo-letters {
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
}

.source-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.source-desc {
  color: var(--muted);
  font-size: 0.78rem;
  flex: 1;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--muted);
}

.source-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: #fef3c7;
  color: #92400e;
}

/* ---------- Mode Routine ---------- */
.routine-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-xl);
  padding: var(--sp-2xl);
  border-radius: var(--radius-2xl);
  background: var(--gradient-navy);
  color: #fff;
  margin-bottom: var(--sp-2xl);
  box-shadow: var(--shadow-lg);
}

.routine-hero h2 { color: #fff; }
.routine-hero p { color: #cfe0f5; margin-top: 4px; max-width: 480px; }

.switch-xl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-md);
  cursor: pointer;
  user-select: none;
}

.switch-xl input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-xl-track {
  width: 64px;
  height: 34px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  transition: var(--transition-smooth);
}

.switch-xl-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.switch-xl input:checked + .switch-xl-track {
  background: #33e08a;
  border-color: #33e08a;
}

.switch-xl input:checked + .switch-xl-track::after {
  transform: translateX(30px);
}

.switch-xl-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.routine-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-lg);
  margin-bottom: var(--sp-2xl);
}

.routine-stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
}

.routine-stat-label { color: var(--muted); font-size: 0.75rem; margin-bottom: 4px; }
.routine-stat-value { font-size: 1.3rem; font-weight: 800; }

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--sp-xl);
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: '';
  position: absolute;
  left: -28px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--brand-blue);
}

.timeline-item[data-status="done"]::before { background: var(--brand-green); box-shadow: 0 0 0 2px var(--brand-green); }
.timeline-item[data-status="waiting"]::before { background: var(--muted); box-shadow: 0 0 0 2px var(--line); }

.timeline-time {
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--brand-blue);
  margin-bottom: 2px;
}

.timeline-title { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.timeline-desc { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* ---------- Intelligence IA ---------- */
.ai-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-lg);
}

.ai-column-title {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: var(--sp-md);
}

.ai-item {
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-bottom: var(--sp-sm);
  font-size: 0.82rem;
}

.ai-item strong { display: block; color: var(--ink); }
.ai-item span { color: var(--muted); font-size: 0.74rem; }

/* ---------- Skeleton loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, #eef1f5 25%, #e4e9f1 37%, #eef1f5 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}

@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-card { height: 120px; border-radius: var(--radius-xl); }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-lg);
}

/* ---------- Empty states élégants ---------- */
.empty-state-v2 {
  text-align: center;
  padding: var(--sp-4xl) var(--sp-2xl);
  border: 1px dashed var(--line);
  border-radius: var(--radius-2xl);
  background: var(--bg);
}

.empty-state-v2 .empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-lg);
  border-radius: var(--radius-full);
  background: var(--gradient-brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

/* ---------- Dashboard réel : éléments actionnables ---------- */
.is-clickable {
  cursor: pointer;
  transition: var(--transition-smooth);
}

.is-clickable:hover {
  background: var(--bg);
}

.kpi-card.is-clickable:hover {
  border-color: var(--brand-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kpi-card.is-clickable:focus-visible,
.is-clickable:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.kpi-card-alert {
  border-color: rgba(229, 67, 46, 0.4);
  background: rgba(229, 67, 46, 0.03);
}

/* ---------- Charts (src/components/charts.js) ---------- */
.chart-empty {
  padding: var(--sp-xl) 0;
  text-align: center;
}

.chart-bars {
  display: grid;
  gap: var(--sp-md);
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 44px;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius-md);
}

.chart-bar-label {
  font-size: 0.85rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-bar-track {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg);
  overflow: hidden;
}

.chart-bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.chart-bar-value {
  font-weight: 700;
  font-size: 0.85rem;
  text-align: right;
}

.chart-trend {
  position: relative;
}

.chart-trend-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-trend-axis-label {
  font-size: 9px;
  fill: var(--muted);
}

.chart-trend-crosshair {
  stroke: var(--line);
  stroke-width: 1;
  transition: opacity 0.1s ease;
  pointer-events: none;
}

.chart-trend-hit {
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -130%);
  background: var(--ink);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 2;
}

/* ---------- Activité récente ---------- */
.activity-feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.activity-feed-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-sm);
  border-radius: var(--radius-md);
}

.activity-feed-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.activity-feed-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.activity-feed-title {
  font-size: 0.85rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-feed-meta {
  font-size: 0.72rem;
}

/* ---------- Mes tâches ---------- */
.my-tasks-sections {
  display: grid;
  gap: var(--sp-lg);
}

.my-tasks-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: var(--sp-sm);
}

.task-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.task-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-sm);
  border-radius: var(--radius-md);
}

.task-mini-title {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-mini-due {
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ---------- Alertes ---------- */
.alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-sm);
}

.alerts-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
}

.alerts-row-high {
  background: rgba(229, 67, 46, 0.06);
  color: var(--ink);
}

.alerts-row-info {
  background: rgba(10, 165, 224, 0.06);
  color: var(--ink);
}

.alerts-icon {
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .control-hero { padding: var(--sp-2xl); }
  .routine-hero { flex-direction: column; align-items: flex-start; }
  .chart-bar-row { grid-template-columns: 90px 1fr 36px; }
}
