/**
 * 工具列表页 v2.0
 * 对标灵图 POD：左侧固定侧栏 + 右侧卡片矩阵
 */

/* ==================== 整体布局 ==================== */
.tools-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* ==================== 左侧导航侧栏 ==================== */
.tools-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.tools-sidebar-section {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.tools-sidebar-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-3) var(--space-3) var(--space-2);
  display: block;
}

.tools-sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--trans-fast);
  margin-bottom: 2px;
  text-decoration: none;
}

.tools-sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.tools-sidebar-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tools-sidebar-item.active .tools-sidebar-icon {
  color: var(--accent);
}

.tools-sidebar-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tools-sidebar-count {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ==================== 右侧主内容区 ==================== */
.tools-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-8) var(--content-pad);
  max-width: calc(var(--content-max) + var(--content-pad) * 2);
}

/* 页面头部 */
.tools-header {
  margin-bottom: var(--space-6);
}

.tools-kicker {
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: var(--font-medium);
  display: block;
  margin-bottom: var(--space-2);
}

.tools-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.tools-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* 搜索栏 */
.tools-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-4);
  height: 40px;
  max-width: 360px;
  margin-bottom: var(--space-6);
  transition: border-color var(--trans-fast);
}

.tools-search:focus-within {
  border-color: var(--accent);
}

.tools-search-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.tools-search input {
  flex: 1;
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

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

/* ==================== 工具卡片网格 ==================== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

/* ==================== 工具卡片 ==================== */
.tool-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--trans-base);
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tool-card:hover .tool-card-cover {
  opacity: 0.9;
}

/* 卡片封面 */
.tool-card-cover {
  height: 140px;
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  transition: opacity var(--trans-base);
  position: relative;
}

.tool-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* SVG 封面：加一层底部渐隐，让卡片标题区衔接自然 */
.tool-card-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 44px;
  background: linear-gradient(to top, rgba(15,15,15,.55), rgba(15,15,15,0));
  pointer-events: none;
}

.tool-card-cover-emoji {
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

/* 卡片内容 */
.tool-card-body {
  padding: var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tool-card-title {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-card-desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: var(--leading-snug);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
}

/* ==================== 徽章 ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1.6;
}

.badge-free {
  background: rgba(85, 209, 135, 0.12);
  color: var(--success);
}

.badge-cost {
  background: rgba(230,57,70, 0.12);
  color: var(--accent);
}

.badge-new {
  background: rgba(56, 189, 248, 0.12);
  color: var(--info);
}

.badge-gold {
  background: rgba(239, 189, 71, 0.12);
  color: var(--gold);
}

/* ==================== 空状态 ==================== */
.tools-empty {
  grid-column: 1 / -1;
  padding: var(--space-20) var(--space-8);
  text-align: center;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-2xl);
}

.tools-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.tools-empty-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* ==================== 响应式 ==================== */
@media (max-width: 1100px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (max-width: 768px) {
  .tools-layout {
    flex-direction: column;
  }

  .tools-sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: var(--header-height);
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--space-2) var(--space-4);
    z-index: var(--z-sticky);
    flex-direction: row;
    display: flex;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .tools-sidebar-label { display: none; }

  .tools-sidebar-section {
    display: flex;
    flex-direction: row;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
  }

  .tools-sidebar-item {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    margin-bottom: 0;
  }

  .tools-sidebar-count { display: none; }

  .tools-main {
    padding: var(--space-6) var(--space-4);
  }

  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .tool-card-cover { height: 120px; font-size: 32px; }
}
