/* ========================================
   导航栏样式 - 现代简约风格
   作者：胡智鹏
   日期：2025-11-18
   精简版：从 799 行优化到约 300 行
   ======================================== */

/* ========================================
   基础导航栏样式
   ======================================== */

.navbar {
  background-color: rgb(255 255 255);
  border-bottom: 1px solid rgb(224 231 234);
  box-shadow: 0 1px 3px rgba(38, 50, 56, 0.04);
  padding: 0;
  min-height: 60px;
}

/* Force navbar inner container to exact width matching features-container */
.navbar > div {
  box-sizing: border-box !important;
}

.navbar-brand {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: rgb(55 71 79);
  font-weight: 600;
  transition: color 0.2s ease;
}

.navbar-brand:hover {
  color: rgb(84 110 122);
}

.navbar-brand .icon-text {
  font-size: 1.5rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-icon {
  width: 36px;
  height: 36px;
  vertical-align: middle;
}

/* ========================================
   导航链接和下拉菜单
   ======================================== */

.navbar-nav .nav-link {
  color: rgb(96 125 139);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  color: rgb(55 71 79);
  background-color: rgb(245 246 247);
}

.navbar-nav .nav-link.active {
  color: rgb(55 71 79);
  background-color: rgb(236 239 241);
  font-weight: 500;
}

.dropdown-menu {
  background-color: rgb(255 255 255);
  border: 1px solid rgb(224 231 234);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(38, 50, 56, 0.08), 0 2px 8px rgba(38, 50, 56, 0.04);
  padding: 0.5rem 0;
  margin-top: 0.5rem;
}

.dropdown-item {
  color: rgb(96 125 139);
  padding: 0.5rem 1rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  color: rgb(55 71 79);
  background-color: rgb(245 246 247);
}

.dropdown-item.active {
  color: rgb(255 255 255);
  background-color: rgb(84 110 122);
  font-weight: 500;
}

.dropdown-divider {
  border-top: 1px solid rgb(224 231 234);
  margin: 0.5rem 0;
}

/* ========================================
   搜索功能
   ======================================== */

#navbarSearch {
  top: 100%;
  right: 0;
  transition: all 0.2s ease;
  max-height: 0;
  overflow: hidden;
}

#navbarSearch.show {
  max-height: 500px;
}

#searchResults .dropdown-item {
  display: flex;
  align-items: center;
  white-space: nowrap;
  height: 50px;
  overflow: hidden;
}

#searchResults .icon {
  margin-right: 10px;
  width: 24px;
  height: 24px;
}

#searchResults .icon-text {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
}

#search-icon i {
  font-size: 24px;
  transition: color 0.2s ease;
  color: rgb(96 125 139);
}

#search-icon:hover i {
  color: rgb(84 110 122);
}

.search-input {
  border: 1px solid rgb(224 231 234);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: rgb(250 250 250);
}

.search-input:focus {
  border-color: rgb(84 110 122);
  box-shadow: 0 0 0 3px rgba(84, 110, 122, 0.12);
  outline: none;
  background-color: rgb(255 255 255);
}

/* ========================================
   汉堡菜单按钮
   ======================================== */

.navbar-toggler {
  border: 1px solid rgb(224 231 234);
  border-radius: 6px;
  padding: 0.375rem 0.5rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.navbar-toggler:hover {
  border-color: rgb(84 110 122);
  background-color: rgb(245 246 247);
}

.navbar-toggler:focus {
  border-color: rgb(84 110 122);
  box-shadow: 0 0 0 2px rgba(84, 110, 122, 0.12);
  outline: none;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(55, 71, 79, 0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  width: 1.5rem;
  height: 1.5rem;
}

/* ========================================
   响应式设计
   ======================================== */

/* 大屏幕 (桌面) */
@media (min-width: 992px) {
  .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    justify-content: space-between;
  }

  .navbar-expand-lg .navbar-nav {
    flex-direction: row;
    gap: 0.5rem;
  }

  .dropdown-menu {
    position: absolute;
  }
}

/* 中等屏幕 (平板) */
@media (max-width: 991px) {
  .navbar {
    padding: 0.5rem 1rem;
  }

  .navbar-collapse {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgb(238 238 238);
  }

  .navbar-nav {
    gap: 0.25rem;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    background-color: rgb(250 250 250);
    margin-left: 1rem;
  }
}

/* 小屏幕 (手机横屏) */
@media (max-width: 768px) {
  .navbar-brand .icon-text {
    font-size: 1.25rem;
  }

  .main-icon {
    width: 32px;
    height: 32px;
  }

  .navbar-nav .nav-link {
    padding: 0.5rem 0.75rem;
  }
}

/* 超小屏幕 (手机竖屏) */
@media (max-width: 480px) {
  .navbar {
    padding: 0.5rem 0.75rem;
  }

  .navbar-brand .icon-text {
    font-size: 1.1rem;
  }

  .main-icon {
    width: 28px;
    height: 28px;
  }

  .navbar-nav .nav-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.9rem;
  }

  .dropdown-menu {
    font-size: 0.9rem;
  }
}

/* 极小屏幕 (小手机) */
@media (max-width: 360px) {
  .navbar-brand .icon-text {
    font-size: 1rem;
  }

  .main-icon {
    width: 24px;
    height: 24px;
  }
}

/* ========================================
   工具特定样式
   ======================================== */

.icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: middle;
}

.material-symbols-rounded {
  font-size: 24px;
  vertical-align: middle;
  user-select: none;
}

