/* Modern Scoped Header Styling */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--header-height) + 38px); /* Height includes top bar */
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

/* Top Header Utility Bar */
.top-header {
  height: 38px;
  background-color: var(--primary-purple);
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--font-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
  overflow: hidden;
  opacity: 1;
}

.top-nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.top-left i, .top-right i {
  color: var(--accent-teal);
  margin-right: 4px;
}

.top-divider {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.75rem;
}

.top-header a {
  color: rgba(255, 255, 255, 0.88);
  transition: var(--transition-fast);
}

.top-header a:hover {
  color: var(--accent-teal);
}

/* Header state on scroll (managed by JS) */
.site-header.header-shrink {
  height: var(--header-shrink-height);
  background-color: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-sm);
}

.site-header.header-shrink .top-header {
  height: 0;
  opacity: 0;
  border-bottom-color: transparent;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  width: 100%;
}

/* Brand Identity (Logo & Text) */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  z-index: 1001;
}

.logo-wrapper {
  height: 46px;
  width: auto; /* Allow horizontal banner to expand */
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 2px 8px;
  box-shadow: 0 4px 10px rgba(94, 18, 94, 0.06);
  border: 1px solid rgba(94, 18, 94, 0.1);
  transition: var(--transition-smooth);
}

.brand-logo:hover .logo-wrapper {
  transform: scale(1.03);
  border-color: var(--accent-teal);
}

.logo-img {
  height: 100%;
  width: auto;
  max-width: 220px; /* Limit banner width */
  object-fit: contain;
}

.logo-svg {
  width: 38px;
  height: 38px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.doctor-name {
  font-family: var(--font-primary);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-purple);
  line-height: 1.15;
  letter-spacing: -0.2px;
  transition: var(--transition-fast);
}

.doctor-title {
  font-family: var(--font-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--secondary-blue);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 1px;
}

.brand-logo:hover .doctor-name {
  color: var(--secondary-blue);
}

/* Navigation Links (Desktop) */
.nav-menu {
  height: 100%;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 100%;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-link {
  font-family: var(--font-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  padding: 0.5rem 0.2rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-arrow {
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  color: var(--text-light);
}

/* Hover & Active States */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 24px; /* Align with navbar border */
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-purple);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.86, 0, 0.07, 1);
}

.site-header.header-shrink .nav-link::after {
  bottom: 18px;
}

.nav-link:hover {
  color: var(--primary-purple);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav-link.active {
  color: var(--primary-purple);
  font-weight: 600;
}

/* Dropdown Menu styling */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.6rem 0;
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1100;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.25s;
}

.dropdown-menu-wide {
  min-width: 320px;
}

.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background-color: var(--bg-white);
  border-left: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.dropdown-menu li {
  position: relative;
}

.dropdown-menu a {
  display: block;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
}

.dropdown-menu a:hover {
  background-color: var(--primary-purple-light);
  color: var(--primary-purple);
  padding-left: 1.5rem;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color-light);
  margin: 0.4rem 0;
}

/* Specific Services Dropdown with Submenus */
.dropdown-menu-services {
  min-width: 250px;
}

.dropdown-menu .has-submenu {
  position: relative;
}

.dropdown-menu .has-submenu > a.submenu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dropdown-menu .menu-icon {
  margin-right: 6px;
  color: var(--accent-teal);
  font-size: 0.9rem;
}

.dropdown-menu .submenu-label {
  display: inline-flex;
  align-items: center;
}

.dropdown-menu .submenu-arrow {
  font-size: 0.7rem;
  color: var(--text-light);
  transition: transform 0.25s ease, color 0.25s ease;
}

.dropdown-menu .has-submenu:hover > a.submenu-toggle {
  background-color: var(--primary-purple-light);
  color: var(--primary-purple);
}

.dropdown-menu .has-submenu:hover .submenu-arrow {
  color: var(--primary-purple);
  transform: translateX(3px);
}

/* Flyout Level 2 Nested Dropdown */
.dropdown-menu .nested-dropdown {
  position: absolute;
  top: -8px;
  left: 100%;
  margin-left: 6px;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(12, 21, 39, 0.16);
  padding: 0.5rem 0;
  min-width: 280px;
  max-height: 480px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1200;
  transform: translateX(8px);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.25s;
}

/* Custom sleek scrollbar for long treatment list */
.dropdown-menu .nested-dropdown::-webkit-scrollbar {
  width: 5px;
}
.dropdown-menu .nested-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.dropdown-menu .nested-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--primary-purple);
}

.dropdown-menu .has-submenu:hover > .nested-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.dropdown-menu .nested-dropdown a {
  padding: 0.5rem 1.25rem;
  font-size: 0.86rem;
  white-space: nowrap;
}

.dropdown-menu .view-all-sub {
  font-weight: 700 !important;
  color: var(--primary-purple) !important;
}

.dropdown-menu .view-all-main {
  font-weight: 700 !important;
  color: var(--secondary-blue) !important;
}

/* Trigger dropdowns on Hover */
.nav-item.dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.nav-item.dropdown:hover .nav-arrow {
  transform: rotate(180deg);
  color: var(--primary-purple);
}

/* Action Group */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.phone-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--secondary-blue);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.phone-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--secondary-blue-light);
  transition: var(--transition-smooth);
}

.phone-link:hover {
  color: var(--primary-purple);
}

.phone-link:hover .phone-icon-wrapper {
  background-color: var(--primary-purple-light);
  color: var(--primary-purple);
  transform: scale(1.05);
}

