/**
 * Layout Styles - Three-Panel Slack-like Layout
 * Desktop: Full three-panel layout with 220px sidebar
 * Tablet: Collapsible sidebar
 * Mobile: Hidden sidebar by default with hamburger menu
 */

/* ============================================
   CSS Variables (Design Tokens)
   ============================================ */

:root {
  /* Colors - Slack-Inspired Palette */
  --color-primary-purple: #4A154B;
  --color-sidebar-dark: #3F0E40;
  --color-sidebar-hover: #4A154B;
  --color-active-channel: #1264A3;
  --color-success-green: #2BAC76;
  --color-error-red: #E01E5A;
  --color-background: #F8F8F8;
  --color-text-primary: #1D1C1D;
  --color-text-secondary: #616061;
  --color-border: #DDDDDD;
  --color-white: #FFFFFF;

  /* Layout Dimensions */
  --top-nav-height: 64px;
  --sidebar-width: 220px;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 20px;

  /* Transitions */
  --transition-speed: 300ms;
  --transition-timing: ease-in-out;

  /* Z-index layers */
  --z-top-nav: 100;
  --z-sidebar: 90;
  --z-sidebar-overlay: 95;
  --z-modal: 1000;
}

/* ============================================
   Global Resets
   ============================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: var(--color-text-primary);
  background: var(--color-background);
  overflow: hidden;
}

/* ============================================
   App Container - Full Height Layout
   ============================================ */

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

/* ============================================
   Main Layout - Sidebar + Message Feed
   ============================================ */

.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--top-nav-height));
}

/* ============================================
   Sidebar (Left Panel)
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-dark);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: transform var(--transition-speed) var(--transition-timing);
  z-index: var(--z-sidebar);
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Message Feed (Center Panel)
   ============================================ */

.message-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  overflow: hidden;
}

.message-feed-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

/* ============================================
   Sidebar Overlay for Mobile/Tablet
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-sidebar-overlay);
  opacity: 0;
  transition: opacity var(--transition-speed) var(--transition-timing);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Desktop (> 1024px) - Full three-panel layout */
@media (min-width: 1025px) {
  .hamburger-menu {
    display: none !important; /* Hide hamburger on desktop */
  }

  .sidebar-overlay {
    display: none !important; /* No overlay needed on desktop */
  }
}

/* Tablet (768px - 1024px) - Collapsible sidebar */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: var(--top-nav-height);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

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

  .sidebar-overlay {
    display: block;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .message-feed {
    width: 100%;
  }
}

/* Mobile (< 768px) - Sidebar hidden by default */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: var(--top-nav-height);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

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

  .sidebar-overlay {
    display: block;
  }

  .message-feed {
    width: 100%;
  }
}

/* ============================================
   Accessibility
   ============================================ */

/* Focus visible styles */
.sidebar:focus-visible,
.message-feed:focus-visible {
  outline: 2px solid var(--color-primary-purple);
  outline-offset: -2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay {
    transition: none;
  }
}
