/* ============================================================================
   Widget « Résultats de l'analyse IA » — feuille de style
   Aucune dépendance externe : le widget est servi tel quel par Zoho.
   ========================================================================== */

:root {
  --c-bg: #ffffff;
  --c-surface: #f7f8fa;
  --c-border: #e3e6ec;
  --c-border-strong: #cfd4de;

  --c-text: #1b2434;
  --c-text-soft: #5b6577;
  --c-text-muted: #8a93a3;

  --c-primary: #2264d1;
  --c-primary-dark: #1a4fa8;
  --c-primary-soft: #eaf1fd;

  --c-excellent: #128a5c;
  --c-excellent-bg: #e4f5ed;
  --c-high: #2f7d32;
  --c-high-bg: #e9f4e9;
  --c-medium: #9a6b00;
  --c-medium-bg: #fdf3df;
  --c-low: #b3521a;
  --c-low-bg: #fdeee4;
  --c-weak: #b3261e;
  --c-weak-bg: #fdeaea;
  --c-neutral: #5b6577;
  --c-neutral-bg: #eef0f4;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 2px rgba(27, 36, 52, .06), 0 1px 3px rgba(27, 36, 52, .04);
  --shadow-lg: 0 12px 32px rgba(27, 36, 52, .16);

  --ff: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Sans ceci, [hidden] perd contre tout display: … déclaré par une règle de
   cette feuille (même style d'origine « auteur » > agent utilisateur, à
   spécificité égale) : .toolbar { display: flex } resterait visible malgré
   l'attribut hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--c-bg);
}

body {
  font-family: var(--ff);
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- Structure */

.widget {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 16px 18px 10px;
}

.widget__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
}

.widget__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.select--lang {
  min-width: 0;
  width: auto;
  height: 32px;
  padding: 0 24px 0 10px;
  font-size: 12.5px;
  background-position: right 8px center;
}

.widget__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
}

.widget__subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--c-text-soft);
}

.widget__footer {
  margin-top: auto;
  padding-top: 12px;
  text-align: right;
}

/* ----------------------------------------------------------------- Contrôles */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
}

.field { position: relative; }
.field--search { flex: 1 1 220px; min-width: 180px; }

.field__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--c-text-muted);
  pointer-events: none;
}

.input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

.field--search .input { padding-left: 28px; }

.input:hover { border-color: #b6bdca; }

.input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(34, 100, 209, .14);
}

.select {
  min-width: 170px;
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%235b6577' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.btn:hover:not(:disabled) { background: var(--c-surface); border-color: #b6bdca; }

.btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
}

.btn:disabled { opacity: .45; cursor: default; }

.btn--primary {
  color: #fff;
  background: var(--c-primary);
  border-color: var(--c-primary);
}
.btn--primary:hover:not(:disabled) { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }

.btn--ghost { background: transparent; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  font-size: 19px;
  line-height: 1;
  color: var(--c-text-soft);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-btn:hover { background: var(--c-surface); color: var(--c-text); }

.link-btn {
  padding: 0;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--c-text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--c-primary); }

