/* ============================================
   Combined Menu Styles (Desktop + Mobile)
   ============================================ */

/* ============ DESKTOP & GENERAL STYLES ============ */

.menu {
  background: linear-gradient(135deg, #274080 0%, #1e3566 100%);
  box-shadow: 0 4px 20px rgba(39, 64, 128, 0.15);
  position: relative;
  z-index: 1020; /* Главная панель должна быть выше выпадающего меню */
  border-radius: 50px;
}

.menu::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #274080 0%, #1e3566 100%);
  border-radius: inherit;
  z-index: 1005; /* Слой панели над выпадающим меню */
  pointer-events: none;
}

.menu .menu-nav {
  background: transparent !important;
  padding: 0;
  position: relative;
  z-index: 1010; /* Навигация выше слоя панели */
}

.menu .navbar {
  padding: 0;
  position: static;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.menu .navbar-nav {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 0;
  flex-wrap: nowrap;
}

/* ============ DESKTOP MENU STYLES ============ */
@media (min-width: 992px) {
  .menu .navbar-nav .nav-item {
    position: static;
    margin: 0;
    flex: 1;
    display: flex;
  }

  .menu .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
        font-weight: 400;
        font-size: 14px;
        padding: 20px 16px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 100%;
        white-space: nowrap;
        height: 100%;
        letter-spacing: 0.3px;
        overflow: hidden;
        z-index: 1010;
  }

  .menu .navbar-nav .nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #fff;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
    z-index: 1;
  }

  .menu .navbar-nav .nav-link:hover::before,
  .menu .navbar-nav .nav-item.active .nav-link::before,
  .menu .navbar-nav .nav-link.active::before {
    transform: scaleX(1);
  }

  .menu .navbar-nav .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
  }

  .menu .navbar-nav .nav-item.active .nav-link,
  .menu .navbar-nav .nav-link.active {
    color: #ffffff;
  }

  /* Mega Menu Dropdown */
  .menu .navbar-nav .dropdown-menu {
    position: absolute;
    left: 0;
    width: 100%;
    top: calc(100% - 25px); /* Меню заезжает под панель на 15px */
    margin: 0;
    padding: 3.5rem 2rem 2rem;
    border: none;
    border-radius: 0 0 25px 25px; /* Красивое закругление снизу */
    background: rgba(255, 255, 255, 0.98);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    align-content: start;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(0.99);
    transform-origin: top center;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
    z-index: 999; /* Ниже, чем панель, чтобы панель была поверх */
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
  }

  @media (max-width: 1399.98px) {
    .menu .navbar-nav .dropdown-menu {
      padding: 2.5rem calc((100% - 1140px) / 2);
    }
  }

  @media (max-width: 1199.98px) {
    .menu .navbar-nav .dropdown-menu {
      padding: 2.5rem calc((100% - 960px) / 2);
      grid-template-columns: repeat(3, 1fr);
    }
  }

  .menu .navbar-nav .dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  /* Mega Menu Items - Island Style */
  .menu .navbar-nav .dropdown-item {
        display: flex;
        gap: 15px;
        padding: 15px 15px;
        border-radius: 25px;
        border: 1px solid #edf0f6;
        transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
        min-height: 76px;
        white-space: normal;
        color: #2a3760;
        font-weight: 500;
        font-size: 15px;
        position: relative;
        text-decoration: none;
        align-items: center;
    }
  }

  .menu .navbar-nav .dropdown-item:hover {
    background: #ffffff;
    border-color: #dfe5f2;
    box-shadow: 0 10px 24px rgba(25, 40, 80, 0.12);
    color: #1e2f5f;
    z-index: 1;
  }

  .menu .navbar-nav .dropdown-item::before {
    content: '\f105';
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 14px;
    color: #1f3a7a;
    transition: all 0.25s ease;
    background: #ffffff;
    width: 38px;
    height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(20, 35, 70, 0.08);
    flex-shrink: 0;
  }

  .menu .navbar-nav .dropdown-item:hover::before {
    background: #1f3a7a;
    color: #ffffff;
    transform: translateX(2px);
  }

  .menu .navbar-nav .dropdown-toggle::after {
    content: "\f078";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    border: none;
    vertical-align: middle;
    margin-left: 10px;
    font-size: 10px;
    transition: transform 0.3s ease;
    opacity: 0.6;
  }

  .menu .navbar-nav .dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
    opacity: 1;
  }

  /* Responsive adjustments */
  @media (min-width: 992px) and (max-width: 1200px) {
    .menu .navbar-nav .nav-link {
      font-size: 14px;
      padding: 24px 10px;
    }
    
    .menu .navbar-nav .dropdown-menu {
      grid-template-columns: repeat(3, 1fr);
    }
  }


