/* Global rule: Hide all images within .twocol.logo by default */
.twocol.logo img {
  display: none;
}

/* Show desktop logo on desktop */
.twocol.logo .desktop-logo {
  display: block;
}

/* Гамбургер и скрытие на десктопе */
#menu-toggle,
.menu-header {
  display: none;
}

.menu-footer-info {
  display: none;
}

.mobile-logo {
  display: none; /* Keep hidden by default for desktop */
}

#menu-toggle {
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
}

@media (max-width: 768px) {
  /* Hide aside element on mobile */
  aside {
    display: none !important;
  }

  /* Hide desktop logo on mobile */
  .twocol.logo .desktop-logo {
    display: none !important;
  }

  /* Show mobile logo on mobile */
  .twocol.logo .mobile-logo {
    display: block !important;
    max-width: 110px; /* Apply desired mobile logo width */
    height: auto;
  }

  /* Ensure the logo link is a block container on mobile */
  .twocol.logo a {
    display: block;
    width: 100%;
    height: auto;
    text-align: center; /* Center the logo */
    padding: 8px 0; /* Add some vertical padding */
  }

  /* Override desktop submenu positioning */
  #topmenu ul li.last .submenu-wrapper,
  #topmenu ul li .submenu-wrapper {
    right: auto !important;
    left: 0 !important;
    position: static !important;
    width: 100% !important;
  }

  #menu-toggle {
    display: block !important;
    font-size: 24px !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    padding: 10px !important;
    position: fixed !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 1002 !important;
    color: #333 !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Hide hamburger button when menu is active */
  .menu-container.active ~ #menu-toggle,
  .menu-container.active + #menu-toggle {
    display: none !important;
  }

  .menu-container {
    display: none;
    flex-direction: column !important;
    background: white;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto !important;
  }

  /* Mobile menu header with logo and close button */
  .menu-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid #eee;
    background: white;
    position: sticky;
    top: 0;
    z-index: 1001;
  }

  .logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 4px auto;
    padding-top: 4px;
  }

  .menu-header .menu-logo {
    max-width: 90px;
    margin: 0;
    display: block;
  }

  .menu-header .menu-close {
    margin-left: auto;
  }

  .menu-close {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
  }

  .menu-close:before {
    content: '×';
    font-size: 32px;
    line-height: 1;
  }

  .menu-container.active {
    display: flex !important;
  }

  .menu-container ul.menu {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    list-style: none;
    width: 100%;
  }

  /* Common styles for all menu levels */
  .menu-container ul.menu li,
  .menu-container .submenu-wrapper ul.menu li {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
  }

  .menu-container ul.menu li a,
  .menu-container .submenu-wrapper ul.menu li a {
    text-decoration: none;
    color: #333;
    display: block;
    width: 100%;
    position: relative;
    padding-right: 15px;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 1.4;
  }

  /* Add arrow indicator only for items that have submenus */
  .menu-container ul.menu li.expanded > a:after,
  .menu-container .submenu-wrapper li.expanded > a:after {
    display: none;
  }

  /* Show arrow only if item has submenu */
  .menu-container ul.menu li.expanded:has(.submenu-wrapper) > a:after,
  .menu-container .submenu-wrapper li.expanded:has(.submenu-wrapper) > a:after {
    display: block;
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #333;
    transition: transform 0.3s ease;
    cursor: pointer;
  }

  /* Add padding and clickable area only for items with submenus */
  .menu-container ul.menu li.expanded:has(.submenu-wrapper) > a,
  .menu-container .submenu-wrapper li.expanded:has(.submenu-wrapper) > a {
    padding-right: 40px;
  }

  /* Add a clickable area around the arrow */
  .menu-container ul.menu li.expanded:has(.submenu-wrapper) > a:before,
  .menu-container .submenu-wrapper li.expanded:has(.submenu-wrapper) > a:before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 40px;
    height: 100%;
    cursor: pointer;
  }

  .menu-container ul.menu li.expanded.open > a:after,
  .menu-container .submenu-wrapper li.expanded.open > a:after {
    transform: translateY(-50%) rotate(180deg);
  }

  .submenu-wrapper {
    display: none !important;
    width: 100%;
    box-sizing: border-box;
  }

  .submenu-wrapper.visible {
    display: block !important;
  }

  /* Style submenu items */
  .submenu-wrapper ul.menu {
    padding-left: 0;
    background: white;
  }

  .submenu-wrapper ul.menu li {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
  }

  .submenu-wrapper ul.menu li:last-child {
    border-bottom: none;
  }

  /* Nested submenu styling */
  .submenu-wrapper .submenu-wrapper {
    background: white;
  }

  .submenu-wrapper .submenu-wrapper ul.menu {
    background: white;
  }

  #menu-toggle.hidden {
    display: none !important;
  }

  .menu-footer-info {
    display: block !important;
    position: static;
    width: 100%;
    background: #f7f7f7;
    border-top: 1px solid #e0e0e0;
    padding: 18px 16px 16px 16px;
    box-sizing: border-box;
    font-size: 14px;
    color: #333;
    z-index: 1002;
    text-align: left;
  }

  .menu-footer-info .region-footer-info > div {
    margin-bottom: 4px;
  }

  .menu-footer-info .region-footer-info > div:first-child {
    font-weight: bold;
    font-size: 16px;
    color: #145080;
    margin-bottom: 6px;
  }

  .menu-footer-info .region-footer-info .social {
    display: flex;
    gap: 14px;
    margin-bottom: 10px;
    justify-content: flex-start;
  }

  .menu-footer-info .region-footer-info .social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.07);
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 22px;
  }

  .menu-footer-info .region-footer-info .social a img,
  .menu-footer-info .region-footer-info .social a i {
    width: 24px;
    height: 24px;
    display: block;
  }

  .menu-footer-info .region-footer-info .social a:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 6px rgba(0,0,0,0.13);
  }

  .menu-footer-info .region-footer-info a {
    color: #2374b8;
    text-decoration: underline;
    word-break: break-all;
  }

  .menu-footer-info .region-footer-info a:hover {
    color: #145080;
    text-decoration: none;
  }

  .menu-footer-info .region-footer-info .tel {
    font-weight: 500;
    letter-spacing: 0.01em;
  }

  #header {
    height: 65px !important; /* Adjust height for mobile header */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
  }
}

/* Desktop submenu hover logic */
#topmenu ul li .submenu-wrapper {
  display: none;
}
#topmenu ul li.hover > .submenu-wrapper,
#topmenu ul li:hover > .submenu-wrapper {
  display: block;
}

/* Hide mobile logo by default (for desktop) */
.mobile-logo {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop logo on mobile */
  .desktop-logo {
    display: none !important;
  }

  /* Show mobile logo on mobile */
  .mobile-logo {
    display: block !important;
  }

  /* The original .twocol.logo display: none rule might be redundant or problematic now. */
  /* If the above rules don't work, consider removing this section or adjusting its specificity. */
  /* For now, we'll keep it commented out to avoid unintended side effects. */
  /* .twocol.logo {
    display: none !important;
  } */

  /* Override desktop submenu positioning */
  #topmenu ul li.last .submenu-wrapper,
  #topmenu ul li .submenu-wrapper {
    right: auto !important;
    left: 0 !important;
    position: static !important;
    width: 100% !important;
  }
}