/* =========================================================
   Composants DevGate (boutons, cartes, badges, stepper, tables)
   ========================================================= */

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: transform var(--dur-1) var(--ease-out),
              background var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              color var(--dur-2) var(--ease-out);
  line-height: 1;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent-500);
  color: white;
  box-shadow: 0 2px 0 rgba(0,0,0,.04), 0 6px 12px rgba(247,116,28,.25);
}
.btn-primary:hover { background: var(--accent-600); }
.btn-ghost {
  background: transparent;
  color: var(--primary-700);
  border: 1px solid var(--surface-3);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--primary-300); }
.btn-dark {
  background: var(--primary-700);
  color: white;
}
.btn-dark:hover { background: var(--primary-800); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f2c5c0;
}
.btn-danger:hover { background: #f6d0cb; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--surface-3);
  padding: 20px;
  transition: border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              transform var(--dur-2) var(--ease-out);
}
.card-accent {
  background: var(--grad-brand);
  color: white;
  border: none;
}
.card-accent h2, .card-accent p { color: white; }

.card-hoverable:hover {
  border-color: var(--primary-300);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--surface-2);
  color: var(--ink-700);
}
.badge.ok       { background: var(--ok-bg);       color: var(--ok); }
.badge.warn     { background: var(--warn-bg);     color: var(--warn); }
.badge.danger   { background: var(--danger-bg);   color: var(--danger); }
.badge.idle     { background: var(--idle-bg);     color: var(--idle); }
.badge.primary  { background: var(--primary-100); color: var(--primary-700); }
.badge.accent   { background: var(--accent-100);  color: var(--accent-600); }
.badge.dark     { background: var(--primary-900); color: white; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--idle);
  display: inline-block;
}
.dot.live {
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(47,171,107,.5);
  animation: pulse 1.8s infinite;
}

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.data-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-500);
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--surface-3);
  font-weight: 600;
  position: sticky; top: 0;
}
.data-table tbody tr {
  transition: background var(--dur-1) var(--ease-out);
}
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-name { display: flex; align-items: center; gap: 10px; }
.data-table .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad-brand);
  color: white; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
/* Avatar reutilisable partout (initiales colorees), pas juste dans les tables */
.avatar {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  color: white; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--grad-brand);
  overflow: hidden;
  letter-spacing: .02em;
}
.avatar::before {
  /* Motif diagonal discret pour donner une texture aux pastilles */
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(135deg,
      rgba(255,255,255,.12) 0 2px,
      transparent 2px 10px);
  pointer-events: none;
  opacity: .55;
}
.avatar > span { position: relative; z-index: 1; }
/* Teintes variables par hash d'email (ajoutees en inline via --tint) */
.avatar[style*="--tint"] {
  background:
    linear-gradient(135deg,
      hsl(var(--tint), 55%, 38%),
      hsl(calc(var(--tint) + 40), 60%, 52%));
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  gap: 0;
  align-items: stretch;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--surface-3);
  background: var(--surface-1);
}
.step {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: background var(--dur-2) var(--ease-out);
  cursor: default;
}
.step + .step { border-left: 1px solid var(--surface-3); }
.step.accessible { cursor: pointer; }
.step.accessible:hover { background: var(--surface-2); }
.step.current {
  background: var(--grad-accent);
  color: white;
}
.step.current .step-title, .step.current .step-meta,
.step.current .step-number { color: white; }
.step.done { background: var(--grad-brand); color: white; }
.step.done .step-title, .step.done .step-meta,
.step.done .step-number { color: white; }
.step.locked { opacity: .55; }
.step-number {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-500);
}
.step-title { font-size: 14px; font-weight: 700; color: var(--ink-900); }
.step-meta  { font-size: 12px; color: var(--ink-500); }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad-brand);
  opacity: .9;
}
.kpi.accent::before { background: var(--grad-accent); }
.kpi-value {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  line-height: 1.1;
}
.kpi-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-500);
}
.kpi-sub { font-size: 12px; color: var(--ink-500); margin-top: 4px; }

/* ---------- Form ---------- */
.form-field {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-field label {
  font-size: 12px; font-weight: 600;
  color: var(--ink-700);
  letter-spacing: .02em;
}
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,39,51,.6);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 200;
  animation: fadeIn var(--dur-2) var(--ease-out);
}
.modal {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
  box-shadow: var(--shadow-2);
}
.modal h2 { margin-bottom: 12px; }
.modal-close {
  position: absolute; top: 18px; right: 20px;
  color: var(--ink-500); font-size: 20px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--primary-900);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: fadeIn var(--dur-2) var(--ease-out);
  min-width: 220px;
  max-width: 420px;
}
.toast.ok     { background: #115c3b; }
.toast.warn   { background: #8a600a; }
.toast.danger { background: #7f1e17; }

/* ---------- Progress ---------- */
.progress {
  height: 6px; border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: var(--grad-accent);
  transition: width var(--dur-3) var(--ease-out);
}

/* ---------- Ring gauge ---------- */
.ring {
  --p: 0;
  --size: 60px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background:
    conic-gradient(var(--accent-500) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::after {
  content: "";
  position: absolute; inset: 5px;
  background: var(--surface-1);
  border-radius: 50%;
  background-image:
    radial-gradient(circle at 30% 30%, rgba(11,79,108,.06), transparent 60%),
    /* Motif de fond en chevrons : identifie visuellement la pastille "progression" */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b4f6c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' opacity='0.18'><polyline points='8 18 14 12 8 6'/><polyline points='13 18 19 12 13 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 55% 55%;
}
.ring > span {
  position: relative;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-700);
  letter-spacing: -.01em;
}
/* Variante "gros anneau" (hero candidat) : motif plus presente */
.ring.ring-lg::after {
  background-size: 42% 42%;
}

/* ---------- Tag chip ---------- */
.chip {
  display: inline-flex; align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--primary-100);
  color: var(--primary-700);
  font-size: 11.5px;
  font-weight: 600;
}

/* ---------- Code block ---------- */
pre.code-block {
  background: var(--primary-900);
  color: #e7f3f8;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid rgba(255,255,255,.05);
}
pre.code-block .kw { color: #ffb366; }
