/* ==========================================================================
   Sidebar globale gauche
   - Etat repos : barre 64px, icones seules
   - Au hover : 240px avec libelles + chevrons
   - Sub-panel apparait a droite des categories qui ont des sous-categories
   - Mobile : drawer plein ecran qui glisse depuis la gauche
   ========================================================================== */

/* Le body est decale a droite de 64px pour laisser la place a la sidebar fixe. */
body{ padding-left: 64px; }

/* ── La sidebar elle-meme ─────────────────────────────────────────────── */
.tme-side{
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 64px;
  background: var(--surface);
  box-shadow: 4px 0 16px rgba(0,0,0,.04);
  z-index: 100;
  transition: width .25s ease, box-shadow .25s ease;
  display: flex;
  flex-direction: column;
}
.tme-side:hover{
  width: 240px;
  box-shadow: 6px 0 32px rgba(0,0,0,.10);
}

/* ── Le bandeau "Menu" en haut ────────────────────────────────────────── */
.tme-side__menu{
  background: var(--primary);
  color: #FFFFFF;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: .08em;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: background .2s ease;
}
.tme-side__menu:hover{ background: var(--primary-2); color:#FFFFFF; }
.tme-side__menu-icon{
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tme-side__menu-icon svg{ width: 100%; height: 100%; }
.tme-side__menu-label{
  opacity: 0;
  white-space: nowrap;
  transition: opacity .2s ease .05s;
}
.tme-side:hover .tme-side__menu-label{ opacity: 1; }

/* ── La liste des categories ──────────────────────────────────────────── */
.tme-side__list{
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
}
.tme-side__list::-webkit-scrollbar{ width: 0; }

.tme-side__item{
  position: relative;
  border-top: 1px solid var(--border);
}
.tme-side__item:first-child{ border-top: none; }

.tme-side__row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}
.tme-side__item:hover > .tme-side__row{
  background: rgba(0,76,148,.07);
  color: var(--primary);
}

.tme-side__l{
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.tme-side__icon{
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .2s ease;
}
.tme-side__icon svg{ width: 100%; height: 100%; }
.tme-side__item:hover .tme-side__icon{ color: var(--primary); }

.tme-side__label{
  opacity: 0;
  white-space: nowrap;
  transition: opacity .2s ease .05s;
}
.tme-side:hover .tme-side__label{ opacity: 1; }

.tme-side__chev{
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
  opacity: 0;
  transition: opacity .2s ease .05s, color .2s ease, transform .2s ease;
}
.tme-side:hover .tme-side__chev{ opacity: 1; }
.tme-side__item:hover .tme-side__chev{
  color: var(--primary);
  transform: translateX(2px);
}

/* ── Categories text-only en bas ──────────────────────────────────────── */
.tme-side__item--text > .tme-side__row{
  padding-left: 50px;
  font-weight: var(--fw-medium);
  color: var(--text-body);
}
.tme-side__item--text > .tme-side__row .tme-side__label{ opacity: 0; }
.tme-side:hover .tme-side__item--text > .tme-side__row .tme-side__label{ opacity: 1; }

/* ── Sub-panel ────────────────────────────────────────────────────────── */
.tme-side__sub{
  position: absolute;
  left: 100%;
  top: 0;
  margin: 0 0 0 8px;
  padding: 6px 0;
  list-style: none;
  background: var(--surface);
  border-radius: var(--rd-md);
  box-shadow: 0 18px 40px rgba(0,0,0,.10);
  min-width: 200px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity .18s ease, transform .18s ease;
}
.tme-side__sub::before{
  content: "";
  position: absolute;
  left: -7px;
  top: 16px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 7px solid var(--surface);
}
.tme-side:hover .tme-side__item:hover .tme-side__sub{
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.tme-side__sub li{ list-style: none; }
.tme-side__sub a{
  display: block;
  padding: 9px 18px;
  color: var(--text-body);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition: color .15s ease, background .15s ease;
  white-space: nowrap;
}
.tme-side__sub a:hover{
  color: var(--primary);
  background: rgba(0,76,148,.05);
}

/* ── Overlay : assombrit la page quand la sidebar est ouverte ─────────── */
.tme-side-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  pointer-events: none;
  z-index: 90;
  transition: background .25s ease;
}
.tme-side:hover ~ .tme-side-overlay{
  background: rgba(0,0,0,.12);
}

/* ── Mobile / Tablette ────────────────────────────────────────────────── */
@media (max-width: 1024px){
  body{ padding-left: 0; }
  .tme-side{
    width: 280px;
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  .tme-side:hover{
    width: 280px;
    transform: translateX(-100%);
  }
  .tme-side.is-open{
    transform: translateX(0);
  }
  .tme-side.is-open ~ .tme-side-overlay{
    background: rgba(0,0,0,.45);
    pointer-events: auto;
  }
  /* Sur mobile l'expand est permanent : labels et chevrons toujours visibles */
  .tme-side__menu-label,
  .tme-side__label,
  .tme-side__chev{ opacity: 1 !important; }
  /* Le sub-panel mobile s'affiche en accordeon plutot qu'a droite */
  .tme-side__sub{
    position: static;
    margin: 0;
    box-shadow: none;
    background: rgba(0,76,148,.04);
    border-radius: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    display: none;
    padding: 0;
  }
  .tme-side__sub::before{ display: none; }
  .tme-side__item.is-open .tme-side__sub{ display: block; }
}