/* Button Book */
.btn-book {
  background-color: var(--secondary-blue);
  color: var(--bg-white);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-primary);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(35, 82, 147, 0.18);
  border: 1.5px solid transparent;
}

.btn-book:hover {
  background-color: var(--primary-purple);
  color: var(--bg-white);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(94, 18, 94, 0.25);
}

/* Mobile Toggle Hamburger */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  z-index: 1002;
  transition: var(--transition-fast);
}

.mobile-toggle:active {
  background-color: var(--primary-purple-light);
}

.mobile-toggle .bar {
  width: 24px;
  height: 2.4px;
  background-color: var(--primary-purple);
  border-radius: var(--radius-pill);
  transition: var(--transition-smooth);
}

/* Mobile responsive drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(94, 18, 94, 0.25);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-smooth);
}

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

.mobile-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: min(340px, 88vw);
  height: 100%;
  background-color: var(--bg-white);
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

.mobile-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.drawer-logo .doctor-name {
  font-size: 1.15rem;
}

.drawer-logo .doctor-title {
  font-size: 0.65rem;
  display: block;
}

.drawer-close {
  font-size: 1.35rem;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--bg-light);
  transition: var(--transition-fast);
}

.drawer-close:hover {
  color: var(--primary-purple);
  background-color: var(--primary-purple-light);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.drawer-list > li {
  margin-bottom: 0.75rem;
}

.drawer-link {
  display: block;
  padding: 0.65rem 0;
  font-family: var(--font-primary);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color-light);
}

.drawer-link.active {
  color: var(--primary-purple);
  border-bottom-color: var(--primary-purple);
}

/* Mobile Accordion Groups */
.drawer-group {
  border-bottom: 1px solid var(--border-color-light);
}

.drawer-group-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  font-family: var(--font-primary);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
}

.drawer-group-trigger i {
  font-size: 0.75rem;
  transition: transform 0.25s ease;
  color: var(--text-light);
}

.drawer-group.active .drawer-group-trigger i {
  transform: rotate(180deg);
  color: var(--primary-purple);
}

.drawer-sublist {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding-left: 0.75rem;
  padding-right: 0.5rem;
  background-color: var(--bg-light);
  border-radius: var(--radius-sm);
}

.drawer-group.active .drawer-sublist {
  max-height: 3200px; /* Fully accommodate nested sublists without clipping */
  padding-top: 0.6rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.6rem;
}

.drawer-sublist a {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.5rem;
  font-family: var(--font-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  min-height: 42px;
}

.drawer-sublist a:hover {
  color: var(--primary-purple);
}

/* Mobile Drawer Nested Subgroups (Spine Treatments & Brain Treatments) */
.drawer-subgroup {
  margin-bottom: 0.5rem;
}

.drawer-subgroup-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  background-color: var(--bg-white);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}

.drawer-subgroup-trigger i.fa-bone,
.drawer-subgroup-trigger i.fa-brain {
  margin-right: 8px;
  color: var(--accent-teal);
  font-size: 1rem;
}

.drawer-subgroup-trigger .sub-arrow {
  font-size: 0.75rem;
  transition: transform 0.25s ease;
  color: var(--text-muted);
}

.drawer-subgroup.active .drawer-subgroup-trigger {
  background-color: var(--primary-purple-light);
  color: var(--primary-purple);
  border-color: rgba(94, 18, 94, 0.3);
}

.drawer-subgroup.active .drawer-subgroup-trigger .sub-arrow {
  transform: rotate(180deg);
  color: var(--primary-purple);
}

.drawer-nested-sublist {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding-left: 0.5rem;
  padding-right: 0.25rem;
  list-style: none;
}

.drawer-subgroup.active .drawer-nested-sublist {
  max-height: 1800px;
  padding-top: 0.4rem;
  padding-bottom: 0.6rem;
}

.drawer-nested-sublist a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-secondary);
  font-size: 0.88rem;
  color: var(--text-main);
  border-radius: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  min-height: 42px;
}

.drawer-nested-sublist a:active,
.drawer-nested-sublist a:hover {
  color: var(--primary-purple);
  background-color: rgba(94, 18, 94, 0.08);
  padding-left: 0.95rem;
}

.drawer-nested-sublist a.active {
  color: var(--primary-purple);
  background-color: var(--primary-purple-light);
  font-weight: 700;
}

.drawer-nested-sublist a:hover {
  color: var(--primary-purple);
  background-color: rgba(94, 18, 94, 0.05);
  padding-left: 0.75rem;
}

.drawer-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drawer-contact-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.drawer-phone, .drawer-email {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--secondary-blue);
  padding: 0.6rem 0;
  background-color: var(--secondary-blue-light);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.drawer-email {
  color: var(--primary-purple);
  background-color: var(--primary-purple-light);
}

.drawer-phone:hover, .drawer-email:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.drawer-btn-book {
  display: block;
  text-align: center;
  background-color: var(--primary-purple);
  color: var(--bg-white);
  padding: 0.8rem 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-primary);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(94, 18, 94, 0.15);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .nav-menu,
  .top-header,
  .nav-actions .phone-link,
  .nav-actions .btn-book {
    display: none;
  }
  
  .mobile-toggle {
    display: flex;
  }

  /* Since top header is hidden, adjust height calculation */
  .site-header {
    height: var(--header-height);
  }
}

@media (max-width: 480px) {
  .logo-wrapper {
    height: 38px;
    padding: 2px 6px;
  }
  .logo-img {
    max-width: 170px;
  }
  .doctor-name {
    font-size: 1.05rem;
  }
  .doctor-title {
    display: none;
  }
  .nav-container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}
