/* 
 * GreenIT - Mobile Navigation Styles
 * 
 * Purpose: Complete mobile navigation solution (≤ 768px)
 * 
 * Includes:
 * 1. Hamburger menu button (three lines → X animation)
 * 2. Mobile dropdown menu (fixed positioning, scrolling, background gradient)
 * 3. Display/hide utility classes (.desktop-only / .mobile-only)
 * 4. Mega Menu mobile version (.mobile-submenu)
 * 
 * Dependencies:
 * - CSS variables from styles.css (colors, spacing, etc.)
 * - HTML structure dynamically generated by components.js
 * 
 * Note:
 * - Desktop base styles are defined in styles.css
 * 
 */

/* Display/hide utilities */
.desktop-only {
  display: flex;
}

.mobile-only {
  display: none;
}

/* Mobile Submenu - Hidden on desktop */
.mobile-submenu {
  display: none;
}

/* Mobile menu button */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 1500;
  position: relative;
}

.mobile-menu-toggle span {
  display: block;
  width: 25px;
  height: 4px;
  min-height: 4px;
  background-color: #fff;
  margin: 3px 0;
  transition: all 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

@media (max-width: 1024px) {
  /* Mobile display/hide rules */
  .desktop-only {
    display: none;
  }
  
  .mobile-only {
    display: flex;
  }
  
  /* Hide desktop dropdown icon */
  .dropdown-icon {
    display: none !important;
  }
  
  /* Hamburger menu button styles - thicker bars */
  .mobile-menu-toggle {
    width: 30px;
    height: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 5px;
  }
  
  .mobile-menu-toggle span:nth-child(1) {
    width: 25px;
  }
  
  .mobile-menu-toggle span:nth-child(2) {
    width: 15px;
  }
  
  .mobile-menu-toggle span:nth-child(3) {
    width: 20px;
  }
  
  .main-header.scrolled .mobile-menu-toggle span {
    background-color: var(--color-gray-800);
    box-shadow: none;
  }
  
  /* Ensure navigation bar floats above hero area */
  .main-header {
    background: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    height: var(--header-height, 60px);
    box-sizing: border-box;
  }
  
  .main-header.scrolled {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: fixed;
  }
  
  /* Adjust menu position when header is scrolled and fixed */
  .main-header.scrolled .main-nav {
    top: 60px;
  }
  
  /* Mobile navigation menu - dropdown style */
  .main-nav {
    position: fixed;
    top: 60px;
    right: 0;
    width: 100%;
    max-height: calc(100vh - 60px);
    height: calc(100vh - 60px);
    z-index: 1400;
    margin: 0;
    padding: 0;
    display: block;
    transform: translateX(100%);
    opacity: 1;
    transition: transform 0.3s ease;
    border-radius: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  /* Responsive width: devices ≥540px use 85vw, max 520px */
  @media (min-width: 540px) {
    .main-nav {
      width: 85vw;
      max-width: 520px;
      border-top-left-radius: 12px;
      border-bottom-left-radius: 12px;
    }
  }
  
  /* Use semi-transparent light background for nav menu when not scrolled */
  .main-header:not(.scrolled) .main-nav {
    background: linear-gradient(to bottom, 
      rgba(25, 55, 109, 0.7) 0%,
      rgba(25, 55, 109, 0.6) 30%,
      rgba(25, 55, 109, 0.5) 50%,
      rgba(25, 55, 109, 0.4) 70%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  /* Use light background for nav menu after scrolling */
  .main-header.scrolled .main-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
  }
  
  /* Display menu when active - slide in from right */
  .main-nav.active {
    transform: translateX(0);
  }
  
  /* Navigation link list */
  .main-nav ul {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0 0 20px 0;
    list-style: none;
    flex-shrink: 0;
    min-height: min-content;
  }
  
  /* Navigation link styles */
  .main-nav a {
    display: flex;
    align-items: center;
    padding: 12px 20px; 
    font-size: 15px;
    font-weight: 500;
    color: var(--color-white) !important;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    position: relative;
    padding-left: 25px;
    letter-spacing: 0.3px;
    box-sizing: border-box;
  }

  .main-nav a::before { /* Small dot before navigation item */
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-primary);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .main-nav a:hover::before,
  .main-nav a.active::before {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
  }
  
  /* Menu item text color in scrolled state */
  .main-header.scrolled .main-nav li a {
    color: var(--color-gray-800) !important;
    text-shadow: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  .main-nav li:last-child a {
    border-bottom: none;
  }
  
  .main-nav a:hover, 
  .main-nav a.active {
    background-color: var(--color-primary);
    color: var(--color-white) !important;
    padding-left: 28px;
  }
  
  /* Remove underline effect from desktop */
  .main-nav a::after {
    display: none;
  }
  
  /* Menu button animation - modify to adapt to different bar lengths */
  .mobile-menu-toggle.active {
    align-items: center !important; /* Ensure content centered */
    justify-content: center !important; /* Horizontal center */
  }
  
  .mobile-menu-toggle.active span {
    margin: 0 !important;
    position: absolute !important;
    width: 25px !important; /* Active all bars uniform length */
    left: 50% !important; /* Center processing */
    transform-origin: center !important; /* Ensure rotation from center point */
    margin-left: -12.5px !important; /* Half width, to center */
  }
  
  .mobile-menu-toggle.active span:nth-child(1) {
    top: 50% !important; /* Center alignment */
    transform: translateY(-50%) rotate(45deg) !important; /* Clockwise rotation 45 degrees */
  }
  
  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0 !important;
    top: 50% !important;
  }
  
  .mobile-menu-toggle.active span:nth-child(3) {
    top: 50% !important; /* Center alignment */
    transform: translateY(-50%) rotate(-45deg) !important; /* Counterclockwise rotation 45 degrees */
  }
  
  /* Scrolled state X button */
  .main-header.scrolled .mobile-menu-toggle.active span {
    background-color: var(--color-gray-800) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
  }
  
  /* Button and language switch area in mobile menu */
  .main-nav .nav-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Scrolled state navigation right area styles */
  .main-header.scrolled .main-nav .nav-right {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  /* Optimize button display on transparent background */
  .main-nav .nav-right .btn.btn-primary {
    margin-bottom: 15px;
    width: 90%;
    max-width: 300px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--color-primary, #1eaf5f);
    border: 2px solid rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    z-index: 1;
  }
  
  /* Button glow effect */
  .main-nav .nav-right .btn.btn-primary:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%);
    z-index: -1;
  }
  
  .main-nav .nav-right .btn.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
    border-color: #fff;
  }
  
  .main-nav .nav-right .btn.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  }
  
  /* Optimize language switch styles - increase contrast */
  .main-nav .nav-right .language-toggle {
    background-color: rgba(25, 55, 109, 0.4); /* Darker background color */
    margin-top: 0;
    border-radius: 20px;
    padding: 5px 8px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(25, 55, 109, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  
  /* Scrolled state language switch - increase contrast */
  .main-header.scrolled .main-nav .language-toggle {
    background-color: rgba(25, 55, 109, 0.25);
    border-color: rgba(25, 55, 109, 0.3);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
  }

  /* Language switch link styles - increase visibility */
  .main-nav .nav-right .language-toggle a {
    color: #ffffff; /* Pure white */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    border-bottom: none;
    padding: 2px 10px;
    font-weight: 700; /* Bold font */
    position: relative;
    transition: all 0.2s ease;
    opacity: 0.9;
    letter-spacing: 0.5px; /* Increase character spacing */
  }
  
  /* Ensure language switch links have no dot */
  .main-nav .nav-right .language-toggle a::before {
    display: none;
  }
  
  /* Language switch active state - more obvious contrast */
  .main-nav .nav-right .language-toggle a.active {
    background-color: rgba(0, 150, 80, 0.8); /* Use green background */
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    opacity: 1;
    color: #fff;
  }
  
  /* Scrolled state language switch link - increase contrast */
  .main-header.scrolled .main-nav .language-toggle a {
    color: rgba(25, 55, 109, 0.9); /* Darker blue */
    text-shadow: none;
    font-weight: 600;
  }
  
  .main-header.scrolled .main-nav .language-toggle a.active {
    background-color: rgba(0, 150, 80, 0.7); /* Green background */
    color: #ffffff;
    font-weight: 700;
  }

  /* Mobile Submenu - Mega Menu mobile version */
  .mobile-submenu { 
    display: block; 
    padding: 6px 12px 10px; 
    background: rgba(46,204,113,0.04); 
  }
  
  .mobile-submenu .group + .group { 
    margin-top: 8px; 
    padding-top: 8px; 
    border-top: 1px dashed rgba(46,204,113,0.15); 
  }
  
  .main-nav .mobile-submenu h4 { 
    font-size: 13px; 
    font-weight: 700;
    color: var(--color-primary); 
    margin: 6px 0 4px; 
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }
  
  .main-nav .mobile-submenu .group a { 
    display: block; 
    padding: 4px 8px 4px 16px; 
    border-radius: 6px;
    color: var(--color-gray-700);
    font-size: 11px;
    font-weight: 400;
    transition: background .2s, color .2s;
    border-bottom: none;
    width: auto;
  }
  
  .main-nav .mobile-submenu .group a::before {
    display: none;
  }
  
  .main-nav .mobile-submenu .group a:hover { 
    background: rgba(46,204,113,0.12); 
    color: var(--color-primary-dark);
    padding-left: 16px;
  }

  body {
    padding-top: 0;
  }
} 