/* Mobile Hamburger Menu for Resume Sections */

/* Hamburger Button */
.mobile-hamburger-menu {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--primary-green);
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mobile-hamburger-menu:hover {
  background: var(--primary-green-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.mobile-hamburger-menu:active {
  transform: scale(0.95);
}

/* Hamburger Icon */
.hamburger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  position: relative;
}

.hamburger-line {
  width: 100%;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

/* Hamburger animation when open */
.mobile-hamburger-menu.open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-hamburger-menu.open .hamburger-line:nth-child(2) {
  opacity: 0;
}

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

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-menu-overlay.show {
  display: block;
  opacity: 1;
}

/* Mobile Menu Panel */
.mobile-menu-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--bg-primary);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-menu-panel.open {
  right: 0;
}

/* Mobile Menu Header */
.mobile-menu-header {
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-green), var(--primary-green-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.mobile-menu-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Content */
.mobile-menu-content {
  flex: 1;
  padding: 20px 0;
}

.mobile-menu-section {
  margin-bottom: 30px;
}

.mobile-menu-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 15px;
  padding: 0 20px;
}

.mobile-menu-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu-item {
  margin-bottom: 2px;
}

.mobile-menu-link {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
  font-size: 0.95rem;
  font-weight: 500;
}

.mobile-menu-link:hover {
  background: var(--bg-secondary);
  color: var(--primary-green);
  border-left-color: var(--primary-green);
}

.mobile-menu-link.active {
  background: var(--primary-green-alpha);
  color: var(--primary-green);
  border-left-color: var(--primary-green);
  font-weight: 600;
}

.mobile-menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Mobile Menu Tabs */
.mobile-menu-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 10px;
  margin: 0 20px 20px 20px;
  padding: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mobile-menu-tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mobile-menu-tab.active {
  background: var(--bg-primary);
  color: var(--primary-green);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.mobile-menu-tab:hover:not(.active) {
  color: var(--text-primary);
}

.mobile-menu-tab-icon {
  width: 16px;
  height: 16px;
}

/* Mobile Menu Footer */
.mobile-menu-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.mobile-menu-footer-btn {
  width: 100%;
  padding: 12px 20px;
  background: var(--primary-green);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mobile-menu-footer-btn:hover {
  background: var(--primary-green-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Mobile Menu Animations */
@keyframes slideInRight {
  from {
    right: -100%;
  }
  to {
    right: 0;
  }
}

@keyframes slideOutRight {
  from {
    right: 0;
  }
  to {
    right: -100%;
  }
}

/* Show hamburger menu only on mobile */
@media (max-width: 768px) {
  .mobile-hamburger-menu {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999 !important;
  }
  
  .mobile-menu-panel {
    z-index: 9998 !important;
  }
  
  .mobile-menu-overlay {
    z-index: 9997 !important;
  }
  
  /* Hide desktop sidebar on mobile when hamburger menu is present */
  .editor-sidebar {
    display: none;
  }
  
  /* Adjust editor main content for mobile */
  .editor-main-content {
    width: 100%;
    margin-left: 0;
  }
  
  /* Ensure proper z-index stacking */
  .mobile-menu-overlay {
    z-index: 999;
  }
  
  .mobile-menu-panel {
    z-index: 1000;
  }
  
  .mobile-hamburger-menu {
    z-index: 1001;
  }
}

/* Integration with existing mobile responsive styles */
@media (max-width: 768px) {
  /* Ensure hamburger menu works with existing mobile layout */
  .editor-container {
    position: relative;
  }
  
  /* Hide the original sidebar when hamburger menu is active */
  .mobile-hamburger-menu ~ .editor-container .editor-sidebar {
    display: none !important;
  }
  
  /* Adjust main content area when hamburger menu is present */
  .mobile-hamburger-menu ~ .editor-container .editor-main-content {
    width: 100% !important;
    margin-left: 0 !important;
    padding: 1rem !important;
  }
  
  /* Smooth transitions for hamburger menu */
  .mobile-hamburger-menu {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .mobile-hamburger-menu:hover {
    transform: scale(1.1);
  }
  
  .mobile-hamburger-menu:active {
    transform: scale(0.9);
  }
  
  /* Enhanced mobile menu animations */
  .mobile-menu-panel {
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .mobile-menu-overlay {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Better visual feedback for menu items */
  .mobile-menu-link {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
  }
  
  .mobile-menu-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
  }
  
  .mobile-menu-link:active::before {
    left: 100%;
  }
  
  /* Improved touch feedback */
  .mobile-menu-link:active {
    transform: scale(0.98);
    background: var(--primary-green-alpha);
  }
  
  .mobile-menu-tab:active {
    transform: scale(0.95);
  }
  
  /* Enhanced scrolling in menu */
  .mobile-menu-content {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better spacing for mobile */
  .mobile-menu-items {
    padding-bottom: 20px;
  }
  
  .mobile-menu-item:last-child .mobile-menu-link {
    border-bottom: none;
  }
  
  /* Accessibility improvements */
  .mobile-hamburger-menu:focus {
    outline: 3px solid var(--primary-green);
    outline-offset: 2px;
  }
  
  .mobile-menu-link:focus {
    outline: 2px solid var(--primary-green);
    outline-offset: -2px;
  }
  
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .mobile-menu-panel {
      border: 2px solid var(--text-primary);
    }
    
    .mobile-menu-link {
      border-bottom: 1px solid var(--border-color);
    }
  }
  
  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    .mobile-hamburger-menu,
    .mobile-menu-panel,
    .mobile-menu-overlay,
    .mobile-menu-link {
      transition: none !important;
    }
    
    .mobile-menu-link::before {
      display: none;
    }
  }
}

/* Additional mobile menu positioning */
@media (max-width: 768px) {
  .mobile-hamburger-menu {
    position: fixed !important;
    left: 24px !important;
    bottom: 24px !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 1001 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-green);
    color: white;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .mobile-hamburger-menu:hover {
    background: var(--primary-green-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  }
  .mobile-hamburger-menu:active {
    transform: scale(0.95);
  }
  
  /* Adjust for mobile keyboards */
  @media (max-height: 600px) {
    .mobile-menu-panel {
      padding-bottom: 60px;
    }
  }
  
  /* Landscape orientation adjustments */
  @media (orientation: landscape) {
    .mobile-menu-panel {
      width: 380px;
    }
    
    .mobile-hamburger-menu {
      top: 15px;
      right: 15px;
    }
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .mobile-hamburger-menu {
    top: 15px !important;
    right: 15px !important;
    width: 50px !important;
    height: 50px !important;
  }
  
  .mobile-menu-panel {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .mobile-menu-header {
    padding: 15px !important;
  }
  
  .mobile-menu-title {
    font-size: 1.125rem !important;
  }
  
  .mobile-menu-link {
    padding: 12px 15px !important;
    font-size: 0.9rem !important;
  }
  
  .mobile-menu-icon {
    width: 18px !important;
    height: 18px !important;
  }
}

/* Integration with existing form improvements */
@media (max-width: 768px) {
  /* Ensure forms work well with hamburger menu */
  .mobile-hamburger-menu ~ .editor-container .form-group {
    margin-bottom: 1.5rem;
  }
  
  .mobile-hamburger-menu ~ .editor-container .project-card {
    margin-bottom: 2rem;
  }
  
  /* Adjust z-index for any modals or overlays */
  .modal,
  .toast-container {
    z-index: 1002;
  }
  
  /* Ensure hamburger menu works with existing mobile responsive features */
  .mobile-hamburger-menu ~ .editor-container .mobile-sidebar-toggle {
    display: none !important;
  }
}

/* Ensure proper section visibility when hamburger menu is used */
@media (max-width: 768px) {
  /* Make sure editor sections are properly handled */
  .editor-section-content {
    display: block !important;
    width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
  }
  
  .editor-section-content.hidden {
    display: none !important;
  }
  
  /* Ensure main content area is properly sized */
  .editor-main-content {
    min-height: 100vh !important;
    padding: 1rem !important;
  }
  
  /* Force visibility of active section */
  .editor-section-content:not(.hidden) {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Transition for smooth section switching */
  .editor-section-content {
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
  }
  
  /* Ensure sections don't overlap */
  .editor-section-content {
    position: relative !important;
    z-index: 1 !important;
  }
  
  /* Debug helper - remove in production */
  .editor-section-content:not(.hidden) {
    border: 2px solid transparent !important;
    animation: sectionActivate 0.3s ease !important;
  }
  
  @keyframes sectionActivate {
    0% {
      border-color: var(--primary-green);
      opacity: 0.8;
    }
    100% {
      border-color: transparent;
      opacity: 1;
    }
  }
}

/* Hide original bottom navigation on mobile when hamburger menu is active */
@media (max-width: 768px) {
    /* Hide the original editor sidebar navigation */
    .editor-sidebar {
        display: none !important;
    }
    
    /* Hide any sidebar tabs */
    .sidebar-tabs {
        display: none !important;
    }
    
    /* Hide mobile sidebar toggle if it exists */
    .mobile-sidebar-toggle {
        display: none !important;
    }
    
    /* Hide sidebar content */
    .sidebar-content {
        display: none !important;
    }
    
    /* Hide section navigation */
    .section-nav {
        display: none !important;
    }
    
    /* Ensure main content takes full width when sidebar is hidden */
    .editor-main-content {
        width: 100% !important;
        padding: 1rem !important;
    }
    
    /* Ensure editor container takes full width */
    .resume-editor-container {
        flex-direction: column !important;
    }
}

/* Hide hamburger menu on desktop/tablet views */
@media (min-width: 769px) {
    .mobile-hamburger-menu {
        display: none !important;
    }
    
    .mobile-menu-panel {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
    
    /* Restore original sidebar layout on desktop - remove all mobile overrides */
    .editor-sidebar {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: none !important;
        order: unset !important;
        overflow: visible !important;
    }
    
    .sidebar-tabs {
        display: flex !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        border-bottom: none !important;
        justify-content: flex-start !important;
        gap: 0 !important;
        padding: 0 !important;
    }
    
    .sidebar-content {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    
    .section-nav {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    
    .mobile-sidebar-toggle {
        display: none !important;
    }
    
    /* Ensure editor container uses original desktop layout */
    .resume-editor-container {
        flex-direction: row !important;
        display: flex !important;
    }
    
    .editor-main-content {
        width: auto !important;
        flex: 1 !important;
        padding: 1rem !important;
    }
}

/* Ensure hamburger menu is only visible on mobile */
.mobile-hamburger-menu {
    display: none; /* Hidden by default */
}

/* CRITICAL: Override editor-layout-fixes.css for desktop - highest specificity */
@media screen and (min-width: 769px) {
    /* Use higher specificity selectors to override other CSS files */
    body .editor-container .editor-sidebar {
        display: flex !important;
        flex-direction: column !important;
        position: static !important;
        width: 320px !important;
        height: auto !important;
        max-height: none !important;
        border-right: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        order: 0 !important;
        overflow: hidden !important;
    }
    
    body .editor-container .editor-main-content {
        width: auto !important;
        flex: 1 !important;
        order: 0 !important;
        padding: 1rem !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    body .editor-container {
        flex-direction: row !important;
        height: auto !important;
        display: flex !important;
    }
    
    body .editor-sidebar .sidebar-tabs {
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        gap: 0 !important;
        padding: 0 !important;
        background-color: var(--bg-secondary) !important;
        border-bottom: 1px solid var(--border-color) !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        flex-shrink: 0 !important;
    }
    
    body .editor-sidebar .sidebar-content {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
    
    body .editor-sidebar .section-nav {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

/* Desktop tab switching - only show active tab content */
@media screen and (min-width: 769px) {
    /* Hide all sidebar content by default */
    body .editor-sidebar .sidebar-content {
        display: none !important;
    }
    
    /* Show only the active sidebar content */
    body .editor-sidebar .sidebar-content.active {
        display: block !important;
    }
    
    /* Ensure tab buttons work properly */
    body .editor-sidebar .sidebar-tab {
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    body .editor-sidebar .sidebar-tab.active {
        background-color: var(--primary-green) !important;
        color: white !important;
    }
    
    body .editor-sidebar .sidebar-tab:hover {
        background-color: var(--primary-green-light) !important;
    }
    
    body .editor-sidebar .sidebar-tab.active:hover {
        background-color: var(--primary-green) !important;
    }
}
