/* Enhanced Mobile Menu Styles for AI Blog - Fixed Version */

/* Mobile menu bar */
.mobile-menu-bar {
  background: #ffffff;
  display: block;
  position: relative;
  z-index: 1001;
  border-bottom: 1px solid #000;
  margin-top: 5px;
}

.mobile-menu-bar button,
#mmenu-btn {
  display: flex;
  justify-content: flex-end;
  margin-left: auto;
  background: var(--color-primary);
  border: 2px solid #fff;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 10px 15px;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s ease;
  min-width: 80px;
  text-align: center;
}

.mobile-menu-bar button:hover,
.mobile-menu-bar button:focus,
#mmenu-btn:hover,
#mmenu-btn:focus {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.mobile-menu-bar button:active,
#mmenu-btn:active {
color: #fff;
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Menu button states */
#mmenu-btn[aria-expanded="true"] {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* Mobile navigation container */
nav#mobile-navigation {
  position: relative;
}

/* Mobile menu */
nav .wsm-menu {
  box-shadow: 0px 5px 42px -6px rgb(92 91 92);
  padding: 20px;
  margin-bottom: 10px;
  background: var(---light-body);
  position: absolute;
  left: auto;
  right: 0;
  top: 80px;
  z-index: 99999;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
  max-width: 350px;
  border-radius: 8px;
  overflow: hidden;
}

nav.menu-active .wsm-menu {
  top: 40px;
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

/* Menu lists */
.wsm-menu ul,
ul.wsm-menu {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Menu items */
.wsm-menu li {
  border-bottom: 1px solid #eee;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

nav.menu-active .wsm-menu li {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered animation for menu items */
nav.menu-active .wsm-menu li:nth-child(1) { transition-delay: 0.1s; }
nav.menu-active .wsm-menu li:nth-child(2) { transition-delay: 0.2s; }
nav.menu-active .wsm-menu li:nth-child(3) { transition-delay: 0.3s; }
nav.menu-active .wsm-menu li:nth-child(4) { transition-delay: 0.4s; }
nav.menu-active .wsm-menu li:nth-child(5) { transition-delay: 0.5s; }

/* Menu links */
.wsm-menu li a {
  padding: 12px 15px;
  text-decoration: none;
  display: block;
  color: var(--color-heading);
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.wsm-menu li a:hover,
.wsm-menu li a:focus {
  color: var(--color-primary);
  background-color: rgba(199, 0, 0, 0.1);
  padding-left: 25px;
  outline: none;
}

/* Menu items with children */
.menu-item-has-children {
  display: flex;
  flex-flow: row wrap;
  position: relative;
}

.menu-item-has-children > a {
  width: 80%;
  min-width: 200px;
}

.menu-item-has-children > i {
  padding: 12px 15px;
  margin-left: auto;
  cursor: pointer;
  color: var(--color-gray);
  transition: transform 0.3s ease, color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20%;
  min-width: 50px;
}

.menu-item-has-children > i:hover,
.menu-item-has-children > i:focus {
  color: var(--color-primary);
  background-color: rgba(199, 0, 0, 0.1);
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.menu-item-has-children.clicked > i {
  transform: rotate(180deg);
  color: var(--color-primary);
}

/* Submenus */
.menu-item-has-children .sub-menu {
  display: block;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background-color: #f9f9f9;
  border-radius: 4px;
  margin-top: 5px;
}

.menu-item-has-children.clicked .sub-menu {
  max-height: 300px;
  padding: 10px 0;
}

.sub-menu li a {
  padding: 8px 25px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-gray);
}

.sub-menu li a:hover,
.sub-menu li a:focus {
  color: var(--color-primary);
  background-color: rgba(199, 0, 0, 0.1);
  padding-left: 35px;
}

/* Close button states */
span.mclose {
  display: none;
}

nav.menu-active span.mclose {
  display: inline;
}

nav.menu-active span.mopen {
  display: none;
}

/* Dark mode support */
body.dark .wsm-menu {
  background: var(--section-color);
  color: var(--white);
}

body.dark .wsm-menu li a {
  color: var(--white);
}

body.dark .wsm-menu li a:hover,
body.dark .wsm-menu li a:focus {
  color: var(--color-primary);
  background-color: rgba(199, 0, 0, 0.2);
}

body.dark .sub-menu {
  background-color: var(--section-color-2) !important;
}

body.dark .sub-menu li a {
  color: #ccc;
}

body.dark .wsm-menu li {
  border-bottom-color: #333;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .wsm-menu {
    left: 10px !important;
    right: 10px !important;
    max-width: none !important;
    min-width: none !important;
    width: auto !important;
  }
  
  .menu-item-has-children > a {
    min-width: 150px;
  }
}

/* Hide desktop menu on mobile */
@media (max-width: 991px) {
  nav#site-navigation {
    display: none;
  }
  
  .mobile-menu-bar {
    display: block;
  }
}

/* Show desktop menu on larger screens */
@media (min-width: 992px) {
  .mobile-menu-bar {
    display: none;
  }
  
  nav#site-navigation {
    display: block;
  }
}

/* Accessibility improvements */
.wsm-menu li a:focus,
.menu-item-has-children > i:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Smooth animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

nav.menu-active .wsm-menu {
  animation: slideDown 0.3s ease;
}

/* Focus management */
.wsm-menu a:focus,
.mobile-menu-bar button:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Prevent body scroll when menu is active */
body.menu-open {
  overflow: hidden;
}

/* Loading animation for menu items */
.wsm-menu li {
  position: relative;
  overflow: hidden;
}

.wsm-menu li::before {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.wsm-menu li:hover::before {
  left: 100%;
}
