/**
 * 山西诚又诚律师事务所 - 头部导航样式
 * ===========================================
 * 作用：头部导航、登录模态框、移动端抽屉菜单样式
 * 引用：所有页面通过 header.php 引入
 * 依赖：需要先引用 style.css（使用其中的 CSS 变量）
 */

/* ==================== 头部导航样式 ==================== */

/* 统一头部样式 - 透明渐变 */
.header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0) 100%);
  transition: all 0.4s ease;
}

/* 滚动后的悬浮头部（黑色半透明） */
.header.is-scrolled {
  position: fixed;
  background: rgba(0, 0, 0, 0.6);
  padding-top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* 内部布局 */
.header-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  gap: 100px;
  transition: height 0.4s ease;
}

.header.is-scrolled .header-inner {
  height: 70px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
}

.logo img {
  height: 60px;
  transition: height 0.4s ease;
  object-fit: contain;
}

.header.is-scrolled .logo img {
  height: 46px;
}

/* 导航菜单 */
.nav-menu {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

.nav-menu .btn-login {
  margin-left: 30px;
}

.nav-menu a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  font-weight: 500;
  padding: 8px 16px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--font-sans);
  position: relative;
}

.nav-menu a:hover {
  color: #fff;
  transform: scale(1.05);
}

.nav-menu a.active {
  color: #fff;
}

/* 下划线滑动效果 */
.nav-menu a::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateX(-50%);
}

.nav-menu a:hover::after,
.nav-menu a.active::after {
  width: 60%;
}

.nav-menu a.active::after {
  background: linear-gradient(90deg, transparent, var(--primary-400), transparent);
}

/* 登录按钮 - 胶囊样式 */
.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-600);
  color: #fff !important;
  padding: 6px 20px !important;
  border-radius: 50px;
  font-weight: 500;
  font-size: 16px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(172, 30, 100, 0.3);
  border: 1px solid var(--primary-600);
  cursor: pointer;
}

.btn-login:hover {
  background: #fff;
  color: var(--primary-600) !important;
  border-color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.btn-login:hover i {
  color: var(--primary-600);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(172, 30, 100, 0.3);
}

.btn-login i {
  font-size: 13px;
  color: #fff;
  transition: color 0.2s ease;
}

/* ===========================================
   登录模态框样式 - 大厂风格
   =========================================== */
.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s ease;
  overflow-y: auto;
}

.login-modal.active {
  opacity: 1;
  visibility: visible;
}

.login-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  transition: backdrop-filter 0.4s ease;
}

.login-modal-content {
  position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 20px;
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 420px;
  margin: 20px;
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.25),
    0 10px 30px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: scale(0.95) translateY(30px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-modal.active .login-modal-content {
  transform: scale(1) translateY(0);
}

.login-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: rotate(90deg);
}

.login-modal-close i {
  font-size: 20px;
  color: #999;
  transition: color 0.3s ease;
}

.login-modal-close:hover i {
  color: #666;
}

/* Logo 区域 */
.login-modal-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-modal-brand .brand-subtitle {
  font-size: 16px;
  color: var(--primary-600);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.login-modal-brand h2 {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-modal-brand .brand-welcome {
  font-size: 14px;
  color: #888;
  font-weight: 400;
}

/* 表单样式 */
.login-form .form-group {
  margin-bottom: 24px;
}

.login-form label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.login-form .input-wrap {
  position: relative;
}

.login-form .input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  font-size: 16px;
  transition: color 0.3s ease;
}

.login-form input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  font-size: 15px;
  background: #fff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #333;
}

.login-form input::placeholder {
  color: #bbb;
}

.login-form input:hover {
  border-color: #d0d0d0;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary-600);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(172, 30, 100, 0.08);
}

.login-form input:focus + .input-icon,
.login-form .input-wrap:focus-within .input-icon {
  color: var(--primary-600);
}

/* 登录按钮 */
.login-submit-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-500) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(172, 30, 100, 0.3);
  position: relative;
  overflow: hidden;
}

.login-submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.login-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(172, 30, 100, 0.4);
}

.login-submit-btn:hover::before {
  left: 100%;
}

.login-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(172, 30, 100, 0.3);
}

/* 底部链接 */
.login-modal-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.login-modal-footer a {
  color: #888;
  font-size: 13px;
  text-decoration: none;
  transition: color 0.3s ease;
}

.login-modal-footer a:hover {
  color: var(--primary-600);
}

/* 移动端切换按钮 - 汉堡菜单 */
.mobile-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: all 0.3s ease;
  border: none;
}

.mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.mobile-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* 移动端菜单遮罩 */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  display: block;
  opacity: 1;
}

/* 移动端抽屉菜单 */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(84vw, 340px);
  height: 100dvh;
  background: linear-gradient(180deg, rgba(17, 17, 17, 0.98) 0%, rgba(74, 13, 43, 0.96) 100%);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 20px calc(28px + env(safe-area-inset-bottom, 0px));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
  box-shadow: -14px 0 42px rgba(0, 0, 0, 0.38);
  transform: translateX(105%);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.mobile-menu.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* 菜单头部 */
.mobile-menu-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-title {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

.mobile-menu-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.mobile-menu-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* 菜单项 */
.mobile-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}

.mobile-menu a {
  color: rgba(255, 255, 255, 0.85);
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu a::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.mobile-menu a:hover,
.mobile-menu a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.mobile-menu a:hover::before,
.mobile-menu a.active::before {
  background: var(--primary-400);
  transform: scale(1.5);
}

/* 登录按钮 */
.mobile-menu .btn-login {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
  color: #fff !important;
  padding: 15px 20px !important;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  justify-content: center;
  margin-top: auto;
  box-shadow: 0 4px 15px rgba(172, 30, 100, 0.4);
  border: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-menu .btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(172, 30, 100, 0.5);
}

.mobile-menu .btn-login::before {
  display: none;
}

/* 响应式适配 */
@media (max-width: 1024px) {
  .header-inner {
    padding: 0 30px;
  }
}

@media (max-width: 768px) {
  .header {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0));
  }
  .header.is-scrolled {
    background: rgba(17, 17, 17, 0.82);
  }
  .nav-menu {
    display: none;
  }
  .mobile-toggle {
    display: flex;
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }
  .header-inner {
    height: 76px;
    justify-content: space-between;
    padding: 0 18px;
    gap: 16px;
  }
  .header.is-scrolled .header-inner {
    height: 64px;
  }
  .logo img {
    height: 44px;
  }
  .header.is-scrolled .logo img {
    height: 38px;
  }
  .login-modal {
    align-items: flex-end;
  }
  .login-modal-content {
    max-width: none;
    width: calc(100% - 24px);
    margin: 12px;
    padding: 40px 24px 28px;
    border-radius: 18px;
  }
}

@media (max-width: 420px) {
  .mobile-menu {
    width: min(88vw, 330px);
  }
  .header-inner {
    padding: 0 16px;
  }
  .logo img {
    height: 40px;
  }
  .mobile-toggle {
    width: 40px;
    height: 40px;
  }
  .mobile-toggle span {
    width: 22px;
  }
}
