/*
 * DiagSAV — section Entretien (photo, cours étape par étape, admin).
 * S'appuie sur les variables et composants de style.css (design 2026).
 */

/* ---------- Page d'accueil Entretien ---------- */
.ent-or {
  margin: 18px 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.ent-section-title {
  margin: 0 0 16px;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1.15rem;
}

.ent-types-wrap {
  width: min(980px, calc(100% - 40px));
  margin: 36px auto 0;
}

.ent-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.ent-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.ent-type-card:hover,
.ent-type-card:focus-visible,
.ent-type-card.is-suggested {
  border-color: var(--navy);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.ent-type-name {
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-weight: 600;
}

.ent-type-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.ent-type-meta {
  margin-top: auto;
  padding-top: 8px;
  color: var(--accent-dark);
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 600;
}

.ent-empty {
  width: min(1000px, calc(100% - 40px));
  margin: 24px auto;
  color: var(--text-muted);
}

/* ---------- Résultat d'identification ---------- */
.ent-result {
  margin-top: 22px;
  padding: 26px 30px;
}

.ent-result h2 {
  margin: 0 0 6px;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1.2rem;
}

.ent-result h3 {
  margin: 20px 0 8px;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-size: 0.98rem;
}

.ent-result ul {
  margin: 0;
  padding-left: 20px;
}

.ent-result li {
  margin-bottom: 6px;
}

.ent-result .btn {
  display: inline-flex;
  margin-top: 12px;
  text-decoration: none;
}

.ent-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 0; /* capsules rectangulaires */
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  vertical-align: middle;
}

.ent-badge--ok {
  background: var(--success-soft);
  color: var(--success);
}

.ent-badge--warn {
  background: var(--warning-soft);
  color: var(--warning);
}

/* ---------- Page cours ---------- */
.ent-docs {
  width: min(1120px, calc(100% - 40px));
  margin: 18px auto 0;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ent-docs h2 {
  margin: 0 0 8px;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1rem;
}

.ent-docs ul {
  margin: 0;
  padding-left: 20px;
}

.ent-toolbar {
  display: flex;
  width: min(1120px, calc(100% - 40px));
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px auto 0;
}

.ent-steps {
  display: grid;
  width: min(1120px, calc(100% - 40px));
  gap: 18px;
  margin: 22px auto 0;
  padding: 0;
  list-style: none;
}

.ent-step {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 84px;
}

.ent-step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.ent-step-head h2 {
  margin: 0;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1.05rem;
}

.ent-step-num {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--gradient);
  color: #ffffff;
  font-family: "Poppins", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.ent-step-body {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  align-items: start;
  gap: 24px;
  padding: 22px;
}

.ent-figure {
  margin: 0;
}

.ent-figure svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.ent-figure--small {
  max-width: 240px;
  margin: 6px 0 12px;
}

.ent-step-text p {
  margin: 0 0 12px;
}

.ent-why {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--navy-soft);
}

.ent-warn {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

@media (max-width: 680px) {
  .ent-step-body {
    grid-template-columns: 1fr;
  }

  .ent-figure {
    max-width: 320px;
  }

  .ent-result {
    padding: 20px;
  }
}

/* ---------- Administration ---------- */
.ent-flash {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.ent-flash--ok {
  background: var(--success-soft);
  color: var(--success);
}

.ent-flash--err {
  background: var(--danger-soft);
  color: var(--danger);
}

.ent-form {
  display: grid;
  gap: 12px;
}

.ent-form label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.ent-form .btn {
  width: fit-content;
}

.ent-textarea {
  min-height: 80px;
  resize: vertical;
}

.ent-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.ent-check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}

.ent-admin-step {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ent-admin-step summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--navy-deep);
  font-weight: 600;
  cursor: pointer;
}

.ent-admin-step .ent-form,
.ent-admin-step .ent-admin-actions {
  padding: 4px 14px 14px;
}

.ent-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Impression ---------- */
@media print {
  .nav,
  .ent-toolbar,
  .disclaimer + .ent-toolbar,
  footer {
    display: none !important;
  }

  .ent-step {
    break-inside: avoid;
    box-shadow: none;
  }

  body {
    background: #ffffff;
  }

  .hero {
    padding-block: 12px;
    background: #ffffff;
    color: var(--text);
  }

  .hero h1 {
    color: var(--navy-deep);
  }
}

/* ---------------------------------------------------------------
   Entretien guidé : cases à cocher et suivi des étapes
   --------------------------------------------------------------- */
.ent-progress {
  position: sticky;
  top: 72px;
  z-index: 5;
  width: min(1120px, calc(100% - 40px));
  margin: 18px auto 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ent-progress-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.ent-progress-count {
  margin: 0;
  color: var(--navy-deep);
  font-family: "Poppins", Arial, sans-serif;
  font-weight: 600;
}

.ent-progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ent-progress-actions .btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.ent-progress-bar {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--navy-soft);
}

.ent-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--navy);
  transition: width 0.25s ease;
}