/* ============ MOBILE STYLES ============ */

/* Hamburger Burger Button */
.menu .navbar-toggler {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  margin: 10px 0;
  flex-shrink: 0;
}

.menu .navbar-toggler:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.menu .navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
  outline: none;
}

.menu .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

@media (max-width: 991px) {
  .menu {
    padding: 0 !important;
    min-height: auto;
  }

  .menu .navbar {
    padding: 0 !important;
    min-height: 48px;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
  }

  .navbar-toggler {
    height: 40px !important;
  }

  /* Toggler Button */
  .menu .navbar-toggler.mobile-menu-trigger {
    border: 1.5px solid rgba(255,255,255,0.35) !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    margin-left: 0;
    background-color: rgba(255,255,255,0.08) !important;
    transition: all 0.2s ease !important;
  }
  
  .menu .navbar-toggler.mobile-menu-trigger:hover {
    background-color: rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.5) !important;
  }

  .menu .navbar-toggler-icon {
    width: 1.2em;
    height: 1.2em;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.9)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
  }

  /* Search Input Area */
  .menu #search {
    padding: 6px 8px !important;
    flex: 1 !important;
    max-width: 100% !important;
  }

  .menu #search form {
    margin: 0;
    position: relative;
    flex: 1;
    max-width: 100%;
  }

  .menu #search input.form-control,
  .menu #search input[type="text"] {
        background-color: rgba(255, 255, 255, 0.12) !important;
        border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        height: 40px !important;
        padding: 6px 10px !important;
        border-radius: 9px !important;
        font-size: 13px !important;
        font-weight: 400 !important;
        transition: all 0.3s ease !important;
  }

  .menu #search input::placeholder {
    color: rgba(255, 255, 255, 0.65) !important;
    font-style: italic;
  }

  .menu #search input:focus {
    background-color: rgba(255, 255, 255, 0.18) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) inset, 0 0 12px rgba(255, 255, 255, 0.15) !important;
    outline: none !important;
  }
  
  .menu #search button[type="submit"] {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 8px;
    opacity: 0.9;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s ease;
  }
  
  .menu #search button[type="submit"]:hover {
    opacity: 1;
  }

  /* Old Bootstrap-based mobile menu (hidden) */
  .menu .navbar-collapse {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1e3566 0%, #274080 100%);
    z-index: 9999;
    padding: 64px 16px 32px;
    overflow-y: auto;
    height: 100vh;
    display: none;
  }

  .menu .mobile-menu-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .menu .mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg) scale(1.1);
  }

  .menu .navbar-nav {
    justify-content: flex-start;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
  }

  .menu .navbar-nav .nav-item {
    flex: none;
    width: 100%;
    margin: 0;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  .menu .navbar-nav .nav-link {
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
  }

  .menu .navbar-nav .nav-link:hover,
  .menu .navbar-nav .nav-item.active .nav-link {
    background-color: rgba(255, 255, 255, 0.16);
    color: #ffffff;
  }

  .menu .navbar-nav .dropdown-toggle::after {
    content: "\f078";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    border: none;
    margin-left: 10px;
    font-size: 10px;
    transition: transform 0.25s ease;
  }

  .menu .navbar-nav .dropdown.show .dropdown-toggle::after {
    transform: rotate(180deg);
  }

  .menu .navbar-nav .dropdown-menu {
    position: static;
    display: none;
    padding: 8px 12px 12px 16px;
    margin: 0;
    background: rgba(255, 255, 255, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .menu .navbar-nav .dropdown.show .dropdown-menu {
    display: block;
    animation: mobileAccordionOpen 0.25s ease;
  }

  @keyframes mobileAccordionOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .menu .navbar-nav .dropdown-item {
    color: rgba(255, 255, 255, 0.92);
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
    transition: background-color 0.2s ease, padding 0.2s ease;
    margin-bottom: 6px;
  }

  .menu .navbar-nav .dropdown-item:last-child {
    margin-bottom: 0;
  }

  .menu .navbar-nav .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.14);
    padding-left: 16px;
  }

  .menu .navbar-nav .dropdown-item.active {
    background-color: rgba(255, 255, 255, 0.18);
    font-weight: 600;
  }

  /* Extra small phones */
  @media (max-width: 380px) {
    .menu .navbar-toggler {
      padding: 8px 10px;
    }
    
    .menu .navbar #search {
      padding: 0 4px;
    }
  }
}

