/* ============================================
   header.css - 头部导航
   顶部栏 / 主导航 / 下拉菜单 / 粘性头部 / 移动端菜单
   ============================================ */

/* ============================================
   头部容器
   ============================================ */
.site-header {
  position: relative;
  width: 100%;
  z-index: var(--z-header);
  background: var(--bg-header);
}

/* ============================================
   顶部信息栏
   ============================================ */
.header-topbar {
  background: var(--gradient-header);
  color: var(--white);
  font-size: var(--font-size-sm);
  line-height: var(--header-top-height);
  height: var(--header-top-height);
}

.header-topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.header-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.header-topbar__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: rgba(255, 255, 255, 0.9);
  transition: color var(--transition-base);
}

.header-topbar__item:hover {
  color: var(--white);
}

.header-topbar__item i {
  font-size: var(--font-size-base);
}

.header-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-topbar__link {
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-xs);
  transition: color var(--transition-base);
}

.header-topbar__link:hover {
  color: var(--white);
}

.header-topbar__separator {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   主导航栏
   ============================================ */
.header-main {
  height: var(--header-height);
  background: var(--bg-header);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base), height var(--transition-base);
}

.header-main .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* ---- Logo ---- */
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  text-decoration: none;
}

.header-logo__img {
  height: 48px;
  width: auto;
}

.header-logo__text {
  display: flex;
  flex-direction: column;
}

.header-logo__name {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--primary-blue);
  line-height: 1.2;
  white-space: nowrap;
}

.header-logo__slogan {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ---- 导航链接 ---- */
.header-nav {
  display: flex;
  align-items: center;
  height: 100%;
}

.header-nav__list {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
}

.header-nav__item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.header-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  padding: 0 var(--space-5);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  transition: color var(--transition-base);
  position: relative;
  white-space: nowrap;
}

.header-nav__link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--gradient-primary);
  border-radius: var(--radius-pill) var(--radius-pill) 0 0;
  transition: width var(--transition-base);
}

.header-nav__link:hover,
.header-nav__item.active .header-nav__link {
  color: var(--primary-blue);
}

.header-nav__link:hover::after,
.header-nav__item.active .header-nav__link::after {
  width: 70%;
}

.header-nav__link .arrow {
  font-size: 10px;
  transition: transform var(--transition-base);
  margin-left: 2px;
}

.header-nav__item:hover .header-nav__link .arrow {
  transform: rotate(180deg);
}

/* ---- 下拉菜单 ---- */
.header-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: var(--bg-white);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  padding: var(--space-3) 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(8px);
  transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
  z-index: var(--z-dropdown);
  border-top: 3px solid transparent;
  border-image: var(--gradient-primary) 1;
}

.header-nav__item:hover .header-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.header-dropdown__item {
  display: block;
}

.header-dropdown__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  white-space: nowrap;
}

.header-dropdown__link:hover {
  color: var(--primary-blue);
  background: rgba(0, 119, 182, 0.04);
  padding-left: calc(var(--space-5) + 4px);
}

.header-dropdown__link i {
  font-size: var(--font-size-lg);
  color: var(--primary-cyan);
  width: 20px;
  text-align: center;
}

/* 大型下拉 (科室导航等) */
.header-dropdown--mega {
  min-width: 480px;
  padding: var(--space-5);
}

.header-dropdown--mega .mega-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.header-dropdown--mega .mega-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-base);
}

.header-dropdown--mega .mega-item:hover {
  background: rgba(0, 119, 182, 0.04);
}

.header-dropdown--mega .mega-item__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(0, 119, 182, 0.08), rgba(0, 204, 153, 0.08));
  flex-shrink: 0;
}

.header-dropdown--mega .mega-item__icon i {
  font-size: var(--font-size-lg);
  color: var(--primary-blue);
}

.header-dropdown--mega .mega-item__text {
  flex: 1;
}

.header-dropdown--mega .mega-item__name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.header-dropdown--mega .mega-item__desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ---- 右侧操作区 ---- */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.header-search-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  background: none;
  border: none;
}

