/* 考拉新媒体导航 - 样式表 */
:root {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #a78bfa;
  --bg: #f8f7fc;
  --card-bg: #ffffff;
  --text: #1e1b4b;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --sidebar-bg: #ffffff;
  --header-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 12px;
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  z-index: 30;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.header .search-box {
  display: flex;
  flex: 1;
  max-width: 560px;
  position: relative;
}

.search-box input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 24px 0 0 24px;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  background: var(--bg);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.search-box .search-mode {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 24px 24px 0;
  font-size: 13px;
  background: white;
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
  outline: none;
  transition: var(--transition);
}

.search-box .search-mode:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.stats {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 0;
}

.sidebar .cat-item {
  padding: 0 12px;
}

.sidebar .cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: var(--transition);
  user-select: none;
}

.sidebar .cat-header:hover {
  background: var(--bg);
}

.sidebar .cat-header .arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-secondary);
}

.sidebar .cat-header.expanded .arrow {
  transform: rotate(90deg);
}

.sidebar .cat-badge {
  margin-left: auto;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.sidebar .sub-list {
  display: none;
  padding-left: 24px;
}

.sidebar .sub-list.open {
  display: block;
}

.sidebar .sub-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

.sidebar .sub-item.active {
  background: rgba(124,58,237,0.1);
  color: var(--primary);
  font-weight: 600;
}

.sidebar .all-link {
  padding: 10px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.sidebar .all-link:hover {
  background: rgba(124,58,237,0.05);
}

/* Main content */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.main .category-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.main .category-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* In-category search */
.cat-search {
  margin-bottom: 20px;
}

.cat-search input {
  width: 100%;
  max-width: 400px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  background: white;
}

.cat-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

/* Tool cards */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow);
}

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

.tool-card .card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.tool-card .card-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg);
  flex-shrink: 0;
}

.tool-card .card-logo-fallback {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.tool-card .card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tool-card .card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Search results */
.search-results .search-header {
  margin-bottom: 16px;
}

.search-results .search-header h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.search-results .filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-results .filter-tag {
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.search-results .filter-tag.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.search-results .result-item {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.search-results .result-item:hover {
  box-shadow: var(--shadow-md);
}

.search-results .result-item .result-cat {
  font-size: 11px;
  color: var(--primary);
  background: rgba(124,58,237,0.08);
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 6px;
}

.search-results .result-item .result-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.search-results .result-item .result-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Overview / Show All */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.overview-cat {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.overview-cat h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}

.overview-cat .sub-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.overview-cat .sub-tag {
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.overview-cat .sub-tag:hover {
  background: rgba(124,58,237,0.1);
  color: var(--primary);
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 80px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
  transition: var(--transition);
  z-index: 40;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(124,58,237,0.4);
}

.back-to-top.visible {
  display: flex;
}

/* Footer */
.site-footer {
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 16px;
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Tablet */
@media (max-width: 1023px) {
  .sidebar { width: 220px; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 767px) {
  .menu-toggle { display: block; }

  .header {
    padding: 12px 16px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .header h1 { font-size: 17px; }

  .header .search-box {
    order: 3;
    max-width: 100%;
    width: 100%;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 60;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .main { padding: 16px; }

  .tools-grid { grid-template-columns: 1fr; }
  .overview-grid { grid-template-columns: 1fr; }

  .stats { display: none; }
}
