/* Main Navigation Top Bar */
.main-navigation {
  width: 100%;
  background-color: transparent;
  padding: 0 !important;
  margin: 0 !important;
}

.wp-custom-nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  gap: 20px;
  direction: rtl;
  align-items: center;
  background-color: transparent;
  justify-content: flex-end; /* Align menu items to the left in RTL */
}

.wp-custom-nav-menu > li {
  position: relative;
  margin: 0;
  padding: 0;
  display: inline-block;
}

.wp-custom-nav-menu > li > a {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  color: #2d3748; /* Dark text for white background */
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  transition: color 0.2s;
  white-space: nowrap;
}

.wp-custom-nav-menu > li > a:hover {
  background-color: transparent;
  color: #f59e0b;
}

.wp-custom-nav-menu .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  list-style: none;
  margin: 0;
  padding: 8px 0;
  min-width: 200px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 999;
}

.wp-custom-nav-menu > li:hover > .sub-menu {
  display: block;
}

.wp-custom-nav-menu .sub-menu li {
  margin: 0;
  padding: 0;
  display: block;
}

.wp-custom-nav-menu .sub-menu a {
  display: block;
  padding: 10px 18px;
  color: #2d3748;
  text-decoration: none;
  font-size: 13px;
  transition: background-color 0.2s, color 0.2s;
}

.wp-custom-nav-menu .sub-menu a:hover {
  background-color: #f59e0b;
  color: white;
}

/* Logo Section */
.wp-block-site-logo img {
  width: 150px !important;
  height: auto !important;
}

@media (max-width: 768px) {
  .wp-custom-nav-menu {
    flex-direction: column;
    padding: 0 !important;
  }
  
  .wp-custom-nav-menu > li {
    width: 100%;
    border-bottom: 1px solid #444;
  }
  
  .wp-custom-nav-menu > li > a {
    padding: 12px 15px;
    justify-content: space-between;
  }
  
  .wp-custom-nav-menu .sub-menu {
    position: static;
    display: none;
    box-shadow: none;
    background: #1a202c;
    min-width: auto;
  }
  
  .wp-custom-nav-menu li.open > .sub-menu {
    display: block;
  }
  
  .wp-custom-nav-menu li.menu-item-has-children > a::after {
    content: ' ▾';
    font-size: 10px;
  }
  
  .wp-custom-nav-menu .sub-menu a {
    color: #ffffff;
    padding: 10px 20px;
    padding-right: 30px;
  }
}

/* Footer Navigation */
.wp-custom-footer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  direction: rtl;
}

.wp-custom-footer-menu > li {
  position: relative;
  margin: 0;
  padding: 0;
  display: inline-block;
}

.wp-custom-footer-menu > li > a {
  display: block;
  padding: 5px 10px;
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.wp-custom-footer-menu > li > a:hover {
  color: #f59e0b;
}

/* Footer Submenus - Open Upwards */
.wp-custom-footer-menu .sub-menu {
  display: none;
  position: absolute;
  bottom: 100%; /* Open upwards */
  left: 50%;
  transform: translateX(-50%);
  background: white;
  list-style: none;
  margin: 0;
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.2);
  z-index: 999;
  border-radius: 4px;
  margin-bottom: 10px; /* Space between link and menu */
}

/* Arrow to indicate menu comes from bottom */
.wp-custom-footer-menu .sub-menu::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: white transparent transparent transparent;
}

.wp-custom-footer-menu > li:hover > .sub-menu {
  display: block;
}

.wp-custom-footer-menu .sub-menu li {
  display: block;
  margin: 0;
}

.wp-custom-footer-menu .sub-menu a {
  display: block;
  padding: 8px 15px;
  color: #000000 !important;
  text-decoration: none;
  font-size: 13px;
  text-align: right;
}

.wp-custom-footer-menu .sub-menu a:hover {
  background-color: #f59e0b;
  color: white;
}

/* Mobile Footer */
@media (max-width: 768px) {
  .wp-custom-footer-menu {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .wp-custom-footer-menu .sub-menu {
    position: static;
    transform: none;
    background: rgba(255,255,255,0.1);
    box-shadow: none;
    margin-bottom: 0;
    width: 100%;
    text-align: center;
  }
  
  .wp-custom-footer-menu .sub-menu::after {
    display: none;
  }
  
  .wp-custom-footer-menu .sub-menu a {
    color: #ddd;
    text-align: center;
  }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 101; /* Ensure it's on top */
}

.mobile-menu-toggle .icon-bar {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #333;
    margin: 5px 0;
    transition: all 0.3s;
}

/* Styles for the 'X' icon when menu is open */
.mobile-menu-toggle.toggled .icon-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.mobile-menu-toggle.toggled .icon-bar:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.toggled .icon-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

@media (max-width: 768px) {
  .site-branding {
    flex-grow: 1; /* Allow logo to take available space */
  }

  .mobile-menu-toggle {
    display: block; /* Show on mobile */
  }

  .main-navigation {
    display: none;
    width: 100%;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-top: 1px solid #e2e8f0;
  }

  .main-navigation.toggled {
    display: block;
  }

  .wp-custom-nav-menu {
    flex-direction: column;
    padding: 10px 0 !important;
    align-items: flex-start;
    width: 100%;
    gap: 0;
  }
  
  .wp-custom-nav-menu > li {
    width: 100%;
    border-bottom: 1px solid #eee;
    display: block;
  }

  .wp-custom-nav-menu > li:last-child {
    border-bottom: none;
  }
  
  .wp-custom-nav-menu > li > a {
    padding: 15px 20px;
    justify-content: space-between;
    width: 100%;
  }
  
  .wp-custom-nav-menu .sub-menu {
    position: static;
    display: none;
    box-shadow: none;
    background: #f7fafc; /* Lighter background for submenu */
    min-width: auto;
    border-top: 1px solid #eee;
  }
  
  .wp-custom-nav-menu li.open > .sub-menu {
    display: block;
  }
  
  .wp-custom-nav-menu li.menu-item-has-children > a::after {
    content: '▾';
    font-size: 16px;
    margin-right: auto;
    margin-left: 10px;
  }
  
  .wp-custom-nav-menu .sub-menu a {
    color: #4a5568;
    padding: 12px 20px;
    padding-right: 40px; /* Indent sub-items */
  }

  .wp-custom-nav-menu .sub-menu a:hover {
    background-color: #edf2f7;
    color: #2d3748;
  }
}