/* css/layout.css */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  height: 100vh;
  width: 100%;
  background-color: var(--background-primary);
  transition: grid-template-columns 0.3s ease-in-out;
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
}

.app-shell::before, .app-shell::after {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, var(--accent-primary), transparent 60%);
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}
.app-shell::before {
    top: -200px;
    left: -200px;
}
.app-shell::after {
    bottom: -300px;
    right: -300px;
    background: radial-gradient(circle, var(--accent-secondary), transparent 70%);
    opacity: 0.08;
}

.app-sidebar, .app-topbar, .app-content {
    position: relative;
    z-index: 1;
    background-color: transparent;
}

.app-sidebar {
  grid-area: sidebar;
  background-color: var(--surface-primary);
  border-right: 1px solid var(--border-primary);
  width: 240px;
  transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
  z-index: 101; /* Higher than overlay */
}

.app-topbar {
  grid-area: topbar;
  background-color: var(--surface-primary);
  border-bottom: 1px solid var(--border-primary);
  height: 60px;
  z-index: 50;
}

.app-content {
  grid-area: content;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  min-width: 0;
}

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 100;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 80px 1fr;
}
.app-shell.sidebar-collapsed .app-sidebar {
  width: 80px;
}

@media (max-width: 768px) {
    .app-shell {
        /* --- THIS IS THE FIX --- */
        /* Revert to a normal block layout on mobile, disabling the grid */
        display: block;
    }
    .app-content {
        height: calc(100vh - 60px); /* Fill remaining height below topbar */
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    .app-shell.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }
    
    .app-shell.sidebar-mobile-open .mobile-sidebar-overlay {
        display: block;
    }
}