.summary-link {
  color: var(--c-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.summary-link:hover { opacity: 0.85; }

/* -------------------------------------------------------------- Avertissements */

.notices { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }

.notice {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #7a5b00;
  background: #fdf7e6;
  border: 1px solid #f0e0b0;
  border-radius: var(--radius-sm);
}

.notice__icon { flex: none; }

/* -------------------------------------------------------------------- Tableau */

.results {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table__th {
  padding: 0;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--c-text-soft);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.table__th--score { width: 190px; }
.table__th--action { width: 40px; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.sort-btn:hover { color: var(--c-text); }

.sort-btn__arrow { font-size: 9px; color: var(--c-primary); }
.sort-btn[data-active="asc"] .sort-btn__arrow::after { content: "▲"; }
.sort-btn[data-active="desc"] .sort-btn__arrow::after { content: "▼"; }

.row {
  cursor: pointer;
  transition: background .12s;
}
.row:hover { background: var(--c-primary-soft); }
.row:focus-visible { outline: 2px solid var(--c-primary); outline-offset: -2px; }
.row + .row .cell { border-top: 1px solid #eef0f3; }

.cell {
  padding: 10px 14px;
  vertical-align: middle;
}

.cell--candidate { font-weight: 500; }
.candidate-main { display: inline-flex; flex-direction: column; gap: 4px; vertical-align: middle; }
.candidate-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.candidate-criteria { color: var(--c-text-muted); font-size: 0.75rem; font-weight: 500; }
.selection-badge { display: inline-flex; width: fit-content; padding: 2px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; line-height: 1.35; }
.selection-badge--qualified { color: var(--c-high); background: var(--c-high-bg); }
.selection-badge--supplemental { color: var(--c-medium); background: var(--c-medium-bg); }
.selection-badge--hired { color: var(--c-neutral); background: var(--c-neutral-bg); }

.cell__rank {
  display: inline-block;
  min-width: 22px;
  margin-right: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
}

.cell--action { text-align: right; color: var(--c-text-muted); }

/* ---------------------------------------------------------------------- Score */

.score {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score__value {
  flex: none;
  min-width: 40px;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.score__track {
  flex: 1;
  height: 6px;
  background: #eceff3;
  border-radius: 3px;
  overflow: hidden;
}

.score__fill {
  height: 100%;
  border-radius: 3px;
  transition: width .25s ease;
}

.score--empty .score__value { color: var(--c-text-muted); font-weight: 500; }

/* ---------------------------------------------------------------------- Badge */

.badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 11px;
  white-space: nowrap;
}

.badge--excellent { color: var(--c-excellent); background: var(--c-excellent-bg); }
.badge--high      { color: var(--c-high);      background: var(--c-high-bg); }
.badge--medium    { color: var(--c-medium);    background: var(--c-medium-bg); }
.badge--low       { color: var(--c-low);       background: var(--c-low-bg); }
.badge--weak      { color: var(--c-weak);      background: var(--c-weak-bg); }
.badge--neutral   { color: var(--c-neutral);   background: var(--c-neutral-bg); }
.badge--none      { color: var(--c-text-muted); background: transparent; font-weight: 500; }

.tier-excellent { background: var(--c-excellent); }
.tier-high      { background: var(--c-high); }
.tier-medium    { background: var(--c-medium); }
.tier-low       { background: var(--c-low); }
.tier-weak      { background: var(--c-weak); }
.tier-neutral   { background: var(--c-neutral); }

/* ----------------------------------------------------------------- Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 14px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
}

.pagination__info {
  margin: 0;
  font-size: 11.5px;
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
}

.pagination__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination__pages {
  font-size: 12px;
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------- États */

.state {
  padding: 26px 18px;
  text-align: center;
}

.state--loading { text-align: left; padding: 4px 0 18px; }

.state--progress {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 30px 18px 28px;
  text-align: left;
}

.state--review-load {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 30px 18px 28px;
  text-align: left;
}

.state--review-load > .state__title { margin-bottom: 22px; text-align: center; }
.progress-steps--review { max-width: 430px; margin: 0 auto; }
.state--review-load .progress-bar { max-width: 430px; }

.state--progress > .state__title { margin-bottom: 22px; text-align: center; }

.progress-steps { display: grid; gap: 14px; }

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  color: var(--c-text-muted);
}

.progress-step__icon {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: -2px;
  border: 1px solid var(--c-border-strong);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: var(--c-bg);
}

.progress-step__content { display: grid; gap: 3px; min-width: 0; }
.progress-step__content strong { font-size: 13px; font-weight: 600; color: inherit; }
.progress-step__content small { font-size: 11.5px; line-height: 1.45; color: var(--c-text-muted); }

.progress-step--done { color: var(--c-high); }
.progress-step--done .progress-step__icon { color: #fff; border-color: var(--c-high); background: var(--c-high); }
.progress-step--active { color: var(--c-primary); }
.progress-step--active .progress-step__icon {
  color: var(--c-primary);
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
  animation: pulse-progress 1.5s ease-in-out infinite;
}

@keyframes pulse-progress {
  50% { box-shadow: 0 0 0 5px rgba(50, 91, 177, .10); }
}

.progress-message { margin: 18px 0 0; text-align: center; }

.state__text--muted { margin-top: 10px; font-size: 12px; color: var(--c-text-muted); }

.progress-ring {
  width: 36px; height: 36px; margin: 0 auto 14px;
  border: 3px solid var(--c-neutral-bg);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-bar {
  height: 8px; margin: 14px auto 0;
  background: var(--c-neutral-bg); border-radius: 999px; overflow: hidden;
}

.progress-bar i {
  display: block; height: 100%; width: 0;
  background: var(--c-primary);
  transition: width 0.35s ease;
}

.progress-bar--indeterminate i {
  width: 35% !important;
  animation: progress-indeterminate 1.25s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  from { transform: translateX(-120%); }
  to { transform: translateX(310%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  margin-bottom: 10px;
  font-size: 19px;
  font-weight: 700;
  color: var(--c-weak);
  background: var(--c-weak-bg);
  border-radius: 50%;
}

.state__icon--muted { color: var(--c-text-muted); background: var(--c-neutral-bg); }

.state__title {
  margin: 0 0 5px;
  font-size: 13.5px;
  font-weight: 600;
}

.state__text {
  margin: 0;
  font-size: 12.5px;
  color: var(--c-text-soft);
  word-break: break-word;
}

.state__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

/* --------------------------------------------------------- Revue des critères */

.state--review { text-align: left; padding: 20px 4px; }
.state--review-error { padding: 36px 18px 28px; }

.review__banner {
  margin-bottom: 14px;
  padding: 8px 10px;
  font-size: 12px;
  color: #7a5b00;
  background: #fdf7e6;
  border: 1px solid #f0e0b0;
  border-radius: var(--radius-sm);
}

.review__columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 40px;
}

/* Sans min-width: 0, une grille ne laisse jamais une piste 1fr descendre
   sous le min-content de son contenu (ici, le texte du critère) : la ligne
   déborde au lieu de se resserrer. */
.review__column { min-width: 0; }

.review__column-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.review__hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--c-text-muted);
}

.review__list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review__item {
  padding: 8px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.review__item-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.review__item-row .review__label { flex: 1 1 auto; min-width: 0; width: auto; }

.review__item-row .review__level {
  flex: 0 0 auto;
  min-width: 0;
  width: 84px;
  padding-right: 20px;
  font-size: 11.5px;
}

.review__item-row .review__remove {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  font-size: 16px;
}

.review__add {
  display: block;
  padding: 4px 0;
}
.review__add:disabled { opacity: .45; cursor: default; text-decoration: none; }

.review__error {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--c-weak);
}

.review__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}

@media (max-width: 720px) {
  .review__columns { grid-template-columns: 1fr; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #e6e9ee 37%, #f0f2f5 63%);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.3s ease-in-out infinite;
}

.skeleton--row { height: 34px; margin-bottom: 7px; }

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

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .score__fill { transition: none; }
}

/* ----------------------------------------------------------------- Diagnostic */

.diagnostic {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.diagnostic__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diagnostic__title { margin: 0; font-size: 12.5px; font-weight: 600; }

.diagnostic__hint { margin: 4px 0 10px; font-size: 11.5px; color: var(--c-text-soft); }
.diagnostic__hint code { font-size: 11px; background: #e9ecf1; padding: 1px 4px; border-radius: 3px; }

.diagnostic__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.diagnostic__output {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

.diagnostic__output:empty { display: none; }

/* ------------------------------------------------------ Panneau de détails */

.drawer { position: fixed; inset: 0; z-index: 40; }

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 36, 52, .34);
  animation: fade-in .16s ease-out;
}

.drawer__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(430px, 92vw);
  background: var(--c-bg);
  box-shadow: var(--shadow-lg);
  animation: slide-in .2s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(18px); opacity: .5; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .drawer__backdrop, .drawer__panel { animation: none; }
}

.drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--c-border);
}

.drawer__title { margin: 0; font-size: 14px; font-weight: 600; }
.drawer__subtitle { margin: 2px 0 0; font-size: 11.5px; color: var(--c-text-muted); }

.drawer__body { flex: 1; overflow-y: auto; padding: 16px; }

.detail-metrics {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  flex: 1;
  padding: 10px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.metric__label {
  margin: 0 0 3px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--c-text-muted);
}

.metric__value { margin: 0; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric__value--text { font-size: 13.5px; padding-top: 3px; }

.detail-block { margin-bottom: 18px; }
.detail-block:last-child { margin-bottom: 0; }

.detail-block__title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--c-text-soft);
}

.detail-block__title::before {
  content: "";
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--c-border-strong);
}

.detail-block--strengths .detail-block__title::before { background: var(--c-high); }
.detail-block--weaknesses .detail-block__title::before { background: var(--c-low); }
.detail-block--summary .detail-block__title::before { background: var(--c-primary); }
.detail-block--recommendation .detail-block__title::before { background: var(--c-medium); }

.detail-zoho-link {
  margin: 0 0 16px;
  font-size: 13px;
}

.detail-block__body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--c-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-block__body--empty { color: var(--c-text-muted); font-style: italic; }

.detail-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.65; }
.detail-list li { margin-bottom: 3px; }

/* -------------------------------------------------------------- Responsive */

@media (max-width: 560px) {
  .widget { padding: 12px 12px 8px; }
  .table__th--score { width: 120px; }
  .score__track { display: none; }
  .cell { padding: 9px 10px; }
  .sort-btn { padding: 9px 10px; }
  .detail-metrics { flex-direction: column; }
}

/* Localisation déjà connue dans le dossier de sourcing. */
.candidate-location { color: var(--c-text-muted); font-size: 0.8rem; font-weight: 400; }
.selection-badge--unknown { color: var(--c-neutral); background: var(--c-neutral-bg); }

/* Légende visible avec les contrôles du listing, sur une ligne dédiée. */
.badge-legend { flex: 0 0 100%; color: var(--c-text-muted); font-size: 0.75rem; line-height: 1.5; }
.badge-legend__intro { margin: 4px 0 6px; }
.badge-legend__items { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.badge-legend__item { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
