/* =========================================================
   VERSION FINALE COMPLÈTE - LAYOUT-FLEX.CSS
   ========================================================= */

/* === Règles de base (Desktop) === */

html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
}

.wrapper {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
}

.left-rail {
  flex: 0 0 var(--sidebar-w);
  align-self: stretch;
  border-right: 1px solid rgba(255, 255, 255, .06);
  z-index: 20; /* z-index pour le desktop */
  background: var(--menu-bg);
}

.content-page {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  align-items: flex-start;
  z-index: 1; /* z-index pour le mobile */
}

.topbar {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1050;
  flex-shrink: 0;
}

.content {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  overscroll-behavior: contain;
}

.page-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  position: relative;
}

.page-main {
  padding: 1rem;
}

/* === Styles pour le tiroir Mobile (< 992px) === */

@media (max-width: 992px) {
  .left-rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: clamp(260px, var(--sidebar-w-sm), var(--sidebar-w-sm-max));
    transform: translateX(-105%);
    transition: transform .25s var(--ease);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
    z-index: 1000; /* z-index élevé pour passer au-dessus de tout */
  }

  .left-rail.is-open {
    transform: translateX(0);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s var(--ease);
    z-index: 995; /* Juste en dessous du menu */
  }

  .drawer-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 993px) {
  .button-menu-mobile {
    display: none !important;
  }
}

/* Bloque le scroll du body quand le tiroir est ouvert */
body.menu-open {
  overflow: hidden;
}