/* ============================================================
   MODCOD PMO — Components (réutilisables, tokens-based)
   À utiliser en remplacement des styles inline.
   ============================================================ */

/* ── FORMS UNIFIÉS ──────────────────────────────────────────
   Remplace .lbl / .inp / .inp-jh / .inp-phase / form inputs inline
   ─────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  margin-bottom: var(--space-2xs);
  letter-spacing: .01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: var(--fs-md);
  font-family: var(--font-body);
  color: var(--text-body);
  background: var(--bg-surface);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-faint); }

.form-input[readonly],
.form-input:disabled { background: var(--gray-100); cursor: not-allowed; }

/* Input sur fond sombre (sidebar, modals dark) — fix contraste P0 */
.form-input--dark,
.form-select--dark {
  background: var(--gray-800);
  color: var(--text-on-dark);
  border-color: var(--gray-700);
}
.form-input--dark::placeholder { color: var(--gray-400); }
.form-input--dark:focus { border-color: var(--color-primary); box-shadow: var(--shadow-focus); }

/* Input compact (cellules timesheet, tableaux planning) */
.form-input--compact {
  padding: 4px 8px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

/* ── BOUTONS ÉTENDUS ────────────────────────────────────────
   .btn-primary et .btn-secondary existent déjà dans pmo.css
   On ajoute les variantes manquantes
   ─────────────────────────────────────────────────────────── */
.btn-ghost {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-md);
  border: none; cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-body); text-decoration: none; }

.btn-danger {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: 8px 14px;
  background: var(--color-danger);
  color: var(--text-inverse);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  border-radius: var(--radius-md);
  border: none; cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), transform .1s;
}
.btn-danger:hover { background: var(--color-danger-deep); transform: translateY(-1px); color: var(--text-inverse); text-decoration: none; }

.btn-success {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: 8px 14px;
  background: var(--color-success);
  color: var(--text-inverse);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  border-radius: var(--radius-md);
  border: none; cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), transform .1s;
}
.btn-success:hover { background: var(--color-success-deep); transform: translateY(-1px); color: var(--text-inverse); text-decoration: none; }

.btn-sm { padding: 6px 10px; font-size: var(--fs-sm); }
.btn-xs { padding: 4px 8px; font-size: var(--fs-xs); }

/* ── CARDS UNIVERSELLES ─────────────────────────────────────
   Remplace .dv2-card, .dash-card, .pv-card, .cap-card divergents
   ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card--padded { padding: var(--space-lg); }
.card--padded-lg { padding: var(--space-xl); }
.card--hoverable { transition: box-shadow var(--transition-base), transform var(--transition-base); }
.card--hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
}
.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  font-family: var(--font-display);
  letter-spacing: -.01em;
  margin: 0;
}
.card-body { padding: var(--space-lg); }

/* Accent stripe (3px top bar) — variants */
.card--accent { position: relative; overflow: hidden; }
.card--accent::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--color-primary);
}
.card--accent-success::before { background: var(--color-success); }
.card--accent-warn::before    { background: var(--color-warn); }
.card--accent-danger::before  { background: var(--color-danger); }
.card--accent-violet::before  { background: var(--color-violet); }

/* ── KPI CARD (universelle) ─────────────────────────────────
   Remplace .pmo-kpi + 7 redéfinitions inline
   ─────────────────────────────────────────────────────────── */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  min-width: 130px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}
.kpi:hover { box-shadow: var(--shadow-sm); }

.kpi-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  margin-bottom: var(--space-2xs);
  font-family: var(--font-display);
}
.kpi-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extra);
  color: var(--text-primary);
  line-height: var(--lh-tight);
  font-family: var(--font-display);
  letter-spacing: -.02em;
}
.kpi-sub {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: var(--space-2xs);
}
.kpi-accent {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--color-primary);
}

/* Variantes sémantiques */
.kpi--primary .kpi-accent { background: var(--color-primary); }
.kpi--success .kpi-accent { background: var(--color-success); }
.kpi--warn    .kpi-accent { background: var(--color-warn); }
.kpi--danger  .kpi-accent { background: var(--color-danger); }
.kpi--info    .kpi-accent { background: var(--color-info); }
.kpi--violet  .kpi-accent { background: var(--color-violet); }

.kpi--primary .kpi-value { color: var(--color-primary); }
.kpi--success .kpi-value { color: var(--color-success-deep); }
.kpi--warn    .kpi-value { color: var(--color-warn-deep); }
.kpi--danger  .kpi-value { color: var(--color-danger-deep); }
.kpi--info    .kpi-value { color: var(--color-info-deep); }
.kpi--violet  .kpi-value { color: var(--color-violet-deep); }

/* ── ALERTES ────────────────────────────────────────────────
   Remplace .alert-box-head inline 3 fois
   ─────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
  background: var(--bg-surface-alt);
  color: var(--text-body);
  font-size: var(--fs-md);
}
.alert--info    { border-left-color: var(--color-info);    background: var(--color-info-soft); }
.alert--success { border-left-color: var(--color-success); background: var(--color-success-soft); }
.alert--warn    { border-left-color: var(--color-warn);    background: var(--color-warn-soft); }
.alert--danger  { border-left-color: var(--color-danger);  background: var(--color-danger-soft); }

.alert-title {
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  color: var(--text-primary);
  margin: 0 0 var(--space-2xs);
}

/* ── BADGES SUPPLÉMENTAIRES ─────────────────────────────────
   Complète .tag, .badge-* existants
   ─────────────────────────────────────────────────────────── */