.header-search-btn:hover {
  background: var(--gray-100);
  color: var(--primary-blue);
}

.header-appointment-btn {
  padding: 8px 20px;
  background: var(--color-appointment);
  color: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.25);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.header-appointment-btn:hover {
  background: var(--color-appointment-hover);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.35);
  transform: translateY(-1px);
}

.header-appointment-btn i {
  font-size: var(--font-size-base);
}

/* ============================================
   粘性头部 (.header-sticky)
   ============================================ */
.site-header.header-sticky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  animation: slideDown 0.3s ease;
}

.site-header.header-sticky .header-topbar {
  display: none;
}

.site-header.header-sticky .header-main {
  height: 64px;
  box-shadow: var(--shadow-header);
}

.site-header.header-sticky .header-logo__img {
  height: 40px;
}

.site-header.header-sticky .header-logo__name {
  font-size: var(--font-size-xl);
}

.site-header.header-sticky .header-logo__slogan {
  display: none;
}

/* 占位元素 (防止粘性头部导致页面跳动) */
.header-placeholder {
  height: var(--header-total-height);
}

.header-placeholder.sticky-active {
  height: var(--header-total-height);
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   移动端汉堡菜单
   ============================================ */
.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-2);
  z-index: calc(var(--z-header) + 10);
}

.hamburger__line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-base);
}

/* 打开状态 X */
.hamburger.active .hamburger__line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active .hamburger__line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger.active .hamburger__line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   移动端导航面板
   ============================================ */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-mask);
  z-index: calc(var(--z-header) - 1);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.mobile-nav-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100vh;
  background: var(--bg-white);
  z-index: var(--z-header);
  box-shadow: var(--shadow-sidebar);
  transition: right var(--transition-base);
  overflow-y: auto;
  padding-top: 60px;
}

.mobile-nav.active {
  right: 0;
}

.mobile-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color-light);
}

.mobile-nav__list {
  padding: var(--space-3) 0;
}

.mobile-nav__item {
  border-bottom: 1px solid var(--border-color-light);
}

.mobile-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.mobile-nav__link:hover,
.mobile-nav__item.active .mobile-nav__link {
  color: var(--primary-blue);
  background: rgba(0, 119, 182, 0.04);
}

.mobile-nav__link .arrow {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.mobile-nav__item.open .mobile-nav__link .arrow {
  transform: rotate(90deg);
}

/* 移动端子菜单 */
.mobile-nav__sub {
  display: none;
  background: var(--gray-50);
  padding: var(--space-2) 0;
}

.mobile-nav__item.open .mobile-nav__sub {
  display: block;
}

.mobile-nav__sub-link {
  display: block;
  padding: var(--space-3) var(--space-5) var(--space-3) var(--space-10);
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  transition: all var(--transition-base);
}

.mobile-nav__sub-link:hover {
  color: var(--primary-blue);
  padding-left: calc(var(--space-10) + 4px);
}

/* 移动端导航底部操作 */
.mobile-nav__footer {
  padding: var(--space-5);
  border-top: 1px solid var(--border-color-light);
  margin-top: var(--space-3);
}

.mobile-nav__phone {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--primary-blue);
  margin-bottom: var(--space-4);
}

.mobile-nav__appointment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: var(--color-appointment);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--transition-base);
}

.mobile-nav__appointment-btn:hover {
  background: var(--color-appointment-hover);
}

/* ============================================
   头部搜索栏
   ============================================ */
.header-search {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-white);
  z-index: calc(var(--z-header) + 5);
  padding: var(--space-6) 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.header-search.active {
  transform: translateY(0);
  opacity: 1;
}

.header-search .container {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-search__input {
  flex: 1;
  padding: 14px 20px;
  font-size: var(--font-size-xl);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-pill);
  transition: border-color var(--transition-base);
  background: none;
}

.header-search__input:focus {
  outline: none;
  border-color: var(--primary-cyan);
}

.header-search__close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-size-xl);
  color: var(--text-muted);
  background: none;
  border: none;
  transition: background-color var(--transition-base);
}

.header-search__close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}
