/* 基础变量 */
:root {
  --bg-color: #f7f8fa;
  --text-color: #333;
  --muted-text: #7a7f85;
  --primary-color: #4a90e2;
  --card-bg: #fff;
  --border-color: #e6e8eb;
  --mars-green: #0fa47f; /* 马尔斯绿 */
}

html, body {
  height: 100%;
}
body {
  background: var(--bg-color);
  color: var(--text-color);
}

/* 布局 */
.layout {
  min-height: calc(100vh - 56px);
}

/* 修复：顶部导航栏 */
.top-header {
  background: var(--mars-green);
  color: #fff;
  padding: 0 20px;
  height: 56px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
}

.logo i {
  margin-right: 8px;
  font-size: 20px;
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-box input {
  border: none;
  border-radius: 20px;
  padding: 8px 44px 8px 14px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  transition: all 0.3s ease;
}

.search-box input:focus {
  background: rgba(255,255,255,0.2);
  outline: none;
  box-shadow: 0 0 8px rgba(255,255,255,0.12);
}

.search-box .search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  padding: 6px 10px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.search-box .search-btn:hover {
  background: rgba(255,255,255,0.28);
  border-color: rgba(255,255,255,0.7);
}

.search-box .search-btn i {
  font-size: 18px;
  line-height: 1;
}

/* 修复：导航菜单 */
.nav-menu {
  display: flex;
  gap: 5px;
}

.nav-menu-item {
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.nav-menu-item:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
  text-decoration: none;
}

.nav-menu-item i {
  font-size: 16px;
}

/* 修复：用户区域 */
.user-area {
  display: flex;
  align-items: center;
}

.user-info .dropdown-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 20px;
  padding: 6px 12px;
}

.user-info .dropdown-toggle:hover {
  background: rgba(255,255,255,0.2);
}

.user-info .dropdown-menu {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  left: auto;
  right: 0;
}

.user-info .dropdown-item {
  color: var(--text-color);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.user-info .dropdown-item:hover {
  background: var(--primary-color);
  color: #fff;
}

.user-info .dropdown-item i {
  font-size: 14px;
}

.sidebar {
  width: 240px;
  background: var(--mars-green);
  color: #fff;
  min-height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
}
.sidebar .layui-nav {
  background: transparent;
}
.sidebar .layui-nav .layui-nav-item a {
  color: #eaf7f2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .layui-nav .layui-nav-item a cite {
  color: #eaf7f2;
}
.sidebar .layui-nav .layui-nav-item.layui-this > a,
.sidebar .layui-nav .layui-nav-item a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.content-area {
  background: transparent;
}

/* 顶部标题与工具栏 */
.top-header {
  background: var(--mars-green);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.top-header .header-left { display: flex; align-items: center; gap: 10px; }
.top-header .header-center { flex: 1; display: flex; justify-content: center; }
.top-header .header-right { display: flex; align-items: center; gap: 10px; }
.top-header .navbar-brand,
.top-header .nav-link,
.top-header a { color: #fff; }

.top-header .search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 800px;
}
.top-header .search-box input#searchInput {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.2);
  color: #fff;
  padding: 0 14px;
}
.top-header .search-box input#searchInput::placeholder {
  color: rgba(255,255,255,0.95);
}
.top-header .search-box #searchBtn.layui-btn-primary {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.25);
  color: #fff;
  padding: 0 12px;
}
.top-header .search-box #searchBtn.layui-btn-primary:hover { background: rgba(255,255,255,0.33); }

/* 登录注册按钮（右上角） */
.top-header #authLinks .auth-link.btn {
  border-color: rgba(255,255,255,0.6);
  color: #fff !important;
}
.top-header #authLinks .auth-link.btn span,
.top-header #authLinks .auth-link.btn i { color: #fff !important; }
.top-header #authLinks .auth-link.btn:hover {
  border-color: #fff;
  background: rgba(255,255,255,0.18);
}

/* 空状态 */
.empty-state {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  color: var(--muted-text);
}
.empty-state .empty-icon {
  font-size: 28px;
  color: #9aa4af;
  margin-bottom: 8px;
}

/* 加载样式 */
.loading {
  color: var(--muted-text);
}

/* 分类卡片 */
.category-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}
.category-card .category-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f0f3f7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.category-card .category-name {
  font-weight: 600;
}
.category-card .category-count {
  color: var(--muted-text);
  font-size: 13px;
}

/* 工具卡片 */
.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 14px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}
.tool-card .tool-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tool-card .tool-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
}
.tool-card .tool-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tool-card .tool-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tool-card .tool-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-card .tool-name .tool-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
.tool-card .tool-name .tool-link:hover {
  color: var(--primary-color);
}
.tool-card .tool-category {
  color: var(--muted-text);
  font-size: 12px;
}
.tool-card .tool-description {
  color: #4b4f56;
  font-size: 14px;
  line-height: 1.5;
  min-height: 40px;
}
.tool-card .tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-card .tool-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tool-card .tool-tag {
  background: #eef3ff;
  color: #3b6fd8;
  border: 1px solid #d9e5ff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}
.tool-card .tool-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool-card .tool-action {
  color: var(--muted-text);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tool-card .tool-action.favorite.favorited {
  color: #f5a623;
}

/* 分页 */
.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
.pagination .page-link {
  color: var(--primary-color);
}
.pagination .page-item.active .page-link {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

/* 表单与筛选 */
.form-select, .form-control {
  background: var(--card-bg);
}

/* 顶部头部与头像下拉 */
.top-header .header-user-btn,
.top-header .header-user-btn:focus {
  background-color: rgba(255,255,255,0.18);
  color: #fff !important;
  border: none;
  box-shadow: none;
  padding: 6px 12px;
  border-radius: 20px;
}
.top-header .header-user-btn:hover {
  background-color: rgba(255,255,255,0.28);
  color: #fff !important;
}
.top-header .dropdown-menu { min-width: 160px; }
.top-header .dropdown-menu .dropdown-item { color: #333 !important; }
.top-header .dropdown-menu .dropdown-item:hover { background: #f5f7fa; color: #111 !important; }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 8px;
  background-color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.35) inset;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* 响应式：小屏侧栏折叠 */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 220px;
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1030;
  }
  .sidebar.active { transform: translateX(0); }
}
