/**
 * CRITICAL HAMBURGER MENU FIX
 * This file MUST be loaded LAST to override all conflicting styles
 * Fixes the menu items showing outside the drawer
 */

/* ============================================
   CRITICAL: HIDE PANEL BY DEFAULT (use left for slide, not display)
   ============================================ */
.hamburger-panel {
  /* Keep in layout for smooth slide animation */
  display: block !important;
  visibility: visible !important;
  
  /* Positioning - off-screen when closed */
  position: fixed !important;
  top: 0 !important;
  left: -100% !important;
  
  /* Size constraints */
  width: 350px !important;
  max-width: 80vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  
  /* Z-index */
  z-index: 10000 !important;
  
  /* Prevent overflow */
  overflow: hidden !important;
  
  /* Background */
  background: rgba(10, 14, 39, 0.98) !important;
  backdrop-filter: blur(30px) !important;
  -webkit-backdrop-filter: blur(30px) !important;
  
  /* Border */
  border-right: 1px solid rgba(59, 130, 246, 0.2) !important;
  
  /* Transition */
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  
  /* Isolation */
  isolation: isolate !important;
  contain: layout style paint !important;
  pointer-events: none !important;
}

/* ============================================
   CRITICAL: SHOW PANEL WHEN ACTIVE
   ============================================ */
.hamburger-panel.active {
  left: 0 !important;
  pointer-events: auto !important;
}

/* ============================================
   CRITICAL: CONSTRAIN ALL CHILDREN
   ============================================ */
.hamburger-panel,
.hamburger-panel *,
.hamburger-panel-content,
.hamburger-panel-content *,
.hamburger-nav,
.hamburger-nav *,
.menu-item,
.menu-item * {
  max-width: 350px !important;
  box-sizing: border-box !important;
}

/* ============================================
   PANEL CONTENT
   ============================================ */
.hamburger-panel-content {
  height: 100% !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  transform: none !important;
  position: relative !important;
  left: 0 !important;
  right: 0 !important;
}

/* ============================================
   NAVIGATION CONTAINER - SCROLLABLE
   ============================================ */
.hamburger-nav {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  padding: 10px 0 !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* ============================================
   MENU ITEMS - FORCE INSIDE
   ============================================ */
.hamburger-nav .menu-item,
.hamburger-nav a.menu-item,
.menu-item {
  /* Display */
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  
  /* Size */
  width: 100% !important;
  max-width: 100% !important;
  padding: 16px 20px !important;
  
  /* Prevent overflow */
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  
  /* Position */
  position: relative !important;
  left: 0 !important;
  right: 0 !important;
  transform: none !important;
  
  /* Styling */
  color: rgba(255, 255, 255, 0.8) !important;
  text-decoration: none !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  
  /* Transition */
  transition: all 0.3s ease !important;
}

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

/* ============================================
   MENU ITEM ICONS
   ============================================ */
.menu-item i {
  width: 20px !important;
  text-align: center !important;
  color: rgba(59, 130, 246, 0.8) !important;
  flex-shrink: 0 !important;
  font-size: 18px !important;
}

/* ============================================
   MENU ITEM TEXT
   ============================================ */
.menu-item span {
  flex: 1 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* ============================================
   MENU HEADER
   ============================================ */
.menu-header {
  flex-shrink: 0 !important;
  padding: 20px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  position: relative !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* ============================================
   USER SECTION
   ============================================ */
.menu-user-section {
  flex-shrink: 0 !important;
  padding: 20px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: rgba(0, 0, 0, 0.2) !important;
  position: relative !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* User row (avatar + name) */
.menu-user-row {
  display: flex !important;
  align-items: center !important;
  gap: 15px !important;
  margin-bottom: 15px !important;
}

/* User avatar circle in menu - ensure icon displays */
.menu-user-avatar {
  width: 50px !important;
  height: 50px !important;
  min-width: 50px !important;
  min-height: 50px !important;
  background: linear-gradient(135deg, #00bfff, #8a2be2) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  font-size: 22px !important;
  flex-shrink: 0 !important;
}

.menu-user-avatar i {
  display: inline-block !important;
  font-size: 22px !important;
  color: inherit !important;
}

/* Logout button - fix icon and layout */
.menu-logout-btn,
#menu-logout-btn {
  width: 100% !important;
  padding: 12px 16px !important;
  background: rgba(255, 68, 68, 0.15) !important;
  border: 1px solid #ff4444 !important;
  border-radius: 8px !important;
  color: #ff4444 !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  transition: all 0.3s ease !important;
}

.menu-logout-btn:hover,
#menu-logout-btn:hover {
  background: rgba(255, 68, 68, 0.25) !important;
  transform: scale(1.02) !important;
}

/* Logout icon - ensure it displays (FA6: right-from-bracket, FA5 alias: sign-out-alt) */
.menu-logout-btn i,
#menu-logout-btn i {
  display: inline-block !important;
  font-size: 16px !important;
  width: 1em !important;
  height: 1em !important;
  color: inherit !important;
  flex-shrink: 0 !important;
}

/* Fallback if FA6 icon not loaded - use sign-out-alt */
.menu-logout-btn .fa-right-from-bracket,
.menu-logout-btn .fa-sign-out-alt,
#menu-logout-btn .fa-right-from-bracket,
#menu-logout-btn .fa-sign-out-alt {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}

/* Header user avatar (when logged in) - ensure icon displays */
.header-user-avatar {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  background: linear-gradient(135deg, #00bfff, #8a2be2) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  font-size: 18px !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
}

.header-user-avatar i {
  display: inline-block !important;
  font-size: 18px !important;
  color: inherit !important;
}

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

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

/* ============================================
   REMOVE ANY PSEUDO-ELEMENTS THAT COULD OVERFLOW
   ============================================ */
.menu-item::before,
.menu-item::after {
  display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .hamburger-panel {
    width: 300px !important;
    max-width: 85vw !important;
  }
  
  .hamburger-panel,
  .hamburger-panel *,
  .menu-item {
    max-width: 300px !important;
  }
}

@media (max-width: 480px) {
  .hamburger-panel {
    width: 280px !important;
    max-width: 90vw !important;
  }
  
  .hamburger-panel,
  .hamburger-panel *,
  .menu-item {
    max-width: 280px !important;
  }
}
