/* ============================================
   SHARED SIDEBAR / MOBILE MENU
   Единый источник стилей мобильного сайдбара для
   публичного сайта и админки. Подключается как
   /lib/sidebar.css обоими серверами (express.static '/lib').
   Относится к разметке:
     .admin-shell > .sidebar-overlay + .admin-sidebar + #hamburger
   Гамбургер при открытом сайдбаре анимированно
   превращается в крестик и служит кнопкой закрытия.
   ============================================ */

/* ---------- Hamburger Button ---------- */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  background: var(--blue-dark);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease;
}

.hamburger__box {
  position: relative;
  width: 22px;
  height: 16px;
}

.hamburger__bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.hamburger__bar:nth-child(1) { top: 0; }
.hamburger__bar:nth-child(2) { top: 50%; transform: translateY(-50%); }
.hamburger__bar:nth-child(3) { bottom: 0; }

/* Open state: morph bars into an X */
.shell--sidebar-open .hamburger__bar:nth-child(1) {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.shell--sidebar-open .hamburger__bar:nth-child(2) {
  opacity: 0;
}

.shell--sidebar-open .hamburger__bar:nth-child(3) {
  bottom: 50%;
  transform: translateY(50%) rotate(-45deg);
}

/* ---------- Overlay (real element, controlled by JS) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ---------- Mobile layout ---------- */
@media (max-width: 900px) {
  .hamburger {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    /* Space at the top so the fixed hamburger does not overlap the brand */
    padding-top: 72px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .shell--sidebar-open .admin-sidebar {
    transform: translateX(0);
  }

  .shell--sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .shell--sidebar-open .hamburger {
    background: var(--blue);
  }

  /* Prevent background scroll when the sidebar is open */
  body.sidebar-locked {
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .hamburger {
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
  }
}
