/*
 * MyE360 · Structures
 * Une seule navigation : barre inférieure translucide sous 48rem, rail latéral au-delà
 * (rail repris de la vue tablette validée G2). Ruptures : 48rem (768 px), 64rem (1024 px), 80rem (1280 px).
 */

/* ---------- Navigation principale ---------- */
.mye-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 0.25rem 0.5rem env(safe-area-inset-bottom, 0);
  background: var(--mye-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--mye-sep);
}

.mye-nav__item {
  position: relative;
  flex: 1 1 0;
  min-width: 3rem;
  height: 3rem;
  margin-bottom: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1875rem;
  color: var(--mye-text-2);
  text-decoration: none;
}

.mye-app .mye-nav__item { color: var(--mye-text-2); }
.mye-app .mye-nav__item:hover { color: var(--mye-text); }

.mye-nav__item .mye-i {
  width: 1.625rem;
  height: 1.625rem;
}

.mye-nav__label {
  font-size: 0.75rem;
  line-height: 1.1;
  letter-spacing: 0.01em;
  font-weight: 500;
}

.mye-app .mye-nav__item[aria-current="page"] { color: var(--mye-primary); }
.mye-nav__item[aria-current="page"] .mye-i { stroke-width: 2.25; }
.mye-nav__item[aria-current="page"] .mye-nav__label { font-weight: 700; }

.mye-nav__badge {
  position: absolute;
  top: 0;
  left: 50%;
  margin-left: 0.375rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.3125rem;
  border-radius: var(--mye-r-full);
  background: var(--mye-brand-red);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Contenu principal sous la barre inférieure */
.mye-main {
  display: block;
  min-width: 0;
  padding-bottom: 7.5rem;
}

/* Écran poussé à action fixe, ou concentration : pas de barre inférieure en mobile */
.mye-app--sans-barre .mye-nav { display: none; }
.mye-app--sans-barre .mye-main { padding-bottom: 0; }

/* ---------- Pages ---------- */
.mye-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem 1.25rem 0;
}

.mye-page--serre { gap: 1.25rem; }
.mye-page--sans-marge { padding-left: 0; padding-right: 0; }

.mye-stack { display: flex; flex-direction: column; gap: 1rem; }
.mye-stack--xs { gap: 0.25rem; }
.mye-stack--s { gap: 0.5rem; }
.mye-stack--m { gap: 0.75rem; }
.mye-stack--l { gap: 1.5rem; }
.mye-stack--xl { gap: 2rem; }

.mye-inline { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.mye-inline--between { justify-content: space-between; }
.mye-inline--s { gap: 0.5rem; }

/* En-tête de racine : grand titre et actions rondes (source : référence A) */
.mye-pagehead {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mye-pagehead__titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.mye-pagehead__kicker {
  font-size: var(--mye-fs-small);
  font-weight: 500;
  color: var(--mye-text-2);
}

/* Barre d'écran poussé : retour, titre de 17 px centré, action (source : D02, gabarit) */
.mye-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.25rem 0.75rem;
  background: var(--mye-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.mye-topbar__back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  min-height: 3rem;
  padding-right: 0.5rem;
  font-size: var(--mye-fs-body-l);
  font-weight: 500;
  text-decoration: none;
}

.mye-topbar__title {
  font-size: var(--mye-fs-body-l);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

.mye-topbar__end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Barre d'action fixe : 52 px au-dessus de la zone basse (source : D02) */
.mye-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  /* Zone basse de l'appareil ajoutée sans calcul : bordure transparente de la hauteur de la zone sûre */
  border-bottom: env(safe-area-inset-bottom, 0px) solid transparent;
  background: var(--mye-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--mye-sep);
}

.mye-actionbar__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: var(--mye-fs-small);
}

.mye-actionbar > .mye-btn--block { flex: 1; }

/* Espace réservé sous le contenu quand une barre d'action fixe est présente */
.mye-actionbar-spacer { height: 6.5rem; }

/* Collections horizontales en mobile (source : références A et B) */
.mye-rail {
  display: flex;
  gap: 0.75rem;
  margin: 0 -1.25rem;
  padding: 0 1.25rem 0.25rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.mye-rail::-webkit-scrollbar { display: none; }
.mye-rail > * { flex: none; width: 12.5rem; scroll-snap-align: start; }
.mye-rail--l > * { width: 16.25rem; }

/* Liste et détail : la sélection mène à la page du détail en mobile */
.mye-split__list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem 1.25rem 0;
}

.mye-split__detail { display: none; }

/* Colonnes : empilées en mobile, dans l'ordre de priorité */
.mye-cols { display: flex; flex-direction: column; gap: 2rem; }
.mye-cols__aside { display: flex; flex-direction: column; gap: 1.5rem; }
.mye-cols__main { display: flex; flex-direction: column; gap: 2rem; min-width: 0; }

/* ---------- Accès : colonne centrée ---------- */
.mye-app[data-layout="acces"] .mye-main { padding-bottom: 3rem; }

.mye-access {
  width: 100%;
  max-width: 26.25rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.mye-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--mye-text);
  text-decoration: none;
}

