/* =========================================================
   tests-nav.css - Phase 4 : navigation des tests Psychotechniques
   Une interface, deux mises en page :
   - < 1024px : écran Liste <-> écran Détail
   - >= 1024px : 3 colonnes (recherche/familles | catégories | détail)
   Charte CapConcours (tokens style.css / design-system.css).
   ========================================================= */

.tnav-wrap { max-width: 1180px; }

.tnav {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

/* ---------- Rail : recherche + filtres ---------- */
.tnav__rail { display: grid; gap: var(--space-3); }

.tnav__recherche { position: relative; }
.tnav__recherche input {
  width: 100%;
  font: inherit;
  font-size: .95rem;
  padding: .7rem 1rem .7rem 2.6rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
}
.tnav__recherche input::placeholder { color: var(--text-faint); }
.tnav__recherche input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.tnav__recherche .icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}

.tnav__filtres {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding-bottom: .2rem;
}
.tnav__puce {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-light);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}
.tnav__puce span { font-size: .75rem; font-weight: 700; opacity: .7; }
.tnav__puce:hover { border-color: var(--primary); color: var(--primary); }
.tnav__puce.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tnav__puce.is-on span { opacity: .85; }

/* ---------- Carte Reprendre ---------- */
.tnav-reprendre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: .85rem 1rem;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--psycho);
  border-radius: var(--radius-md);
  background: var(--psycho-bg);
}
.tnav-reprendre strong {
  font-family: var(--font-heading);
  font-size: .95rem;
}
.tnav-reprendre p { font-size: .88rem; color: var(--text-light); margin-top: .15rem; }
.tnav-reprendre[hidden] { display: none; }

/* ---------- Groupes de familles + cartes ---------- */
.tnav__groupes { display: grid; gap: var(--space-4); }
.tnav-groupe[hidden] { display: none; }

.tnav-groupe__titre {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  font-size: 1rem;
  padding-bottom: .4rem;
  margin-bottom: .55rem;
  border-bottom: 1px solid var(--border-light);
}
.tnav-groupe__titre span {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-faint);
}
.tnav.is-recherche .tnav-groupe__titre { display: none; }
.tnav.is-recherche .tnav__groupes { gap: var(--space-3); }

.tnav-liste { display: grid; gap: .5rem; }
.tnav-item[hidden] { display: none; }

.tnav-carte {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .8rem;
  text-align: left;
  padding: .7rem .8rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg);
  transition: var(--transition);
}
.tnav-carte:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tnav-carte.is-on { border-color: var(--primary); background: var(--primary-soft); }
.tnav-carte__ico {
  flex: 0 0 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--psycho-bg);
  color: var(--psycho);
}
.tnav-carte__ico .icon { width: 20px; height: 20px; }
.tnav-carte__corps { flex: 1 1 auto; min-width: 0; display: grid; gap: .25rem; }
.tnav-carte__ligne { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tnav-carte__nom {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .97rem;
}
.tnav-carte__meta { font-size: .79rem; color: var(--text-light); }
.tnav-carte__suite { color: var(--text-faint); font-size: 1.15rem; line-height: 1; }

.tnav-barre {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: rgba(86, 36, 208, .12);
  overflow: hidden;
}
.tnav-barre[hidden] { display: none; }
.tnav-barre span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

.tnav__vide {
  padding: var(--space-4) var(--space-3);
  text-align: center;
  color: var(--text-light);
  font-size: .92rem;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
}
.tnav__vide[hidden] { display: none; }

/* ---------- Détail ---------- */
.tnav__detail { display: grid; gap: var(--space-3); }
.tnav__panneaux { display: grid; gap: var(--space-3); }
.tnav-carte__suite .icon { width: 18px; height: 18px; }
.tnav__retour .icon { width: 15px; height: 15px; transform: rotate(180deg); }

.tnav__retour {
  justify-self: start;
  display: none;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg);
  font-size: .87rem;
  font-weight: 600;
  color: var(--text);
}
.tnav__retour:hover { border-color: var(--primary); color: var(--primary); }