/* ========================================
   暗色模式兼容
   ======================================== */

@media (prefers-color-scheme: dark) {
  /* 如果用户切换到暗色模式，这些样式会自动应用 */
  .navbar {
    background-color: rgb(26 26 26);
    border-bottom-color: rgb(45 45 45);
  }

  .navbar-brand,
  .navbar-nav .nav-link {
    color: rgb(224 224 224);
  }

  .navbar-nav .nav-link:hover {
    color: rgb(255 255 255);
    background-color: rgb(45 45 45);
  }

  .dropdown-menu {
    background-color: rgb(38 38 38);
    border-color: rgb(45 45 45);
  }

  .dropdown-item {
    color: rgb(224 224 224);
  }

  .dropdown-item:hover {
    color: rgb(255 255 255);
    background-color: rgb(45 45 45);
  }
}

/* ========================================
   性能优化
   ======================================== */

/* 减少重绘 */
.navbar,
.navbar-nav,
.dropdown-menu {
  will-change: auto;
}

/* 禁用不必要的动画 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   导航栏广告轮播样式
   ======================================== */

.nav-ad-carousel {
  margin: 0 1rem;
  display: flex;
  align-items: center;
}

.ad-carousel-container {
  width: 120px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: rgb(245 246 247);
  border: 1px solid rgb(224 231 234);
}

.ad-carousel-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.ad-carousel-item {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  cursor: pointer;
  display: block;
}

.ad-carousel-item.active {
  opacity: 1;
  z-index: 1;
}

.ad-carousel-item:hover {
  transform: scale(1.02);
  transition: all 0.3s ease;
}

/* ========================================
   导航栏展开式搜索框样式
   ======================================== */

.nav-search {
  margin: 0 0.5rem;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-toggle-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  color: rgb(96 125 139);
}

.search-toggle-btn:hover {
  background-color: rgb(245 246 247);
  color: rgb(55 71 79);
}

.search-toggle-btn.active {
  background-color: rgb(236 239 241);
  color: rgb(84 110 122);
}

.search-input-wrapper {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  background: rgb(255 255 255);
  border: 1px solid rgb(224 231 234);
  border-radius: 8px;
  margin-right: 0.5rem;
}

.search-input-wrapper.active {
  width: 300px;
  opacity: 1;
}

.nav-search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.5rem 1rem;
  font-size: 14px;
  background: transparent;
  color: rgb(55 71 79);
}

.nav-search-input::placeholder {
  color: rgb(176 190 197);
}

.search-close-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: rgb(176 190 197);
  transition: color 0.2s ease;
}

.search-close-btn:hover {
  color: rgb(96 125 139);
}

.search-close-btn .material-symbols-rounded {
  font-size: 20px;
}

/* ========================================
   响应式优化 - 广告和搜索
   ======================================== */

@media (max-width: 992px) {
  /* 平板：保持广告但缩小搜索框 */
  .search-input-wrapper.active {
    width: 250px;
  }

  .ad-carousel-container {
    width: 100px;
    height: 35px;
  }
}

@media (max-width: 768px) {
  /* 移动端：隐藏广告，缩小搜索框 */
  .nav-ad-carousel {
    display: none !important;
  }

  .search-input-wrapper.active {
    width: 200px;
  }

  .nav-search-input {
    font-size: 13px;
    padding: 0.4rem 0.8rem;
  }
}

@media (max-width: 480px) {
  /* 小屏手机：全宽搜索框 */
  .search-input-wrapper.active {
    position: fixed;
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    top: 70px;
    z-index: 10001;
    box-shadow: 0 4px 12px rgba(38, 50, 56, 0.15);
  }

  .search-toggle-btn.active {
    position: fixed;
    right: 10px;
    top: 70px;
    z-index: 10002;
    background: rgb(255 255 255);
    box-shadow: 0 2px 8px rgba(38, 50, 56, 0.1);
  }
}

/* ========================================
   Top Ad Banner - Modern Design
   ======================================== */

.top-ad-banner {
  background: linear-gradient(135deg, rgb(84 110 122) 0%, rgb(96 125 139) 100%);
  color: rgb(255 255 255);
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(38, 50, 56, 0.08);
  animation: slideDown 0.3s ease-out;
  position: relative;
  z-index: 10001;
}

.top-ad-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ad-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.ad-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.ad-image {
  height: 32px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  border-radius: 4px;
}

.ad-link {
  color: rgb(255 255 255);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.ad-link:hover {
  opacity: 0.9;
  text-decoration: underline;
  color: rgb(255 255 255);
}

.ad-text {
  line-height: 1.4;
}

.ad-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-close-btn:hover {
  color: rgb(255 255 255);
  background: rgba(255, 255, 255, 0.15);
}

.ad-close-btn .material-symbols-rounded {
  font-size: 1.25rem;
}

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

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

/* Mobile responsive */
@media (max-width: 768px) {
  .top-ad-banner {
    padding: 0.625rem 1rem;
  }

  .ad-message {
    gap: 0.5rem;
  }

  .ad-icon {
    font-size: 1.1rem;
  }

  .ad-text {
    font-size: 0.8rem;
  }

  .ad-close-btn {
    padding: 0.125rem;
  }
}

@media (max-width: 480px) {
  .ad-text {
    font-size: 0.75rem;
    line-height: 1.3;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .top-ad-banner {
    animation: none !important;
  }

  .ad-link {
    transition: none !important;
  }
}