.mye-app a.mye-brand,
.mye-app a.mye-brand:hover { color: var(--mye-text); }

/* Marque d'accès : carré de 48 px, rayon 12 px, primaire (source : D03) */
.mye-brand__mark {
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: var(--mye-r-m);
  background: var(--mye-primary);
  color: var(--mye-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--mye-fs-small);
  font-weight: 700;
}

.mye-brand__text { display: flex; flex-direction: column; }
.mye-brand__text strong { font-size: var(--mye-fs-body-l); }
.mye-brand__text span { font-size: var(--mye-fs-small); color: var(--mye-text-2); }

/* Barre de retour des écrans d'accès (source : D03) */
.mye-backbar { display: flex; align-items: center; min-height: 3rem; margin: 0 -0.5rem; }
.mye-backbar a { min-height: 3rem; padding: 0 0.5rem; display: inline-flex; align-items: center; gap: 0.125rem; text-decoration: none; }

/* Séparateur « ou » (source : D03) */
.mye-or { display: flex; align-items: center; gap: 0.75rem; font-size: var(--mye-fs-small); color: var(--mye-text-2); }
.mye-or::before, .mye-or::after { content: ""; flex: 1; height: 0.5px; background: var(--mye-sep); }

/* Pastille de fournisseur externe (source : D03, cercle neutre en attendant le logo autorisé) */
.mye-provider { width: 1.25rem; height: 1.25rem; border-radius: var(--mye-r-full); border: 2px solid var(--mye-text-2); }

/* ---------- Concentration ---------- */
.mye-focus-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
  background: var(--mye-bg);
}

.mye-focus-head__bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
}

.mye-focus-head__title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: var(--mye-fs-body-s);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mye-focus-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.5rem 1.25rem 0;
}

.mye-focus-aside { display: none; }

/* ======================================================================
   Tablette portrait et au-delà : rail latéral (48rem, 768 px)
   ====================================================================== */
