/* ========================================
   全局导航栏样式
   配合 js/components/navbar.js 使用
   ======================================== */

.navbar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 1rem;
}

/* 左侧 Logo */
.navbar-left {
  flex: 1;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 600;
  font-size: 1rem;
  transition: opacity var(--transition-fast, 150ms ease);
}

.navbar-logo:hover {
  opacity: 0.8;
}

.navbar-logo i {
  font-size: 1.1rem;
}

/* 右侧区域：搜索框 + 按钮 */
.navbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 搜索框 */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md, 8px);
  transition: all var(--transition-fast, 150ms ease);
  width: 300px;
  position: relative;
}

.search-box:focus-within {
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.search-box i {
  color: var(--color-gray-400);
  font-size: 0.875rem;
}

.search-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0.4rem 0 !important;
  font-size: 0.875rem !important;
  color: var(--color-gray-700);
  width: 100%;
  min-width: 0;
  font-family: inherit;
  line-height: 1.4;
  height: auto;
  border-radius: 0;
}

.search-input::placeholder {
  color: var(--color-gray-400);
}

.search-hint {
  font-size: 0.7rem;
  color: var(--color-gray-400);
  background: var(--color-gray-100);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* 按钮组 */
.navbar-btns {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.navbar-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-gray-200);
  background: var(--color-white);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast, 150ms ease);
  font-size: 0.9rem;
  color: var(--color-gray-600);
  text-decoration: none;
  position: relative;
}

.navbar-btn:hover {
  background: var(--color-gray-50);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.navbar-btn i {
  font-size: 0.9rem;
}

/* 汉堡菜单按钮 */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-gray-600);
  border-radius: 1px;
  transition: all var(--transition-fast, 150ms ease);
}

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

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

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

/* 搜索下拉 — 紧贴搜索框下方 */
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

/* 历史下拉 */
.history-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 240px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

/* 主题下拉 */
#themeDropdownContainer {
  position: relative;
}

#themeToggle {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
}

#themeToggle i {
  font-size: 0.9rem;
}

.theme-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 140px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast, 150ms ease);
  border-bottom: 1px solid var(--color-gray-100);
}

.theme-option:last-child {
  border-bottom: none;
}

.theme-option:hover {
  background: var(--color-gray-50);
}

.theme-option span {
  flex: 1;
  font-size: 0.875rem;
  color: var(--color-gray-700);
}

.theme-option .fa-check {
  font-size: 0.875rem;
  color: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition-fast, 150ms ease);
}

.theme-option.selected .fa-check {
  opacity: 1;
}

.search-results,
.history-list {
  display: flex;
  flex-direction: column;
}

.search-item,
.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast, 150ms ease);
  border-bottom: 1px solid var(--color-gray-100);
  text-decoration: none;
  color: inherit;
}

.search-item:last-child,
.history-item:last-child {
  border-bottom: none;
}

.search-item:hover,
.history-item:hover {
  background: var(--color-gray-50);
}

.search-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.search-item-info {
  flex: 1;
  min-width: 0;
}

.search-title {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-desc {
  font-size: 0.75rem;
  color: var(--color-gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-header {
  padding: 0.625rem 1rem;
  font-weight: 500;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--color-gray-200);
  background: var(--color-gray-50);
  color: var(--color-gray-500);
}

.history-item {
  font-size: 0.85rem;
  color: var(--color-gray-700);
  text-decoration: none;
}

.history-item small {
  color: var(--color-gray-400);
  margin-left: auto;
  font-size: 0.7rem;
  white-space: nowrap;
}

.history-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-time {
  flex-shrink: 0;
}

.history-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-gray-400);
  font-size: 0.85rem;
}

/* 移动端菜单 */
.mobile-menu {
  display: none;
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  box-shadow: var(--shadow-md);
  z-index: 200;
  padding: 0.5rem 0;
}

.mobile-menu.active {
  display: block;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--color-gray-700);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background var(--transition-fast, 150ms ease);
}

.mobile-menu-item:hover {
  background: var(--color-gray-50);
}

.mobile-menu-item i {
  width: 1.25rem;
  text-align: center;
  color: var(--color-gray-400);
}

/* 响应式 */
@media (max-width: 768px) {
  .navbar-container {
    height: 50px;
    padding: 0 0.75rem;
  }

  .search-box {
    flex: 1;
    width: auto;
  }

  .search-hint {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .navbar-btns .navbar-btn:not(.hamburger) {
    display: none;
  }

  .search-dropdown {
    width: calc(100vw - 1.5rem);
    max-width: none;
  }

  .history-dropdown {
    right: 0;
  }
}
