// ==========================================================================
// LAYOUT SYSTEM
// ==========================================================================
// Core layout utilities and patterns for the application shell
// ==========================================================================

// Layout variables
:root {
  --header-height: 64px;
  --sidenav-width-expanded: 240px;
  --sidenav-width-rail: 64px;
  --sidenav-width-hidden: 0px;
}

// ==========================================================================
// LAYOUT CONTAINERS
// ==========================================================================

.layout-container {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layout-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 1000;
  background-color: var(--surface-elevated, #ffffff);
  border-bottom: 1px solid var(--border-secondary, #e5e5e5);
}

.layout-body {
  flex: 1;
  display: flex;
  margin-top: var(--header-height);
  overflow: hidden;
}

.layout-sidebar {
  flex-shrink: 0;
  height: 100%;
  background-color: var(--surface-elevated, #ffffff);
  border-right: 1px solid var(--border-secondary, #e5e5e5);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  &.sidebar-expanded {
    width: var(--sidenav-width-expanded);
  }
  
  &.sidebar-rail {
    width: var(--sidenav-width-rail);
  }
  
  &.sidebar-hidden {
    width: var(--sidenav-width-hidden);
  }
}

.layout-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layout-content {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
  background-color: var(--surface-primary, #fafafa);
}

// ==========================================================================
// RESPONSIVE LAYOUT UTILITIES
// ==========================================================================

@media (max-width: 768px) {
  .layout-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    z-index: 900;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    &.sidebar-visible {
      transform: translateX(0);
      width: 280px;
      box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
  }
  
  .layout-main {
    margin-left: 0 !important;
  }
  
  .layout-content {
    padding: 1rem;
  }
}

// ==========================================================================
// LAYOUT STATE UTILITIES
// ==========================================================================

.layout-no-scroll {
  overflow: hidden;
}

.layout-with-sidebar-expanded .layout-main {
  margin-left: var(--sidenav-width-expanded);
}

.layout-with-sidebar-rail .layout-main {
  margin-left: var(--sidenav-width-rail);
}

.layout-with-sidebar-hidden .layout-main {
  margin-left: var(--sidenav-width-hidden);
}

// ==========================================================================
// LAYOUT ANIMATIONS
// ==========================================================================

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

.layout-animation-enter {
  animation: slideInFromLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.layout-animation-leave {
  animation: slideOutToLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

// ==========================================================================
// LAYOUT FOCUS MANAGEMENT
// ==========================================================================

.layout-focus-trap {
  position: relative;
}

.layout-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 800;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-in-out;
  
  &.active {
    opacity: 1;
    visibility: visible;
  }
}