.tnav__placeholder {
  padding: var(--space-4) var(--space-3);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: .9rem;
  text-align: center;
}
.tnav__placeholder[hidden] { display: none; }

.tnav-panneau {
  padding: var(--space-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--space-3);
}
.tnav-panneau[hidden] { display: none; }
.tnav-panneau__titre {
  font-size: 1.15rem;
  outline: none;
}
.tnav-panneau__meta { font-size: .82rem; color: var(--text-light); margin-top: .2rem; }
.tnav-panneau__note {
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-left: 3px solid var(--psycho);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
}

.tnav-niveaux {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}
.tnav-niveau {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .5rem .3rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
}
.tnav-niveau:hover { border-color: var(--primary); }
.tnav-niveau.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.tnav-niveau__num { font-size: .7rem; font-weight: 700; color: var(--text-faint); letter-spacing: .03em; }
.tnav-niveau.is-on .tnav-niveau__num { color: var(--primary); }
.tnav-niveau__nom { font-size: .84rem; font-weight: 700; }
.tnav-niveau__pt {
  position: absolute;
  top: .3rem;
  right: .35rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tnav-niveau__pt[hidden] { display: none; }

.tnav-bloc { display: grid; gap: .5rem; }
.tnav-bloc[hidden] { display: none; }
.tnav-sous {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}
.tnav-tests { display: grid; gap: .45rem; }

.tnav-test {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.tnav-test__nom { flex: 1 1 auto; font-size: .9rem; font-weight: 600; }
.tnav-test.is-lock { background: var(--bg-alt); }
.tnav-test.is-pending { border-color: var(--accent); }

.test-state.is-pending { background: rgba(242, 101, 34, .12); color: var(--accent-dark); }
.test-state.is-lock { background: rgba(106, 111, 115, .12); color: var(--text-light); }
.test-score { font-size: .74rem; font-weight: 700; color: var(--success); margin-left: .15rem; }

.tnav-panneau__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-light);
}
.tnav-lecons { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.tnav-lecons > span { font-size: .78rem; color: var(--text-faint); font-weight: 600; }

/* ---------- Barre d'onglets mobile ---------- */
.tnav-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: none;
  background: var(--bg);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, .06);
}
.tnav-tabs a {
  flex: 1 1 0;
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: .5rem 0 .45rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-light);
}
.tnav-tabs a .icon { width: 20px; height: 20px; }
.tnav-tabs a[aria-current="page"] { color: var(--primary); }

/* ---------- Mobile : écrans Liste / Détail ---------- */
@media (max-width: 1023px) {
  .tnav { display: block; }
  .tnav__rail, .tnav__centre, .tnav__detail { display: grid; gap: var(--space-4); }
  .tnav[data-screen="liste"] .tnav__detail { display: none; }
  .tnav[data-screen="detail"] .tnav__rail,
  .tnav[data-screen="detail"] .tnav__centre { display: none; }
  .tnav[data-screen="detail"] .tnav__retour { display: inline-flex; }
}

/* ---------- Desktop : 3 colonnes ---------- */
@media (min-width: 1024px) {
  .tnav { grid-template-columns: 250px minmax(0, 1fr) 350px; }
  .tnav__rail { position: sticky; top: calc(var(--header-h) + 16px); }
  .tnav__detail { position: sticky; top: calc(var(--header-h) + 16px); }
  .tnav__retour { display: none !important; }
  .tnav__placeholder { padding: var(--space-5) var(--space-3); }
}

@media (min-width: 1024px) and (max-width: 1200px) {
  .tnav { grid-template-columns: 220px minmax(0, 1fr) 320px; }
}

/* ---------- Petits écrans : barre d'onglets ---------- */
@media (max-width: 767px) {
  .tnav-tabs { display: flex; }
  body { padding-bottom: 66px; }
  .tnav-panneau { padding: var(--space-3) var(--space-3) var(--space-4); }
  .tnav-niveaux { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tnav-test { flex-wrap: wrap; }
}
