/* Dropdown Styles - CRITICAL FIXES */
.nav {
  overflow: visible !important;
}

.navin {
  overflow: visible !important;
}

nav#menu {
  overflow: visible !important;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown .dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.nav-dropdown .dropdown-toggle .arrow {
  font-size: 10px;
  transition: transform .3s;
}

.nav-dropdown:hover .dropdown-toggle .arrow {
  transform: rotate(180deg);
}

/* Dropdown menu - positioned BELOW the parent */
.nav-dropdown .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 15px 35px #101b6820;
  min-width: 240px;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .3s, transform .3s, visibility .3s;
  z-index: 9999;
  text-align: right;
  margin-top: 5px;
}

/* Show dropdown on hover - Desktop */
@media(min-width: 851px) {
  .nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

/* For dropdowns near the right edge, open to the LEFT side - Desktop */
@media(min-width: 851px) {
  .nav-dropdown:nth-last-child(-n+2) .dropdown-menu {
    right: auto;
    left: 0;
    transform: translateX(-10px) translateY(10px);
  }

  .nav-dropdown:nth-last-child(-n+2):hover .dropdown-menu {
    transform: translateX(0) translateY(0);
  }
}

.nav-dropdown .dropdown-menu a {
  display: block;
  padding: 10px 15px;
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
  text-align: right;
}

.nav-dropdown .dropdown-menu a:hover {
  background: #f0f3ff;
  color: var(--blue);
  padding-right: 20px;
}

.nav-dropdown .dropdown-menu a.active {
  background: var(--green);
  color: #fff;
}

/* ============================================================
   SECOND LEVEL SUBMENU - DROPS TO RIGHT SIDE
   ============================================================ */
.dropdown-submenu {
  position: relative;
}

.dropdown-submenu .submenu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  transition: all .2s;
  cursor: pointer;
  white-space: nowrap;
  text-align: right;
}

.dropdown-submenu .submenu-toggle .arrow-left {
  font-size: 14px;
  margin-right: auto;
  margin-left: 8px;
  transition: transform .3s;
  color: var(--muted);
}

.dropdown-submenu:hover .submenu-toggle {
  background: #f0f3ff;
  color: var(--blue);
  padding-right: 20px;
}

.dropdown-submenu .submenu-toggle.active {
  background: var(--green);
  color: #fff;
}

.dropdown-submenu .submenu-toggle.active .arrow-left {
  color: #fff;
}

/* Submenu drops to the RIGHT side */
.dropdown-submenu .submenu-menu {
  position: absolute;
  top: 0;
  right: 100%;
  left: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 15px 35px #101b6820;
  min-width: 220px;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: opacity .3s, transform .3s, visibility .3s;
  z-index: 9999;
  text-align: right;
}

/* Show submenu on hover - Desktop */
@media(min-width: 851px) {
  .dropdown-submenu:hover .submenu-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
  }
}

.dropdown-submenu .submenu-menu a {
  display: block;
  padding: 10px 15px;
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
  text-align: right;
}

.dropdown-submenu .submenu-menu a:hover {
  background: #f0f3ff;
  color: var(--blue);
  padding-right: 20px;
}

.dropdown-submenu .submenu-menu a.active {
  background: var(--green);
  color: #fff;
}

/* ============================================================
   MOBILE RESPONSIVE - CRITICAL FIXES
   ============================================================ */
@media(max-width:850px) {
  .nav-dropdown {
    width: 100%;
    display: block;
  }
  
  .nav-dropdown .dropdown-toggle {
    width: 100%;
    justify-content: space-between;
    display: flex;
    padding: 10px 12px;
    border-radius: 8px;
    color: #4f5a70;
    font-size: 12px;
  }
  
  .nav-dropdown .dropdown-toggle:hover {
    background: #f0f3ff;
    color: var(--blue);
  }
  
  .nav-dropdown .dropdown-toggle .arrow {
    transition: transform .3s;
  }
  
  .nav-dropdown.open .dropdown-toggle .arrow {
    transform: rotate(180deg);
  }
  
  .nav-dropdown.open .dropdown-toggle {
    background: #f0f3ff;
    color: var(--blue);
  }
  
  .nav-dropdown .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 0;
    border-right: 3px solid var(--green);
    border-radius: 0;
    margin: 0;
    padding: 0 10px;
    background: transparent;
    display: none;
    width: 100%;
    margin-top: 0;
  }
  
  .nav-dropdown.open .dropdown-menu {
    display: block;
  }
  
  .nav-dropdown .dropdown-menu a {
    padding: 8px 15px;
    font-size: 11px;
    white-space: normal;
    border-radius: 8px;
  }
  
  .nav-dropdown .dropdown-menu a:hover {
    padding-right: 20px;
    background: #f0f3ff;
  }
  
  /* Reset right/left for mobile */
  .nav-dropdown:nth-last-child(-n+2) .dropdown-menu {
    right: auto;
    left: auto;
    transform: none;
  }
  
  /* ==========================================
     SUBMENU MOBILE STYLES
     ========================================== */
  .dropdown-submenu {
    width: 100%;
    display: block;
  }
  
  .dropdown-submenu .submenu-toggle {
    width: 100%;
    justify-content: space-between;
    display: flex;
    padding: 8px 15px;
    font-size: 11px;
  }
  
  .dropdown-submenu .submenu-toggle .arrow-left {
    transform: rotate(-90deg);
    transition: transform .3s;
  }
  
  .dropdown-submenu.open .submenu-toggle .arrow-left {
    transform: rotate(0deg);
  }
  
  .dropdown-submenu .submenu-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 0;
    border-right: 3px solid var(--green2);
    border-radius: 0;
    margin: 0;
    padding: 0 10px;
    background: transparent;
    display: none;
    width: 100%;
    margin-top: 0;
  }
  
  .dropdown-submenu.open .submenu-menu {
    display: block;
  }
  
  .dropdown-submenu .submenu-menu a {
    padding: 8px 15px;
    font-size: 11px;
    white-space: normal;
    border-radius: 8px;
  }
  
  .dropdown-submenu .submenu-menu a:hover {
    padding-right: 20px;
    background: #f0f3ff;
  }
}

/* Mobile Menu Container */
@media(max-width:850px) {
  nav#menu {
    display: none;
    position: absolute;
    top: 78px;
    right: 18px;
    left: 18px;
    background: #fff;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 15px 35px #101b6820;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
  
  nav#menu.open {
    display: flex;
  }
  
  nav#menu > a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: #4f5a70;
    font-size: 12px;
    width: 100%;
  }
  
  nav#menu > a:hover,
  nav#menu > a.active {
    background: #f0f3ff;
    color: var(--blue);
  }
}