.ent-progress.is-complete .ent-progress-bar span {
  background: var(--success);
}

.ent-remaining {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.ent-progress.is-complete .ent-remaining {
  color: var(--success);
  font-weight: 600;
}

.ent-remaining-link {
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  margin: 2px 0;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-light);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.ent-remaining-link:hover,
.ent-remaining-link:focus-visible {
  background: var(--accent);
  color: #ffffff;
}

/* La case « Fait » dans l'en-tête de chaque étape */
.ent-check {
  display: inline-flex;
  margin-left: auto;
  min-height: 44px;
  padding: 0 14px 0 10px;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.ent-check:hover {
  border-color: var(--navy-mid);
}

.ent-check-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ent-check-box {
  position: relative;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 2px solid var(--navy-mid);
  border-radius: 7px;
  background: #ffffff;
}

.ent-check-input:focus-visible + .ent-check-box {
  outline: 3px solid var(--accent-light);
  outline-offset: 2px;
}

.ent-check-input:checked + .ent-check-box {
  border-color: var(--success);
  background: var(--success);
}

.ent-check-input:checked + .ent-check-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 1px;
  width: 7px;
  height: 13px;
  border: solid #ffffff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

/* Coche qui se dessine + petit rebond de la case */
.ent-check-input:checked + .ent-check-box {
  animation: ent-box-pop 0.32s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.ent-check-input:checked + .ent-check-box::after {
  animation: ent-tick-draw 0.3s ease-out 0.05s both;
}

.ent-check-box {
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ent-step,
.ent-step-head,
.ent-step-num,
.ent-check {
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.ent-step-body {
  transition: opacity 0.3s ease;
}

.ent-step.is-done .ent-step-num {
  animation: ent-num-flip 0.4s ease-out;
}

.ent-progress.is-complete {
  animation: ent-complete 0.7s ease-out;
}

@keyframes ent-box-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* La coche est un L tourné : on dévoile la petite branche, puis la grande */
@keyframes ent-tick-draw {
  0%   { clip-path: inset(calc(100% - 3px) 100% 0 0); }
  40%  { clip-path: inset(calc(100% - 3px) 0 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes ent-num-flip {
  0%   { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

@keyframes ent-complete {
  0%   { box-shadow: var(--shadow), 0 0 0 0 rgba(31, 122, 76, 0.45); }
  100% { box-shadow: var(--shadow), 0 0 0 16px rgba(31, 122, 76, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .ent-check-input:checked + .ent-check-box,
  .ent-check-input:checked + .ent-check-box::after,
  .ent-step.is-done .ent-step-num,
  .ent-progress.is-complete {
    animation: none;
  }

  .ent-step,
  .ent-step-head,
  .ent-step-num,
  .ent-check,
  .ent-check-box,
  .ent-step-body {
    transition: none;
  }
}

/* Étape faite : en-tête vert, contenu atténué */
.ent-step.is-done {
  border-color: #b9dcc8;
}

.ent-step.is-done .ent-step-head {
  background: var(--success-soft);
}

.ent-step.is-done .ent-step-num {
  background: var(--success);
}

.ent-step.is-done .ent-check {
  border-color: var(--success);
  color: var(--success);
}

.ent-step.is-done .ent-step-body {
  opacity: 0.55;
}

/* Étape restante : liseré d'attention sur le numéro */
.ent-step:not(.is-done) .ent-step-num {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ent-steps.hide-done .ent-step.is-done {
  display: none;
}

/* Laisse la place au bandeau de suivi quand on saute à une étape */
.ent-progress:not([hidden]) + .ent-steps .ent-step {
  scroll-margin-top: 230px;
}

@media (max-width: 680px) {
  .ent-progress {
    position: static;
    padding: 14px;
  }

  .ent-progress:not([hidden]) + .ent-steps .ent-step {
    scroll-margin-top: 84px;
  }

  .ent-progress-actions,
  .ent-progress-actions .btn {
    width: 100%;
  }

  .ent-check-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .ent-check {
    padding: 0 10px;
  }
}

@media print {
  .ent-progress {
    display: none !important;
  }

  .ent-steps.hide-done .ent-step.is-done {
    display: block;
  }

  .ent-step.is-done .ent-step-body {
    opacity: 1;
  }

  .ent-check {
    border: 0;
    padding: 0;
  }
}
