/* ==========================================================================
   PREMIUM HEADER & MEGA-MENU STYLES
   ========================================================================== */

:root {
  --header-bg: rgba(255, 255, 255, 0.72);
  --header-border: rgba(0, 0, 0, 0.06);
  --header-height: 72px;
  --header-shadow: 0 4px 30px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
  --dropdown-bg: rgba(255, 255, 255, 0.98);
  --dropdown-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
  --color-blue-rgb: 0, 113, 227;
  --color-orange-rgb: 255, 102, 0;
}

/* Header Container */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--header-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  padding: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 24px;
  max-width: 1300px;
  margin: 0 auto;
  position: relative;
}

/* Left Brand Wrapper */
.header-brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Logo */
.logo {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.7px;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-cap-icon {
  font-size: 1.55rem;
  color: var(--color-orange);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.logo:hover .logo-cap-icon {
  transform: rotate(-15deg) scale(1.15);
}

.logo span {
  color: var(--color-orange);
}

/* Bento Catalog Trigger */
.catalog-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(var(--color-blue-rgb), 0.06) 0%, rgba(var(--color-blue-rgb), 0.02) 100%);
  border: 1px solid rgba(var(--color-blue-rgb), 0.15);
  color: var(--color-blue);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.catalog-trigger-btn i.ti-apps {
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

.catalog-trigger-btn i.ti-chevron-down {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.catalog-trigger-btn:hover {
  background: linear-gradient(135deg, rgba(var(--color-blue-rgb), 0.1) 0%, rgba(var(--color-blue-rgb), 0.05) 100%);
  border-color: rgba(var(--color-blue-rgb), 0.3);
  box-shadow: 0 4px 15px rgba(var(--color-blue-rgb), 0.08);
}

.catalog-trigger-btn.active i.ti-apps {
  transform: rotate(90deg);
}

.catalog-trigger-btn.active i.ti-chevron-down {
  transform: rotate(180deg);
}

/* Navigation List */
.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* On desktop, the sheet scroll wrapper just passes through */
.mobile-sheet-scroll {
  display: contents;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  color: #000;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.nav-link i.ti-chevron-down {
  font-size: 0.75rem;
  transition: transform 0.25s ease;
}

.nav-item:hover>.nav-link {
  color: var(--text-main);
  background-color: rgba(0, 0, 0, 0.03);
}

.nav-item:hover>.nav-link i.ti-chevron-down {
  transform: rotate(180deg);
}

.nav-link.active {
  color: var(--color-blue);
  background-color: rgba(var(--color-blue-rgb), 0.05);
}

/* ==========================================================================
   DROPDOWN & MEGA MENU ARCHITECTURE
   ========================================================================== */

/* Standard Dropdown (Levels 2-4) */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background-color: #ffffff;
  border: 1px solid var(--header-border);
  border-radius: 16px;
  box-shadow: var(--dropdown-shadow);
  list-style: none;
  padding: 10px;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1100;
}

/* Hover Triggers */
.nav-item:hover>.dropdown-menu,
.nav-item:hover>.mega-menu-wrapper,
.dropdown-submenu:hover>.dropdown-menu,
.mega-menu-wrapper.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu li {
  position: relative;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: rgba(var(--color-blue-rgb), 0.05);
  color: var(--color-blue);
}

.dropdown-item-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-item-content i {
  font-size: 1.1rem;
  opacity: 0.8;
}

.dropdown-item i.ti-chevron-right {
  font-size: 0.75rem;
}

/* Submenu Flyouts (Level 3 & 4) */
.dropdown-submenu>.dropdown-menu {
  top: -10px;
  left: calc(100% + 4px);
}

/* Mega Menu Container */
.nav-item.has-mega-menu {
  position: static;
}

.mega-menu-wrapper {
  position: absolute;
  top: calc(100% + 8px);
  left: 24px;
  right: 24px;
  background-color: #ffffff;
  border: 1px solid var(--header-border);
  border-radius: 20px;
  box-shadow: var(--dropdown-shadow);
  padding: 30px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1200;
  max-width: 1250px;
  margin: 0 auto;
}

/* Bento Catalog Grid Layout */
.bento-catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.bento-column {
  display: flex;
  flex-direction: column;
}

.bento-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 16px;
}

.bento-header i {
  color: var(--color-orange);
  font-size: 1.25rem;
}

.bento-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Premium Card item */
.bento-card-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.bento-card-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background-color: rgba(var(--color-blue-rgb), 0.05);
  color: var(--color-blue);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.bento-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bento-card-text strong {
  font-size: 0.85rem;
  color: var(--text-main);
  transition: color 0.2s ease;
}

.bento-card-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.bento-card-item:hover {
  background-color: rgba(var(--color-blue-rgb), 0.04);
  transform: translateX(4px);
}

.bento-card-item:hover .bento-card-icon-box {
  background-color: var(--color-blue);
  color: #fff;
  transform: scale(1.05);
}

.bento-card-item:hover strong {
  color: var(--color-blue);
}

/* Main Navigation Mega Menu Grid (up to 4 levels) */
.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 30px;
}

.mega-grid-column {
  display: flex;
  flex-direction: column;
}

/* Level 2 heading */
.level2-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.level2-title i {
  color: var(--color-blue);
}

.level3-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Level 3 heading */
.level3-title {
  font-size: 0.82rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-orange);
  margin-bottom: 8px;
}

.level4-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level4-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 4px 0;
}

.level4-link:hover {
  color: var(--color-blue);
  transform: translateX(3px);
}