/* ============ NEW MOBILE MENU STYLES ============ */

/* Island Nav Bar */
.island-nav-wrapper {
    position: -webkit-sticky;
    position: sticky;
    top: 20px;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 0 15px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.island-home {
    margin-top: 55px; /* Отступ для главной, чтобы не перекрывать панель контактов */
}

.island-bar {
    background: #ffffff;
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 25px;
    height: 85px; /* Увеличена высота панели для логотипа */
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.island-logo-img {
    height: 55px; /* Увеличено на 50% от предыдущих 48px */
    width: auto;
    object-fit: contain;
}

.island-burger {
    background: #f8f9fa;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.island-burger:active {
    background-color: #f0f0f0;
    transform: scale(0.95);
}

.island-burger-line {
    width: 22px;
    height: 2px;
    background-color: #274080;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Overlay Container */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Side Drawer */
.mobile-menu-container {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 2100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: right 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
}

.mobile-menu-container.active {
    right: 0;
}

/* Header inside Menu */
.mobile-menu-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-menu-title {
    font-size: 18px;
    font-weight: 700;
    color: #274080;
    margin: 0;
}

.mobile-menu-close-btn {
    background: #f8f9fa;
    border: none;
    font-size: 20px;
    color: #333;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Search Area in Menu */
.mobile-menu-search-wrapper {
    padding: 20px;
    background: #f8f9fa;
}

.mobile-menu-search-wrapper .search-form {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 40px;
    padding: 4px 4px 4px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 0;
    position: relative;
}

.mobile-menu-search-wrapper .search-form__input,
.mobile-menu-search-wrapper .search-field,
.mobile-menu-search-wrapper input[type="text"] {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    flex: 1;
    padding: 10px 0 !important;
    font-size: 16px;
    color: #333;
    outline: none !important;
    width: 100%;
}

.mobile-menu-search-wrapper .search-submit,
.mobile-menu-search-wrapper button[type="submit"] {
    background: #274080;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.mobile-menu-search-wrapper .search-submit:hover {
    background: #1e3566;
}

/* Скрываем список ajax поиска если он пустой */
.mobile-menu-search-wrapper .ajax-search {
    display: none;
}

/* Socials Area in Menu */
.mobile-menu-socials {
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    gap: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-menu-social-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: #f0f2f5;
    color: #274080;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.mobile-menu-social-btn:hover {
    background-color: #274080;
    color: #fff;
}

/* Menu Items List */
.mobile-menu-list {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    width: 100%;
}

.mobile-menu-list .nav-item {
    margin: 0;
    width: 100%;
    display: block;
}

.mobile-menu-list .nav-link {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Изменили на flex-start для длинного текста */
    padding: 16px 20px;
    color: #333;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    border-bottom: 1px solid #f8f8f8;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

.mobile-menu-list .dropdown-toggle::after {
    content: '\f107';
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    border: none;
    font-size: 14px;
    margin-left: 15px;
    margin-top: 4px; /* Подвинем стрелку чуть ниже если текст в несколько строк */
    transition: transform 0.3s;
    flex-shrink: 0;
}

.mobile-menu-list .dropdown.show > .dropdown-toggle::after {
    transform: rotate(180deg);
}

.mobile-menu-list .dropdown-menu {
    position: static !important;
    float: none !important;
    background-color: #fcfcfc;
    border: none;
    padding: 0;
    display: none;
    width: 100% !important;
    box-shadow: none !important;
    transform: none !important;
}

.mobile-menu-list .dropdown-menu.show {
    display: block;
    animation: mobileFadeIn 0.3s ease;
}

@keyframes mobileFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mobile-menu-list .dropdown-item {
    padding: 12px 20px 12px 40px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f5f5f5;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    display: block;
    line-height: 1.5;
}

.btn-header-mobile {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5 !important;
    border: none !important;
    color: #274080 !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
}

.btn-header-mobile:hover {
    background: #274080 !important;
    color: #fff !important;
    transform: translateY(-3px);
}

.mobile-menu-footer {
    padding: 20px;
    margin-top: auto;
    border-top: 1px solid #eee;
}

.mobile-menu-footer .btn-header {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
}
