/**
 * Hamburger Menu - Fixed Styles
 * Addresses all critical layout bugs
 */

/* ============================================
   HAMBURGER TRIGGER BUTTON
   ============================================ */
.hamburger-menu {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 10001;
}

.hamburger-menu:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.1);
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* ============================================
   HAMBURGER PANEL - CRITICAL FIXES
   ============================================ */
.hamburger-panel {
  /* FIXED: Proper positioning */
  position: fixed;
  top: 0;
  left: -100%;
  width: min(350px, 80vw);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  
  /* FIXED: Safe area support for notched devices */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  
  /* FIXED: Proper z-index isolation */
  z-index: 10000;
  
  /* FIXED: Prevent overflow */
  overflow: hidden;
  
  /* Background and styling */
  background: rgba(10, 14, 39, 0.98);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid rgba(59, 130, 246, 0.2);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  
  /* Smooth transition */
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* FIXED: Isolation context */
  isolation: isolate;
  contain: layout style paint;
}

/* FIXED: Open state */
.hamburger-panel.active {
  left: 0;
}

/* ============================================
   PANEL CONTENT - SCROLLABLE CONTAINER
   ============================================ */
.hamburger-panel-content {
  /* FIXED: Full height with proper calculation */
  height: 100%;
  width: 100%;
  max-width: 100%;
  
  /* FIXED: Prevent overflow */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  
  /* Prevent any transform that could push outside */
  transform: none !important;
}

/* ============================================
   MENU HEADER
   ============================================ */
.menu-header {
  /* Fixed height header */
  flex-shrink: 0;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.menu-header h3 {
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.menu-close {
  width: 36px;
  height: 36px;
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid rgba(255, 68, 68, 0.3);
  border-radius: 8px;
  color: #ff4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.3s ease;
}

.menu-close:hover {
  background: rgba(255, 68, 68, 0.2);
  border-color: rgba(255, 68, 68, 0.5);
  transform: scale(1.05);
}

/* ============================================
   NAVIGATION - SCROLLABLE AREA
   ============================================ */
.hamburger-nav {
  /* FIXED: Scrollable content area */
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  
  /* FIXED: Smooth scrolling */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  
  /* Padding for content */
  padding: 10px 0;
}

/* Custom scrollbar */
.hamburger-nav::-webkit-scrollbar {
  width: 6px;
}

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

.hamburger-nav::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 3px;
}

.hamburger-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.5);
}

/* ============================================
   MENU ITEMS - CONSTRAINED
   ============================================ */
.menu-item {
  /* FIXED: Constrained width */
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 16px 20px;
  
  /* FIXED: Prevent overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  
  /* Styling */
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  
  /* Flexbox for icon + text */
  display: flex;
  align-items: center;
  gap: 12px;
  
  /* Transition */
  transition: all 0.3s ease;
  
  /* FIXED: No transform that could push outside */
  transform: none !important;
  position: relative;
}

.menu-item i {
  width: 20px;
  text-align: center;
  color: rgba(59, 130, 246, 0.8);
  flex-shrink: 0;
}

.menu-item:hover,
.menu-item:focus {
  background: rgba(59, 130, 246, 0.1);
  color: #ffffff;
  outline: none;
}

.menu-item:focus {
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* ============================================
   USER SECTION - FIXED AT BOTTOM
   ============================================ */
.menu-user-section {
  /* Fixed at bottom */
  flex-shrink: 0;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

/* ============================================
   OVERLAY
   ============================================ */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  
  z-index: 9999;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
  .hamburger-panel {
    width: min(300px, 85vw);
  }
  
  .menu-item {
    padding: 14px 16px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .hamburger-panel {
    width: min(280px, 90vw);
  }
  
  .menu-header {
    padding: 16px;
  }
  
  .menu-item {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .hamburger-panel,
  .hamburger-menu,
  .menu-item,
  .menu-overlay {
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .hamburger-panel {
    border-right: 2px solid #ffffff;
  }
  
  .menu-item:focus {
    outline: 2px solid #ffffff;
    outline-offset: -2px;
  }
}

/* Focus visible (keyboard navigation) */
.menu-item:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.8);
  outline-offset: -2px;
}