.level4-link i {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Action buttons & toggle */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 4px;
}

/* Backdrop Overlay */
.header-overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 950;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.header-overlay-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   iOS BOTTOM SHEET MOBILE MENU
   ========================================================================== */

/* Grab Handle */
.mobile-sheet-handle {
  display: none;
}

/* Mobile Contacts Block */
.mobile-contacts-block {
  display: none;
}

/* Mobile Sheet Header */
.mobile-sheet-header {
  display: none;
}

/* Hide on desktop */
.header-mobile-messengers {
  display: none;
}

@media (max-width: 1024px) {
  .menu-toggle {
    display: block;
  }

  .catalog-trigger-btn {
    display: none;
  }

  /* iOS Bottom Sheet Backdrop */
  .header-overlay-backdrop {
    z-index: 1900;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* iOS Bottom Sheet — the nav itself */
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 85vh;
    max-height: 85vh;
    background-color: #ffffff;
    border-radius: 24px 24px 0 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.3s ease,
      visibility 0.3s ease;
    z-index: 2000;
    box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.15),
      0 -2px 20px rgba(0, 0, 0, 0.08);
  }

  .nav.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* Grab Handle at the top of the sheet */
  .mobile-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 4px;
    flex-shrink: 0;
  }

  .mobile-sheet-handle-bar {
    width: 40px;
    height: 5px;
    background-color: rgba(0, 0, 0, 0.12);
    border-radius: 100px;
  }

  /* Scrollable content area inside the sheet */
  .mobile-sheet-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 20px 24px;
  }

  /* Sheet header with title and close button */
  .mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 8px;
  }

  .mobile-sheet-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main, #1d1d1f);
  }

  .mobile-sheet-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-muted, #6e6e73);
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .mobile-sheet-close:hover {
    background: rgba(0, 0, 0, 0.1);
  }

  /* Nav items inside the sheet */
  .nav-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  }

  .nav-item:last-child {
    border-bottom: none;
  }

  .nav-link {
    justify-content: flex-start;
    padding: 15px 15px;
    border-radius: 0;
    font-size: 1.05rem;
    font-weight: 600;
  }

  .nav-link i.ti-chevron-down {
    transition: transform 0.3s ease;
  }

  .nav-item.open-mobile>.nav-link i.ti-chevron-down {
    transform: rotate(180deg);
  }

  /* Submenus reset for mobile accordions */
  .dropdown-menu,
  .mega-menu-wrapper,
  .dropdown-submenu>.dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: rgba(0, 0, 0, 0.015);
    border-radius: 12px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
      padding 0.35s ease;
    display: flex;
    flex-direction: column;
    width: auto;
  }

  /* When active */
  .nav-item.open-mobile>.dropdown-menu,
  .nav-item.open-mobile>.mega-menu-wrapper,
  .dropdown-submenu.open-mobile>.dropdown-menu {
    max-height: 4000px;
    padding: 8px 0 8px 12px;
  }

  .dropdown-item {
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 0.95rem;
  }

  .dropdown-item:active {
    background-color: rgba(var(--color-blue-rgb), 0.08);
  }

  .bento-catalog-grid,
  .mega-menu-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .level2-title {
    margin: 10px 0;
  }

  .level3-title {
    margin-top: 10px;
  }

  .level4-link {
    padding: 10px 0;
  }

  .header-actions #btn-header-order {
    display: none;
  }

  #bento-catalog-menu {
    display: none !important;
  }

  /* Mobile Contacts Block at bottom of the sheet */
  .mobile-contacts-block {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 20px 28px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(to top, rgba(0, 113, 227, 0.02), transparent);
    flex-shrink: 0;
  }

  .mobile-contacts-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mobile-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main, #1d1d1f);
    font-size: 0.92rem;
    font-weight: 500;
    padding: 8px 0;
    transition: color 0.2s ease;
  }

  .mobile-contact-item i {
    font-size: 1.15rem;
    color: var(--color-blue, #0071e3);
    width: 24px;
    text-align: center;
  }

  .mobile-contact-item:active {
    color: var(--color-blue, #0071e3);
  }

  .mobile-socials-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 4px;
  }

  .mobile-social-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted, #6e6e73);
    text-decoration: none;
    transition: all 0.25s ease;
  }

  .mobile-social-btn:active {
    transform: scale(0.92);
  }

  .mobile-social-btn.tg {
    color: #0088cc;
    border-color: rgba(0, 136, 204, 0.15);
  }

  .mobile-social-btn.wa {
    color: #25d366;
    border-color: rgba(37, 211, 102, 0.15);
  }

  .mobile-social-btn.vk {
    color: #4a76a8;
    border-color: rgba(74, 118, 168, 0.15);
  }

  /* Mobile messengers next to logo */
  .header-mobile-messengers {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
  }

  .header-mobile-msg-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .header-mobile-msg-btn:active {
    transform: scale(0.9);
  }

  .header-mobile-msg-btn.tg {
    color: #0088cc;
    background: rgba(0, 136, 204, 0.06);
    border-color: rgba(0, 136, 204, 0.12);
  }

  .header-mobile-msg-btn.wa {
    color: #25d366;
    background: rgba(37, 211, 102, 0.06);
    border-color: rgba(37, 211, 102, 0.12);
  }

  .header-mobile-msg-btn.vk {
    color: #4a76a8;
    background: rgba(74, 118, 168, 0.06);
    border-color: rgba(74, 118, 168, 0.12);
  }
}