/* CSS 自定义属性 */
:root {
  /* 主色调 */
  --primary-color: #5B6AFF;
  --secondary-color: #8C54FF;
  --accent-color: #667EEA;
  
  /* 浅色主题 */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F5F7FA;
  --bg-card: #FFFFFF;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #E5E7EB;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* 深色主题 */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1F2937;
  --bg-card: #374151;
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-muted: #9CA3AF;
  --border-color: #4B5563;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 顶部导航栏 */
.header {
  height: 60px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-content {
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.mobile-menu-btn:hover {
  background-color: var(--bg-secondary);
}

.hamburger {
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  transition: all 0.3s ease;
}

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

.mobile-menu-btn.active .hamburger:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active .hamburger:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 14px;
}

.logo-text {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-primary);
}

/* 搜索框 */
.search-container {
  flex: 1;
  max-width: 500px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 12px 12px 12px 44px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(91, 106, 255, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* 主题切换按钮 */
.theme-toggle {
  width: 40px;
  height: 40px;
  background-color: var(--bg-secondary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.theme-toggle:hover {
  background-color: var(--border-color);
  transform: scale(1.05);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.sun-icon {
  display: block;
}

.moon-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: block;
}

/* 主容器 */
.main-container {
  display: flex;
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

/* 侧边栏 */
.sidebar {
  width: 240px;
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  left: 0;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  transition: all 0.3s ease;
  z-index: 900;
}

.sidebar-content {
  padding: 24px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* 分类导航 */
.category-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.category-item:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.category-item.active {
  background-color: rgba(91, 106, 255, 0.1);
  color: var(--primary-color);
  border-left: 4px solid var(--primary-color);
}

.category-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-icon {
  width: 20px;
  height: 20px;
}

.category-count {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.category-item.active .category-count {
  background-color: rgba(91, 106, 255, 0.2);
  color: var(--primary-color);
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  padding-bottom: 72px;
  transition: margin-left 0.3s ease;
}

.content-header {
  margin-bottom: 24px;
}

.content-title {
  font-size: 28px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.content-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* 工具网格 */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding-bottom: 0px;
}

/* 工具卡片 */
.tool-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-color);
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tool-card:hover::before {
  opacity: 1;
}

/* 卡片头部 */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  font-size: 32px;
  line-height: 1;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  transition: color 0.3s ease;
}

.tool-card:hover .card-title {
  color: var(--primary-color);
}

.card-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.star-icon {
  width: 12px;
  height: 12px;
  fill: #FCD34D;
  color: #FCD34D;
}

.featured-badge {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* 卡片描述 */
.card-description {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 标签 */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tag {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag-icon {
  width: 10px;
  height: 10px;
}

.tag-more {
  color: var(--text-muted);
  font-size: 12px;
}

/* 卡片底部 */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.pricing-badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.pricing-free {
  background-color: rgba(34, 197, 94, 0.1);
  color: #059669;
}

.pricing-freemium {
  background-color: rgba(59, 130, 246, 0.1);
  color: #2563EB;
}

.pricing-paid {
  background-color: rgba(249, 115, 22, 0.1);
  color: #EA580C;
}

[data-theme="dark"] .pricing-free {
  background-color: rgba(34, 197, 94, 0.2);
  color: #10B981;
}

[data-theme="dark"] .pricing-freemium {
  background-color: rgba(59, 130, 246, 0.2);
  color: #3B82F6;
}

[data-theme="dark"] .pricing-paid {
  background-color: rgba(249, 115, 22, 0.2);
  color: #F97316;
}

.card-action {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary-color);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tool-card:hover .card-action {
  color: var(--secondary-color);
}

.action-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.tool-card:hover .action-icon {
  transform: translateX(2px);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-description {
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* 移动端遮罩层 */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 800;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  
  .logo-text {
    display: none;
  }
  
  .search-container {
    max-width: none;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-overlay.show {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .tool-card {
    padding: 20px;
  }
  
  .content-title {
    font-size: 24px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (min-width: 1025px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (min-width: 1400px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

/* 桌面端，假设 footer 高度约 48px */
.main-content {
    padding-bottom: 72px; /* 适当大于 footer 高度 */
}

/* 移动端适配，假设 footer 高度略大或更紧凑 */
@media (max-width: 600px) {
    .main-content {
        padding-bottom: 72px; /* 适当调整，保证内容不被遮挡且不太近 */
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card {
  animation: fadeIn 0.3s ease-out;
}

/* 加载动画 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

.like-btn {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 0 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.like-btn:hover, .like-btn.liked {
  color: var(--primary-color);
  background: rgba(91, 106, 255, 0.08);
}
.like-icon {
  font-size: 16px;
}
.like-count {
  font-size: 13px;
}

.card-likes {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-placeholder {
  height: 40px;
  width: 100%;
  pointer-events: none;
}