@layer components {
/* Layout system - replaces Metro spanX grid */

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "content";
  min-height: 100vh;
}

.layout--with-sidebar {
  grid-template-columns: 17.5rem 1fr;
  grid-template-areas: "sidebar content";
}

.layout__sidebar {
  grid-area: sidebar;
  padding: 0.625rem;
}

.layout__content {
  grid-area: content;
  padding: 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-width: 0;
}

/* Mobile: sidebar hidden by default, toggle to show */
@media (max-width: 768px) {
  .layout--with-sidebar {
    grid-template-columns: 1fr;
    grid-template-areas: "content";
  }

  .layout__sidebar {
    position: fixed;
    top: 45px; /* below header */
    left: 0;
    bottom: 0;
    width: 85vw;
    max-width: 25rem;
    background: var(--neutral-50);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 100;
    overflow-y: auto;
  }

  .layout__sidebar--open {
    transform: translateX(0);
  }

  /* Overlay when sidebar is open */
  .layout__overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 45px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .layout__overlay--visible {
    display: block;
  }
}

/* Sidebar toggle button - only visible on mobile */
.sidebar-toggle {
  display: none !important; /* hidden on desktop */
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: white;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex !important;
  }
}

/* Sidebar sub-menus */
.layout__sidebar .sub-menu,
.sidebar > ul ul {
  position: static;
  z-index: auto;
  display: block;
  box-shadow: none;
}

.sidebar .sub-menu.hidden {
  display: none;
}
}
