/* Navigation de page (sidebar / barre fixe en bas sur mobile) ——————————————————————— */
.page-navigation {

  /* ——— Mobile : barre fixe en bas ——— */
  /*backdrop-filter: blur(12px);*/
  /*background-color: rgb(255 255 255 / 0.75);*/
  background-color: var(--color-clear-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 -2px 8px rgb(0 0 0 / 0.08);
  inset-block-end: var(--space-8);
  inset-inline: var(--space-8);
  /*margin-inline: auto;*/
  max-width: calc(100% - var(--space-8) * 2);
  position: fixed;
  /*width: max-content;*/
  z-index: 100;

  ul {
    align-items: center;
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin-block: 0;
    /*padding: var(--space-8);*/
    position: relative;
  }

  li {
    position: relative;
    width: min-content;
  }

  /* Tableau de bord au centre : les 2 items suivants passent avant */
  li:nth-child(2),
  li:nth-child(3) {
    order: -1;
  }

  /* Élément central surélevé, sorti du flux */
  li:first-child {
    /*left: 50%;
    position: absolute;
    top: 0;
    translate: -50% -50%;*/

   .menu-item {
      background-color: var(--color-clear-bg);
      border-radius: 50%;
      box-shadow: var(--shadow-border);
      padding: var(--space-12);
      transform: scale(1.2);
    }

    .menu-label {
      clip: rect(0 0 0 0);
      clip-path: inset(50%);
      height: 1px;
      overflow: hidden;
      position: absolute;
      white-space: nowrap;
      width: 1px;
    }

    .menu-icon {
      height: 1.5rem;
      transform: scale(1.2);
      width: 1.5rem;
    }
  }

  a {
    align-items: center;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column-reverse;
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 400;
    gap: 0.25rem;
    line-height: 1.2;
    padding-inline-end: var(--space-4);
    text-align: center;
    text-decoration: none;
    text-transform: none;
  }

  /* Labels masqués sur mobile (icônes seules)
     Pour réactiver les labels : supprimer ce bloc et décommenter
     .menu-label { position: relative; } ci-dessous */
  .menu-label {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }
  /* Version avec labels visibles :
  .menu-label {
    position: relative;
  }
  */

  .menu-item {
    transition-property: color, background-color;
    transition-duration: 150ms;
    transition-timing-function: ease-out;
  }

  .menu-item.active {
    color: var(--color-accent);
  }

  /* Pas de bullet/indent sur mobile — l'actif est indiqué par la couleur */
  .menu-item.active .menu-label {
    margin-inline-start: 0;
  }
  .menu-item.active .menu-label::before {
    display: none;
  }

  .menu-icon {
    display: block;
    margin-inline-end: 0;
    width: 1.25rem;
    height: 1.25rem;
    transform: scale(1.25);
  }
}

@media (width < 720px) {
  .page-navigation a:hover,
  .page-navigation a:focus,
  .page-navigation a:active,
  .page-navigation .menu-item.active {
    background-color: transparent;
  }
}

/* ——— Desktop : sidebar verticale classique ——— */
@media (width > 720px) {
  .page-navigation {
    backdrop-filter: none;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    inset-block-end: auto;
    inset-inline: auto;
    margin-inline: 0;
    max-width: none;
    position: static;
    width: auto;
    z-index: auto;

    ul {
      display: block;
      padding-block-start: var(--space-12);
      padding-inline: var(--space-8);
      position: static;
    }

    li {
      margin-block-end: var(--space-4);
      order: 0;
      width: auto;
    }

    li:first-child {
      left: auto;
      position: relative;
      top: auto;
      translate: none;

      a,
      .menu-item,
      .menu-item.active {
        border-radius: var(--radius-md);
        box-shadow: none;
        color: inherit;
        padding: 0.35rem var(--space-4) 0.35rem var(--space-8);
        transform: none;
      }

      .menu-item:hover,
      .menu-item.active {
        background-color: var(--color-surface-lighter);
      }

      .menu-label {
        clip: auto;
        clip-path: none;
        height: auto;
        min-width: 0;
        overflow: hidden;
        position: relative;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: auto;
      }

      .menu-icon {
        width: 1.25rem;
        height: 1.25rem;
        transform: none;
      }
    }

    li.nav-separator::after {
      background-color: var(--color-border-light);
      content: "";
      display: block;
      height: 1px;
      margin-block: var(--space-20);
      margin-inline: var(--space-8);
    }

    .menu-label {
      clip: auto;
      clip-path: none;
      height: auto;
      min-width: 0;
      overflow: hidden;
      position: relative;
      text-overflow: ellipsis;
      white-space: nowrap;
      width: auto;
    }

    a {
      flex-direction: row;
      font-size: 0.875rem;
      gap: 0;
      justify-content: space-between;
      line-height: inherit;
      text-align: start;
    }

    .menu-item.active {
      color: inherit;
    }

    .menu-item.active .menu-label {
      padding-inline-start: 1.25rem;
    }

    .menu-item.active .menu-label::before {
      background-color: var(--color-accent);
      border-radius: 50%;
      content: "";
      display: block;
      height: 8px;
      left: 0.3rem;
      outline: 1px solid var(--color-primary);
      outline-offset: 2px;
      position: absolute;
      top: 50%;
      translate: 0 -50%;
      width: 8px;
    }

    .menu-icon {
      display: inline-block;
      margin-inline-end: 0.5rem;
      transform: none;
    }
  }
}

/* Bouton toggle sidebar (desktop uniquement) */
.sidebar__toggle {
  display: none;
}

@media (width > 720px) {
  .sidebar__toggle {
    align-items: center;
    background: transparent;
    border: 1px solid var(--color-border-light);
    border-radius: var(--space-8);
    cursor: pointer;
    display: flex;
    gap: var(--space-8);
    justify-content: space-between;
    margin: var(--space-8);
    padding: var(--space-4) var(--space-8) var(--space-4) var(--space-8);
    width: calc(100% - var(--space-16));

    svg {
      flex-shrink: 0;
      transition: rotate 0.3s ease;
    }
  }
}

.sidebar__toggle-label {
  color: var(--color-body-text);
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
}

.sidebar--collapsed .sidebar__toggle svg {
  rotate: 180deg;
}

.sidebar--collapsed .sidebar__toggle-label {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Sidebar repliée (desktop) */
@media (width > 720px) {
  .sidebar--collapsed .page-navigation {
    ul {
      align-items: center;
    }

    .menu-label,
    li:first-child .menu-label {
      clip: rect(0 0 0 0);
      clip-path: inset(50%);
      height: 1px;
      overflow: hidden;
      position: absolute;
      white-space: nowrap;
      width: 1px;
    }

    li.nav-separator::after {
      display: none;
    }
 
    a {
      justify-content: center;
      padding: var(--space-8);
    }
    
    li:first-child {
      .menu-item, 
      .menu-item.active,
      a {
        padding: var(--space-8);
      }
    }

    .menu-icon {
      margin-inline-end: 0;
    }

    .menu-item.active .menu-label {
      margin-inline-start: 0;
    }

    .menu-item.active .menu-label::before {
      display: none;
    }
  }
  
  .sidebar--collapsed {
    .sidebar__toggle {
      padding: var(--space-4) var(--space-8);
    }
  }
}

/* ——— Ordre mobile spécifique aux pages Bases ——— */
/* Sur les pages Mon compte, l'ordre général (li:nth-child(2/3) avant le reste)
   positionne le Tableau de bord au centre. Sur les pages Bases, Recherche globale
   (1er item DOM) doit se retrouver au milieu : entre Doctrine (4e) et
   Notices bibliographiques (5e). */

@media (width <= 720px) {
  .bases .page-navigation li:first-child {
    order: 1;
  }

  .bases .page-navigation li:nth-child(5),
  .bases .page-navigation li:nth-child(6),
  .bases .page-navigation li:nth-child(7),
  .bases .page-navigation li:nth-child(8) {
    order: 2;
  }
}