@media (min-width: 48rem) {
  .mye-app[data-layout="app"] {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    align-items: start;
    /* Fond du rail prolongé sur toute la hauteur de la page */
    background: linear-gradient(to right, var(--mye-bg-2) 6rem, var(--mye-sep) 6rem, var(--mye-sep) 6.03rem, var(--mye-bg) 6.03rem);
  }

  .mye-app[data-layout="app"] .mye-skip { grid-column: 1 / -1; }

  .mye-nav,
  .mye-app--sans-barre .mye-nav {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    bottom: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 2rem 0;
    background: var(--mye-bg-2);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: 0;
    border-right: 0.5px solid var(--mye-sep);
  }

  .mye-nav__item {
    flex: none;
    width: 4.5rem;
    height: 4rem;
    margin: 0;
    gap: 0.25rem;
    border-radius: var(--mye-r-btn);
  }

  .mye-nav__label { font-size: var(--mye-fs-caption); }

  .mye-nav__item[aria-current="page"] { background: var(--mye-primary-soft); }

  .mye-nav__badge { top: 0.375rem; }

  .mye-main,
  .mye-app--sans-barre .mye-main { padding-bottom: 3rem; }

  .mye-page {
    width: 100%;
    max-width: 45rem;
    margin: 0 auto;
    padding: 2.5rem 2.5rem 0;
    gap: 2.25rem;
  }

  .mye-page--large { max-width: 75rem; }
  .mye-page--moyen { max-width: 60rem; }

  .mye-split__list { width: 100%; max-width: 45rem; margin: 0 auto; padding: 2.5rem 2.5rem 0; }

  .mye-rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .mye-rail > *,
  .mye-rail--l > * { width: auto; }
  .mye-rail--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .mye-topbar {
    position: static;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    padding: 1rem 2.5rem 0;
    max-width: 45rem;
    margin: 0 auto;
    width: 100%;
  }

  .mye-topbar--large { max-width: 75rem; }
  .mye-topbar--moyen { max-width: 60rem; }

  /* La barre d'action suit la largeur du contenu et ne masque rien */
  .mye-actionbar {
    position: sticky;
    left: auto;
    right: auto;
    width: 100%;
    max-width: 45rem;
    margin: 2rem auto 0;
    padding: 1rem 2.5rem 1.25rem;
    border-top: 0.5px solid var(--mye-sep);
  }

  .mye-actionbar--large { max-width: 75rem; }
  .mye-actionbar--moyen { max-width: 60rem; }
  .mye-actionbar-spacer { display: none; }
  .mye-actionbar > .mye-btn--block { flex: none; width: auto; min-width: 14rem; }
  .mye-actionbar--partage > .mye-btn--block { flex: 1; min-width: 0; }

  .mye-access { padding-top: 4rem; }

  .mye-focus-head,
  .mye-focus-body {
    width: 100%;
    max-width: 45rem;
    margin: 0 auto;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

/* ======================================================================
   Tablette paysage et ordinateur (64rem, 1024 px)
   ====================================================================== */
@media (min-width: 64rem) {
  .mye-rail--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .mye-cols--aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 3rem;
    align-items: start;
  }

  .mye-cols--aside-l {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24rem;
    gap: 3rem;
    align-items: start;
  }

  /* Colonne de contexte à gauche, placée en tête du DOM pour garder l'ordre mobile */
  .mye-cols--aside-gauche {
    display: grid;
    grid-template-columns: 20rem minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
  }

  .mye-cols--2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3rem;
    align-items: start;
  }

  .mye-cols__aside--sticky { position: sticky; top: 2rem; }

  /* Liste et détail côte à côte (source : vue tablette G2, liste de 340 px) */
  .mye-split {
    display: grid;
    grid-template-columns: 21.25rem minmax(0, 1fr);
    align-items: start;
    min-height: 100vh;
  }

  .mye-split__list {
    max-width: none;
    margin: 0;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: 2.5rem 0.75rem 2rem;
    border-right: 0.5px solid var(--mye-sep);
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .mye-split__detail {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding: 2.5rem;
    min-width: 0;
  }

  .mye-split .mye-page { max-width: none; margin: 0; padding: 0; }
  .mye-split__list > .mye-split__head { padding: 0 0.75rem; }
  /* Liste maître à hauteur plafonnée : ses blocs ne se compriment pas */
  .mye-split__list > * { flex-shrink: 0; }
  .mye-split__list .mye-chips--rail { margin: 0; padding: 0 0.75rem; }
  .mye-split__list > .mye-alert { margin: 0 0.75rem; }
  .mye-split__list .mye-h1 { font-size: 1.75rem; }

  /* Concentration : contenu dominant et panneau latéral */
  .mye-focus-layout {
    display: grid;
    grid-template-columns: minmax(0, 45rem) 20rem;
    justify-content: center;
    gap: 3rem;
    align-items: start;
    padding: 0 2.5rem;
  }

  .mye-focus-layout .mye-focus-head,
  .mye-focus-layout .mye-focus-body { padding-left: 0; padding-right: 0; max-width: none; }

  .mye-focus-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1.5rem;
    margin-top: 1.5rem;
  }

  .mye-app .mye-focus-only-mobile { display: none; }
}


/* Faible hauteur ou clavier ouvert : les barres ne prennent pas la place du champ */
@media (max-height: 30rem) and (max-width: 47.99rem) {
  .mye-actionbar { position: static; }
  .mye-actionbar-spacer { display: none; }
}

/* Écran poussé : le titre suit la barre de retour sans grande marge (source : D04) */
.mye-topbar + .mye-page { padding-top: 0.5rem; }

@media (min-width: 48rem) {
  .mye-topbar + .mye-page { padding-top: 1rem; }
}
