/* Header Styles */
.header {
  background: #f4f3f8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  margin: 0;
  padding: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  width: 100%;
  max-width: 516px;
  margin: 0 auto;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 0;
}

.logo-img {
  height: 48px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #6ab43e;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.7rem;
  color: #7c7c7c;
}

.header-nav {
  display: flex;
  gap: 32px;
  align-items: center;
}

.header-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #222;
  text-decoration: none;
  font-size: 0.85rem;
  min-width: 56px;
  max-width: 56px;
  position: relative;
  transition: color 0.3s;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

.header-icon.active-green {
  color: #a6ce39 !important;
}

.header-icon:hover {
  color: #7CB342;
}

.header-icon i {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.header-icon span {
  font-size: 0.8rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: none;
  max-width: none;
}

.menu-toggle {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  margin-right: 0;
}

.hamburger {
  width: 24px;
  height: 3px;
  background: #222;
  border-radius: 2px;
}

/* Header dropdown */
.header-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  position: relative;
  transition: all 0.3s ease;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 8px;
}


.dropdown-toggle:hover,
.dropdown-toggle.active {
  color: #A6CE39 !important;
  background: transparent !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  border: none !important;
  z-index: 1001;
  position: relative;
  margin-bottom: 0;
}

.dropdown-toggle:hover i,
.dropdown-toggle.active i {
  color: #A6CE39; 
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  padding: 12px 0;
  min-width: 220px;
  width: 220px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  margin-top: 0;
}

/* Dropdown mobile click functionality */
.header-dropdown.dropdown-open .dropdown-menu,
.nav-dropdown.dropdown-open .dropdown-menu,
.header-dropdown.active .dropdown-menu,
.nav-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Dropdown Items */
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  color: #333;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background-color 0.2s, color 0.2s;
  gap: 12px;
  border-radius: 8px;
  margin: 2px 8px;
  white-space: nowrap;
  background: transparent;
}

.dropdown-item:hover {
  background-color: #a6ce39 !important;
  color: white !important;
}

.dropdown-item:active,
.dropdown-item.selected {
  background-color: #a6ce39 !important;
  color: white !important;
}

/* Current page highlighting */
.dropdown-item.current-page {
  background-color: #a6ce39 !important;
  color: white !important;
  font-weight: 600;
}

.submenu-item.current-page {
  background-color: #a6ce39 !important;
  color: white !important;
  font-weight: 600;
}

.header-icon.current-page {
  color: #A6CE39 !important;
  font-weight: 600;
}

.header-icon.current-page i,
.header-icon.current-page span {
  color: #A6CE39 !important;
}

/* Tab có item con đang active */
.dropdown-toggle.has-active-child {
  color: #A6CE39 !important;
}

.dropdown-toggle.has-active-child i,
.dropdown-toggle.has-active-child span {
  color: #A6CE39 !important;
}

/* Parent dropdown item có submenu item active */
.dropdown-item.has-submenu.has-active-child {
  background-color: #f0f8e8 !important;
  color: #a6ce39 !important;
  font-weight: 600;
}

.dropdown-item.has-submenu.has-active-child .submenu-arrow {
  color: #a6ce39 !important;
}

.dropdown-item.has-submenu {
  position: relative;
  background: transparent;
  color: #333;
  font-weight: 600;
  z-index: 10;
  overflow: visible;
  white-space: nowrap;
  margin: 2px 8px;
  border-radius: 8px;
}

.dropdown-item.has-submenu:hover {
  background: #a6ce39 !important;
  color: white !important;
  border-radius: 8px;
  margin: 2px 8px;
}

.dropdown-item.has-submenu:active,
.dropdown-item.has-submenu.selected {
  background: #a6ce39 !important;
  color: white !important;
  border-radius: 8px;
  margin: 2px 8px;
}

.dropdown-item.has-submenu .submenu-arrow {
  margin-left: auto;
  color: #333;
  font-size: 0.8rem;
  transition: color 0.2s;
}

.dropdown-item.has-submenu:hover .submenu-arrow,
.dropdown-item.has-submenu:active .submenu-arrow,
.dropdown-item.has-submenu.selected .submenu-arrow {
  color: white !important;
}

.dropdown-item span {
  flex: 1;
  font-weight: 500;
}

/* Submenu */
.has-submenu {
  position: relative;
}

.submenu-arrow {
  font-size: 0.8rem !important;
  margin-left: auto;
  transition: transform 0.3s;
  color: inherit;
}

.has-submenu:hover .submenu-arrow {
  transform: rotate(0deg);
}

.has-submenu .submenu {
  position: absolute;
  top: -50px;
  left: calc(100% + 8px);
  background: white;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  min-width: auto;
  width: max-content;
  max-width: 180px;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition: all 0.2s ease;
  border: 1px solid #e5e5e5;
}

