/* ==========================================================================
   header.css — 全站公共页头样式（所有页面引入）
   --------------------------------------------------------------------------
   结构：.top-bar 红色信息条 → .main-header 白色logo区+站内搜索
         → .main-nav 红色主导航（含二级下拉）
   依赖：base.css
   ========================================================================== */

/* ------------------------------ 顶部信息条 ------------------------------- */
.top-bar {
  background: linear-gradient(90deg, var(--red-800), var(--red-700));
  color: rgba(255, 255, 255, .92);
  font-size: 13px;
}

.top-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 34px;
}

.top-bar__welcome::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: 2px;
}

.top-bar__extra {
  display: flex;
  align-items: center;
}

.top-bar__extra a {
  color: rgba(255, 255, 255, .85);
  margin-left: 14px;
}

.top-bar__extra a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ------------------------------ logo + 搜索 ------------------------------ */
.main-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
}

.main-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.logo img {
  height: 60px;
  width: auto;
}

/* LOGO 右侧部门名：「| 纪检监察处」 */
.logo__mark {
  font-size: 32px;
  line-height: 1;
  color: #d9d4cf;
}

.logo__dept {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--red-700);
  white-space: nowrap;
}

/* 站内搜索 */
.site-search {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.site-search input {
  width: 220px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid #d9d4cf;
  border-right: none;
  border-radius: 19px 0 0 19px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.site-search input::placeholder {
  color: #b3aea9;
}

.site-search input:focus {
  border-color: var(--red-600);
  box-shadow: 0 0 0 3px rgba(196, 34, 44, .12);
}

.site-search button {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 20px;
  background: var(--red-700);
  color: #fff;
  font-size: 14px;
  border-radius: 0 19px 19px 0;
  transition: background-color .2s ease;
}

.site-search button:hover {
  background: var(--red-600);
}

/* 兼容 CMS 全文检索组件：组件自行生成 <form>（带内联 style="display:inline"）
   包裹 input/button，导致二者不再是 .site-search 的直接子元素、flex 失效换行。
   这里把 form 变成 flex 容器恢复同一行；display 需 !important
   以压过组件注入的内联样式 */
.site-search form {
  display: flex !important;
  align-items: center;
}

/* LOGO 与站内搜索之间的办学理念标语 */
.header-slogan {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 4px;
  white-space: nowrap;
  color: var(--red-700);
}

@media (max-width: 1200px) {
  /* 视口变窄后 LOGO 与搜索盒均为固定宽，剩余空间放不下大号标语，直接隐藏 */
  .header-slogan {
    display: none;
  }
}

/* ------------------------------- 主导航 --------------------------------- */
.main-nav {
  position: relative;
  z-index: 100;
  background: var(--red-700);
  box-shadow: 0 2px 8px rgba(114, 13, 18, .28);
}

.main-nav .container {
  display: flex;
  align-items: center;
}

/* 汉堡按钮（≤768px 显示） */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 46px;
  padding: 12px 11px;
  margin-left: auto;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: #fff;
  transition: transform .25s ease, opacity .2s ease;
}

/* 展开：三线变叉 */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 一级菜单 */
.nav-list {
  flex: 1;
  display: flex;
  justify-content: center;
}

.nav-list > li {
  position: relative;
}

.nav-list > li > a {
  position: relative;
  display: block;
  padding: 0 30px;
  line-height: 48px;
  color: rgba(255, 255, 255, .95);
  font-size: 17px;
  letter-spacing: 2px;
  transition: background-color .2s ease;
}

.nav-list > li > a:hover {
  background: var(--red-800);
  color: #fff;
}

/* 当前所在频道 */
.nav-list > li.current > a {
  background: var(--red-800);
}

.nav-list > li.current > a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--gold);
}

/* 含下拉的父项小箭头 */
.has-sub > a .caret {
  display: inline-block;
  margin-left: 7px;
  border: 4px solid transparent;
  border-top-color: rgba(255, 255, 255, .8);
  vertical-align: 3px;
  transition: transform .2s ease;
}

.has-sub:hover > a .caret,
.has-sub.expand > a .caret {
  transform: rotate(180deg);
}

/* 二级下拉菜单 */
.submenu {
  position: absolute;
  top: 100%;
  left: 50%;
  min-width: 170px;
  background: var(--bg-card);
  border-top: 3px solid var(--gold);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-md);
  transform: translate(-50%, 10px);
  opacity: 0;
  visibility: hidden;
  transition: transform .25s ease, opacity .25s ease, visibility .25s;
  z-index: 120;
}

.submenu li + li {
  border-top: 1px solid var(--red-50);
}

.submenu a {
  display: block;
  padding: 11px 20px;
  font-size: 15px;
  color: var(--ink-900);
  text-align: center;
  transition: background-color .2s ease, color .2s ease;
}

.submenu a:hover {
  background: var(--red-50);
  color: var(--red-700);
}

/* 悬停 / 键盘聚焦 / JS展开 三种方式均可唤起下拉 */
.has-sub:hover > .submenu,
.has-sub:focus-within > .submenu,
.has-sub.expand > .submenu {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ------------------------------ 响应式调整 ------------------------------- */
@media (max-width: 992px) {
  .logo img { height: 52px; }
}

@media (max-width: 768px) {
  .site-search { display: none; }

  /* 窄屏放不下 LOGO 右侧部门名（图片+文字+汉堡按钮会溢出），仅保留图片 */
  .logo__mark,
  .logo__dept { display: none; }

  .main-header .container { padding-top: 12px; padding-bottom: 12px; }

  .nav-toggle { display: flex; }

  /* 导航纵向展开 */
  .nav-list {
    display: none;
    flex-direction: column;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, .15);
  }

  .main-nav.open .nav-list { display: flex; }

  .nav-list > li > a {
    line-height: 44px;
    padding: 0 20px;
    text-align: left;
    font-size: 16px;
    letter-spacing: normal;
  }

  .nav-list > li.current > a::after { display: none; }
  .nav-list > li.current > a {
    border-left: 4px solid var(--gold);
    padding-left: 16px;
  }

  /* 下拉菜单改为点击展开式 */
  .submenu {
    display: none;
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    min-width: 0;
    background: var(--red-800);
    border-top: none;
    border-radius: 0;
    box-shadow: none;
  }

  .has-sub.expand > .submenu { display: block; }

  .submenu li + li { border-top: 1px solid rgba(255, 255, 255, .12); }

  .submenu a {
    color: rgba(255, 255, 255, .85);
    text-align: left;
    padding: 0 20px 0 44px;
    line-height: 42px;
  }

  .submenu a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
  }
}

@media (max-width: 480px) {
  .top-bar { font-size: 12px; }
  .top-bar .container { height: 32px; }
  .top-bar__welcome { display: none; }  /* 窄屏隐藏欢迎语，保留日期与快捷操作 */
  .top-bar__extra a { margin-left: 10px; }
}