.badge-critical { background: var(--color-danger-soft); color: var(--color-danger-deep); }
.badge-warning  { background: var(--color-warn-soft);   color: var(--color-warn-deep); }
.badge-info     { background: var(--color-info-soft);   color: var(--color-info-deep); }
.badge-ok       { background: var(--color-success-soft);color: var(--color-success-deep); }

/* ── AVATARS (typologie consultants) ────────────────────────
   Remplace les `background:{{ typo_colors.get(...) }}` inline
   ─────────────────────────────────────────────────────────── */
.avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-inverse);
  font-family: var(--font-display);
  letter-spacing: .02em;
  background: var(--typo-dft);
  flex-shrink: 0;
}
.avatar--sm { width: 22px; height: 22px; font-size: var(--fs-2xs); }
.avatar--lg { width: 36px; height: 36px; font-size: var(--fs-sm); }

.avatar--cp    { background: var(--typo-cp); }
.avatar--cs    { background: var(--typo-cs); }
.avatar--cmoa  { background: var(--typo-cmoa); }
.avatar--cmoe  { background: var(--typo-cmoe); }
.avatar--cj    { background: var(--typo-cj); }

/* ── LEGEND SWATCH ──────────────────────────────────────────
   Remplace les 6+ <span style="background:#..."> inline
   ─────────────────────────────────────────────────────────── */
.legend {
  display: inline-flex; align-items: center; gap: var(--space-sm);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-right: var(--space-md);
}
.legend-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: var(--radius-xs);
  background: var(--color-primary);
}
.legend-swatch--primary { background: var(--color-primary); }
.legend-swatch--success { background: var(--color-success); }
.legend-swatch--warn    { background: var(--color-warn); }
.legend-swatch--danger  { background: var(--color-danger); }
.legend-swatch--info    { background: var(--color-info); }
.legend-swatch--violet  { background: var(--color-violet); }
.legend-swatch--muted   { background: var(--gray-400); }

/* ── EMPTY STATES UNIFIÉS ───────────────────────────────────
   Remplace les empty states disparates (emoji 4xl vs texte gris)
   ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-lg);
}
.empty-state-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-md);
  color: var(--text-faint);
}
.empty-state-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-body);
  margin: 0 0 var(--space-2xs);
}
.empty-state-text {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  max-width: 280px;
}

/* ── PROGRESS BAR UNIFIÉE ───────────────────────────────────
   Remplace les 4+ implémentations divergentes
   ─────────────────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.progress--sm { height: 3px; }
.progress--md { height: 8px; }
.progress--lg { height: 12px; }

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
}
.progress-bar--success { background: var(--color-success); }
.progress-bar--warn    { background: var(--color-warn); }
.progress-bar--danger  { background: var(--color-danger); }
.progress-bar--info    { background: var(--color-info); }
.progress-bar--violet  { background: var(--color-violet); }

/* ── MODAL UNIFIÉE ──────────────────────────────────────────
   Remplace les modals diverses (dv2-modal, ts-modal, planning-modal)
   ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-lg);
  animation: modal-overlay-in var(--transition-base);
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  animation: modal-in var(--transition-base);
}
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 880px; }
.modal--xl { max-width: 1120px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -.01em;
}
.modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: var(--fs-lg); color: var(--text-muted);
  padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover { background: var(--gray-100); color: var(--text-body); }
.modal-body   { padding: var(--space-xl); overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: var(--space-sm); justify-content: flex-end;
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
}

@keyframes modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── ANIMATIONS GLOBALES (page load staggered reveals) ───── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fade-in-up .4s ease both;
}
.animate-stagger > * { animation: fade-in-up .4s ease both; }
.animate-stagger > *:nth-child(1) { animation-delay: .05s; }
.animate-stagger > *:nth-child(2) { animation-delay: .1s; }
.animate-stagger > *:nth-child(3) { animation-delay: .15s; }
.animate-stagger > *:nth-child(4) { animation-delay: .2s; }
.animate-stagger > *:nth-child(5) { animation-delay: .25s; }
.animate-stagger > *:nth-child(6) { animation-delay: .3s; }
.animate-stagger > *:nth-child(7) { animation-delay: .35s; }
.animate-stagger > *:nth-child(8) { animation-delay: .4s; }

/* Pulse pour cellules actives (heatmap, alertes) */
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, .4); }
  50%      { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}
.pulse-soft { animation: pulse-soft 2s ease-in-out infinite; }

/* ── HELPERS ATOMIQUES ──────────────────────────────────────
   Quelques utilities pour remplacer Tailwind ponctuellement
   ─────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }
.text-success{ color: var(--color-success); }
.text-warn   { color: var(--color-warn); }
.text-danger { color: var(--color-danger); }
.text-info   { color: var(--color-info); }
.text-primary{ color: var(--color-primary); }

.font-display { font-family: var(--font-display); }
.font-mono    { font-family: var(--font-mono); }

.fw-medium   { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ── A11Y : Focus visible global ─────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
button, a, input, select, textarea {
  outline: none;
}

/* Sr-only (lecteur d'écran) */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