/* Tạo khu vực hover buffer giữa dropdown item và submenu */
.has-submenu .submenu::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -8px;
  width: 8px;
  height: calc(100% + 10px);
  background: transparent;
  z-index: -1;
}

/* Desktop hover cho submenu */
@media (min-width: 769px) {
  .has-submenu:hover .submenu {
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Giữ submenu mở khi hover vào chính submenu */
  .submenu:hover {
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Đảm bảo hover buffer hoạt động trên desktop */
  .has-submenu:hover .submenu::before {
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Khi hover vào parent item, hiển thị submenu */
  .has-submenu:hover .submenu,
  .has-submenu.show-submenu .submenu {
    opacity: 1 !important;
    visibility: visible !important;
  }
}

.has-submenu.show-submenu .submenu {
  opacity: 1 !important;
  visibility: visible !important;
}

.has-submenu .submenu,
.has-submenu.hide-submenu .submenu {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Submenu Items */
.submenu-item {
  display: block;
  padding: 10px 14px;
  color: #333;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 1px 6px;
  font-weight: 500;
  background: transparent;
  white-space: nowrap;
}

.submenu-item:hover,
.submenu-item:active,
.submenu-item:focus {
  background-color: #f8f9fa;
  color: #a6ce39;
  border-radius: 6px;
  margin: 1px 6px;
  transition: all 0.2s ease;
}

.submenu .submenu-item:hover,
.submenu .submenu-item:active,
.submenu .submenu-item:focus,
a.submenu-item:hover,
a.submenu-item:active,
a.submenu-item:focus {
  background-color: #f8f9fa !important;
  color: #a6ce39 !important;
  border-radius: 8px !important;
  margin: 2px 8px !important;
  transition: all 0.2s ease !important;
}

.submenu-item.vls-suggest {
  border: none;
  margin: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  background-color: transparent;
  color: #222;
  padding: 8px 10px;
}

.submenu-item.vls-suggest:hover,
.submenu-item.vls-suggest:active,
.submenu-item.vls-suggest:focus {
  background-color: #f8f9fa !important;
  border-color: none;
  color: #a6ce39 !important;
  border-radius: 8px !important;
  margin: 2px 8px !important;
}

.submenu-item i {
  display: none !important;
}

/* Dropdown overlay for mobile */
.dropdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 999;
  display: none;
}

.nav-dropdown.active ~ .dropdown-overlay {
  display: block;
}

/* Header icons - same color as menu toggle */
.header-icon i,
.header-icon span {
  color: #222 !important;
}

/* Dropdown toggle - consistent with other icons */
.dropdown-toggle i {
  color: #222 !important;
}

.dropdown-toggle span {
  color: #222 !important;
}

.dropdown-toggle:hover i,
.dropdown-toggle:hover span,
.dropdown-toggle.active i,
.dropdown-toggle.active span {
  color: #A6CE39 !important;
}

.dropdown-toggle.active {
  color: #A6CE39 !important;
  background: transparent !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  border: none !important;
  z-index: 1001;
  position: relative;
  margin-bottom: 0;
}

/* Mobile responsive for small screens */
@media (max-width: 430px) {
  .logo-img {
    height: 42px;
    max-width: 95px;
  }
  
  .header-nav {
    gap: 16px;
    justify-content: space-between;
  }
  
  .header-icon {
    min-width: 44px;
    max-width: 44px;
    font-size: 0.65rem;
    padding: 5px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
  }
  
  .header-icon i {
    font-size: 1.2rem;
    margin-bottom: 3px;
    line-height: 1;
  }
  
  .header-icon span {
    font-size: 0.65rem;
    line-height: 1.1;
    overflow: visible;
    white-space: nowrap;
    max-width: none;
  }
  
  .dropdown-toggle {
    min-width: 44px;
    max-width: 44px;
    padding: 5px 4px;
    margin: -5px -4px;
  }
  
  .dropdown-toggle i {
    font-size: 1.2rem !important;
    margin-bottom: 3px;
  }
  
  .dropdown-toggle span {
    font-size: 0.65rem !important;
    line-height: 1.1;
    white-space: nowrap;
    overflow: visible;
  }
}

/* Mobile responsive for medium small screens */
@media (min-width: 431px) and (max-width: 600px) {
  .header-content {
    padding: 8px 24px;
    max-width: none;
  }
  
  .logo-img {
    height: 48px;
    max-width: 115px;
  }
  
  .header-nav {
    gap: 12px;
  }
  
  .header-icon {
    min-width: 50px;
    max-width: 50px;
    font-size: 0.85rem;
    overflow: visible;
  }
  
  .header-icon i {
    font-size: 1.3rem;
    margin-bottom: 3px;
  }
  
  .header-icon span {
    font-size: 0.75rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: visible;
  }
  
  .dropdown-toggle {
    min-width: 50px;
    max-width: 50px;
    padding: 7px 5px;
    margin: -7px -5px;
  }
  
  .dropdown-toggle i {
    font-size: 1.3rem !important;
    margin-bottom: 3px;
  }
  
  .dropdown-toggle span {
    font-size: 0.75rem !important;
    line-height: 1.1;
    white-space: nowrap;
    overflow: visible;
  }
}

/* Mobile responsive cho dropdown */
@media (max-width: 768px) and (min-width: 601px) {
  .header-nav {
    gap: 18px;
  }
  
  .header-icon {
    min-width: 54px;
    max-width: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
  }
  
  .header-icon i {
    font-size: 1.4rem;
    margin-bottom: 3px;
    line-height: 1;
  }
  
  .header-icon span {
    font-size: 0.8rem;
    line-height: 1.1;
    font-weight: 500;
    white-space: nowrap;
    overflow: visible;
    text-overflow: none;
    max-width: none;
  }
  
  /* Reset dropdown styles for mobile */
  .dropdown-toggle {
    padding: 9px 5px;
    margin: -9px -5px;
    border-radius: 8px;
    min-width: 54px;
    max-width: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: visible;
  }
  
  .dropdown-toggle i {
    font-size: 1.4rem !important;
    margin-bottom: 3px;
    line-height: 1;
  }
  
  .dropdown-toggle span {
    font-size: 0.8rem !important;
    line-height: 1.1;
    font-weight: 500;
    white-space: nowrap;
    overflow: visible;
    text-overflow: none;
    max-width: none;
  }
  
  /* Mobile dropdown active state */
  .dropdown-toggle.active {
    color: #A6CE39 !important;
    background: transparent !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    border: none !important;
    z-index: 1001;
    position: relative;
    margin-bottom: 0;
  }
  
  .dropdown-toggle.active i,
  .dropdown-toggle.active span {
    color: #A6CE39 !important;
  }
  
  /* Mobile dropdown menu */
  .dropdown-menu {
    left: 50%;
    transform: translateX(-50%);
    min-width: 140px;
    width: 150px;
    margin-top: 0;
    top: calc(100% + 6px);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .nav-dropdown.active .dropdown-menu,
  .header-dropdown.active .dropdown-menu,
  .nav-dropdown.dropdown-open .dropdown-menu,
  .header-dropdown.dropdown-open .dropdown-menu {
    transform: translateX(-50%) translateY(0);
  }
  
  .dropdown-item {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  
  /* Mobile submenu adjustments */
  .submenu {
    left: calc(100% + 0.5px) !important;
    top: 8px !important;
    transform: translateY(0) translateX(-6px) !important;
    margin-left: 0;
    margin-top: 0;
    min-width: auto !important;
    width: max-content !important;
    max-width: 180px !important;
    z-index: 1001;
  }
  
  .has-submenu:hover .submenu,
  .has-submenu:focus-within .submenu,
  .has-submenu.show-submenu .submenu {
    transform: translateY(0) translateX(0) !important;
  }
  
  .submenu-item {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }
  
  /* Show dropdown when open */
  .header-dropdown.dropdown-open .dropdown-menu,
  .nav-dropdown.dropdown-open .dropdown-menu,
  .header-dropdown.active .dropdown-menu,
  .nav-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
  }
  
  /* Ensure dropdown closes properly */
  .header-dropdown:not(.dropdown-open):not(.active) .dropdown-menu,
  .nav-dropdown:not(.dropdown-open):not(.active) .dropdown-menu {
    opacity: 0;
    visibility: hidden;
  }
  
  .header-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle,
  .nav-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle {
    color: #222 !important;
    background: none;
    border-radius: 8px;
    box-shadow: none;
    margin-bottom: 0;
  }
  
  .header-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle i,
  .header-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle span,
  .nav-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle i,
  .nav-dropdown:not(.dropdown-open):not(.active) .dropdown-toggle span {
    color: #222 !important;
  }
}

/* Touch device optimizations */
@media (max-width: 768px) {
  /* Improve touch targets */
  .dropdown-toggle {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    min-height: 44px; /* iOS recommended touch target size */
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Prevent zoom on double tap */
  .dropdown-toggle,
  .dropdown-item {
    touch-action: manipulation;
  }
  
  /* Mobile active states with green background */
  .dropdown-item:active,
  .dropdown-item.active,
  .dropdown-item.has-submenu:active,
  .dropdown-item.has-submenu.active {
    background: #a6ce39 !important;
    color: white !important;
  }
  
  .dropdown-item.has-submenu:active .submenu-arrow,
  .dropdown-item.has-submenu.active .submenu-arrow {
    color: white !important;
  }
  
  /* Ensure proper z-index stacking */
  .nav-dropdown.active,
  .header-dropdown.active,
  .nav-dropdown.dropdown-open,
  .header-dropdown.dropdown-open {
    z-index: 1001;
  }
  
  .nav-dropdown.active .dropdown-menu,
  .header-dropdown.active .dropdown-menu,
  .nav-dropdown.dropdown-open .dropdown-menu,
  .header-dropdown.dropdown-open .dropdown-menu {
    z-index: 1002;
  }
  
  /* Disable hover effects on mobile only */
  @media (max-width: 768px) {
    .has-submenu:hover .submenu {
      opacity: 0 !important;
      visibility: hidden !important;
    }
  }
  
  /* Mobile submenu only shows via click/touch */
  .has-submenu.show-submenu .submenu {
    opacity: 1 !important;
    visibility: visible !important;
  }
}

/* Desktop responsive */
@media (min-width: 431px) and (max-width: 600px) {
  .header-content {
    padding: 8px 24px;
    max-width: none;
  }
  
  .header-nav {
    gap: 16px;
  }
  
  .header-icon {
    min-width: 48px;
    max-width: 48px;
  }
  
  .header-icon i {
    font-size: 1.25rem;
  }
  
  .header-icon span {
    font-size: 0.75rem;
  }
}

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1023px) {
  .header-content {
    padding: 12px 40px;
    max-width: none;
  }
  
  .header-nav {
    gap: 32px;
  }
  
  .header-icon {
    min-width: 52px;
    max-width: 52px;
    font-size: 0.9rem;
    overflow: visible;
  }
  
  .header-icon i {
    font-size: 1.4rem;
  }
  
  .header-icon span {
    font-size: 0.8rem;
    overflow: visible;
    white-space: nowrap;
  }
}

@media (min-width: 1024px) {
  /* Header full width */
  .header-content {
    padding: 16px 80px;
    max-width: none;
    margin: 0 auto;
    width: 100%;
  }
  .logo-group {
    margin-left: 0;
  }
  .logo-img {
    height: 60px;
    max-width: 200px;
  }
  .header-nav {
    gap: 48px;
  }
  .header-icon {
    font-size: 16px;
    padding: 10px 16px;
    gap: 12px;
    overflow: visible;
  }
  .header-icon i {
    font-size: 18px;
  }
  .header-icon span {
    font-size: 15px;
    font-weight: 500;
    overflow: visible;
    white-space: nowrap;
  }
  .dropdown-menu {
    min-width: 240px;
    padding: 15px 0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  }
  .dropdown-item {
    padding: 12px 24px;
    font-size: 15px;
  }
  .dropdown-item i {
    font-size: 16px;
    width: 20px;
  }
  .submenu {
    min-width: auto;
    width: max-content;
    max-width: 200px;
    border-radius: 10px;
  }
  .submenu-item {
    padding: 10px 16px;
    font-size: 14px;
  }
  .menu-toggle {
    display: flex;
    width: 32px;
    height: 32px;
    margin-right: 0;
  }
  .user-menu {
    min-width: 280px;
    padding: 25px;
    border-radius: 12px;
    position: fixed;
    top: 96px;
    right: 32px;
    left: auto;
    z-index: 4000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  }
}

/* --- Điều chỉnh dropdown cho mobile nhỏ --- */
@media (max-width: 600px) {
  .dropdown-menu {
    min-width: 120px;
    width: auto;
    max-width: 95vw;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 0;
    border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.10);
  }
  .dropdown-item {
    padding: 6px 12px;
    font-size: 0.92rem;
    min-width: 100px;
    width: 100%;
    box-sizing: border-box;
  }
}

/* --- Điều chỉnh dropdown cho tablet nhỏ --- */
@media (min-width: 601px) and (max-width: 900px) {
  .dropdown-menu {
    min-width: 150px;
    width: 60vw;
    max-width: 350px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 0;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  }
  .dropdown-item {
    padding: 10px 16px;
    font-size: 1rem;
  }
}

/* --- Ưu tiên cho mobile: giảm chiều rộng, padding dropdown --- */

/* Mobile submenu cho tất cả kích thước mobile */
@media (max-width: 768px) {
  .has-submenu .submenu {
    left: calc(100% + 0.5px) !important;
    top: 8px !important;
    transform: translateY(0) translateX(-6px) !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
    min-width: auto !important;
    width: max-content !important;
    max-width: 180px !important;
    z-index: 1001 !important;
  }
  
  .has-submenu:hover .submenu,
  .has-submenu:focus-within .submenu,
  .has-submenu.show-submenu .submenu {
    transform: translateY(0) translateX(0) !important;
  }
  
  .submenu-item {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }
}
