/* CSS Variables for Theme */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e8e8e8;
  --text-primary: #222222;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border-color: #e0e0e0;
  /* Tailwind Rose (light): rose-500 / rose-600 */
  --accent-color: #f43f5e;
  --accent-hover: #e11d48;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3d3d3d;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #404040;
  /* Tailwind Rose (dark): rose-400 / rose-500 */
  --accent-color: #fb7185;
  --accent-hover: #f43f5e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
    "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background-color: rgba(var(--bg-secondary-rgb, 245, 245, 245), 0.9);
}

[data-theme="dark"] .header {
  background-color: rgba(var(--bg-secondary-rgb, 45, 45, 45), 0.9);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-link {
  text-decoration: none;
  color: var(--text-primary);
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Search */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 250px;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15);
}

.search-icon {
  position: absolute;
  right: 0.75rem;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  background-color: var(--bg-primary);
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--accent-color);
}

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

/* Language Selector */
.language-select {
  padding: 0.5rem 1.5rem 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.language-select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 0;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin: 2rem 0;
}

.stat-item {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.cta-section {
  text-align: center;
  margin: 3rem 0;
}

.cta-button {
  display: inline-block;
  padding: 1rem 2rem;
  background-color: var(--accent-color);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: var(--transition);
}

.cta-button:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Page Title */
.page-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.search-container {
  margin-bottom: 2rem;
}

/* Categories Grid - 最多4列 */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

/* Category Section - 最大高度800px */
.category-section {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  max-height: 800px;
  min-width: 0;
  transition: box-shadow 100ms ease;
  box-shadow: inset 0 0 0 0 transparent;
}

/* 每个分类区块不同边框颜色 */
.category-section:nth-child(8n + 1) {
  border-color: #4caf50;
}
.category-section:nth-child(8n + 2) {
  border-color: #9c27b0;
}
.category-section:nth-child(8n + 3) {
  border-color: #ff9800;
}
.category-section:nth-child(8n + 4) {
  border-color: #2196f3;
}
.category-section:nth-child(8n + 5) {
  border-color: #e91e63;
}
.category-section:nth-child(8n + 6) {
  border-color: #00bcd4;
}
.category-section:nth-child(8n + 7) {
  border-color: #8bc34a;
}
.category-section:nth-child(8n + 8) {
  border-color: #ff5722;
}

[data-theme="dark"] .category-section:nth-child(8n + 1) {
  border-color: #66bb6a;
}
[data-theme="dark"] .category-section:nth-child(8n + 2) {
  border-color: #ab47bc;
}
[data-theme="dark"] .category-section:nth-child(8n + 3) {
  border-color: #ffa726;
}
[data-theme="dark"] .category-section:nth-child(8n + 4) {
  border-color: #42a5f5;
}
[data-theme="dark"] .category-section:nth-child(8n + 5) {
  border-color: #ec407a;
}
[data-theme="dark"] .category-section:nth-child(8n + 6) {
  border-color: #26c6da;
}
[data-theme="dark"] .category-section:nth-child(8n + 7) {
  border-color: #9ccc65;
}
[data-theme="dark"] .category-section:nth-child(8n + 8) {
  border-color: #ff7043;
}

/* 悬停时边框内侧加粗 */
.category-section:nth-child(8n + 1):hover {
  box-shadow: inset 0 0 0 1px #4caf50;
}
.category-section:nth-child(8n + 2):hover {
  box-shadow: inset 0 0 0 1px #9c27b0;
}
.category-section:nth-child(8n + 3):hover {
  box-shadow: inset 0 0 0 1px #ff9800;
}
.category-section:nth-child(8n + 4):hover {
  box-shadow: inset 0 0 0 1px #2196f3;
}
.category-section:nth-child(8n + 5):hover {
  box-shadow: inset 0 0 0 1px #e91e63;
}
.category-section:nth-child(8n + 6):hover {
  box-shadow: inset 0 0 0 1px #00bcd4;
}
.category-section:nth-child(8n + 7):hover {
  box-shadow: inset 0 0 0 1px #8bc34a;
}
.category-section:nth-child(8n + 8):hover {
  box-shadow: inset 0 0 0 1px #ff5722;
}

[data-theme="dark"] .category-section:nth-child(8n + 1):hover {
  box-shadow: inset 0 0 0 1px #66bb6a;
}
[data-theme="dark"] .category-section:nth-child(8n + 2):hover {
  box-shadow: inset 0 0 0 1px #ab47bc;
}
[data-theme="dark"] .category-section:nth-child(8n + 3):hover {
  box-shadow: inset 0 0 0 1px #ffa726;
}
[data-theme="dark"] .category-section:nth-child(8n + 4):hover {
  box-shadow: inset 0 0 0 1px #42a5f5;
}
[data-theme="dark"] .category-section:nth-child(8n + 5):hover {
  box-shadow: inset 0 0 0 1px #ec407a;
}
[data-theme="dark"] .category-section:nth-child(8n + 6):hover {
  box-shadow: inset 0 0 0 1px #26c6da;
}
[data-theme="dark"] .category-section:nth-child(8n + 7):hover {
  box-shadow: inset 0 0 0 1px #9ccc65;
}
[data-theme="dark"] .category-section:nth-child(8n + 8):hover {
  box-shadow: inset 0 0 0 1px #ff7043;
}

.category-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
  transition: border-bottom-color 100ms ease;
}

.category-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
  flex-shrink: 0;
}

/* 悬停时标题横线颜色与边框一致 */
.category-section:nth-child(8n + 1):hover .category-title {
  border-bottom-color: #4caf50;
}
.category-section:nth-child(8n + 2):hover .category-title {
  border-bottom-color: #9c27b0;
}
.category-section:nth-child(8n + 3):hover .category-title {
  border-bottom-color: #ff9800;
}
.category-section:nth-child(8n + 4):hover .category-title {
  border-bottom-color: #2196f3;
}
.category-section:nth-child(8n + 5):hover .category-title {
  border-bottom-color: #e91e63;
}
.category-section:nth-child(8n + 6):hover .category-title {
  border-bottom-color: #00bcd4;
}
.category-section:nth-child(8n + 7):hover .category-title {
  border-bottom-color: #8bc34a;
}
.category-section:nth-child(8n + 8):hover .category-title {
  border-bottom-color: #ff5722;
}

[data-theme="dark"] .category-section:nth-child(8n + 1):hover .category-title {
  border-bottom-color: #66bb6a;
}
[data-theme="dark"] .category-section:nth-child(8n + 2):hover .category-title {
  border-bottom-color: #ab47bc;
}
[data-theme="dark"] .category-section:nth-child(8n + 3):hover .category-title {
  border-bottom-color: #ffa726;
}
[data-theme="dark"] .category-section:nth-child(8n + 4):hover .category-title {
  border-bottom-color: #42a5f5;
}
[data-theme="dark"] .category-section:nth-child(8n + 5):hover .category-title {
  border-bottom-color: #ec407a;
}
[data-theme="dark"] .category-section:nth-child(8n + 6):hover .category-title {
  border-bottom-color: #26c6da;
}
[data-theme="dark"] .category-section:nth-child(8n + 7):hover .category-title {
  border-bottom-color: #9ccc65;
}
[data-theme="dark"] .category-section:nth-child(8n + 8):hover .category-title {
  border-bottom-color: #ff7043;
}

/* Sites List Wrapper - 内部滚动 */
.sites-list-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #888888 transparent;
}

.sites-list-wrapper::-webkit-scrollbar {
  width: 2px;
}

.sites-list-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.sites-list-wrapper::-webkit-scrollbar-thumb {
  background: #888888;
  border-radius: 2px;
}

[data-theme="dark"] .sites-list-wrapper {
  scrollbar-color: #555555 transparent;
}

[data-theme="dark"] .sites-list-wrapper::-webkit-scrollbar-thumb {
  background: #555555;
}

/* Sites List - 纵向排列 */
.sites-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Site Item - 每行一个 */
.site-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-radius: var(--radius);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}

.site-item:hover {
  background-color: var(--bg-tertiary);
}

/* Site Tooltip (JS controlled) */
.site-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  line-height: 1.4;
  max-width: 300px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  white-space: normal;
}

.site-tooltip.visible {
  opacity: 1;
}

.site-tooltip-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.site-tooltip-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Site Number - 圆角矩形浅色背景 */
.site-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  background-color: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Site Favicon */
.site-favicon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 4px;
}

/* Site Info */
.site-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.site-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-domain {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* No Results */
.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 4rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

/* Responsive */
/* Desktop Large: 4列 (默认 > 1200px) */

/* Desktop: 3列 */
@media (max-width: 1200px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

/* Tablet Landscape: 2列 */
@media (max-width: 992px) {
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .category-section {
    max-height: 700px;
  }
}

/* Tablet Portrait */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    gap: 1rem;
  }

  .header-nav {
    width: 100%;
    justify-content: space-between;
  }

  .search-input {
    width: 100%;
    max-width: 300px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .stats {
    flex-direction: column;
    gap: 1.5rem;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .category-section {
    max-height: 600px;
    padding: 0.875rem;
  }

  .category-title {
    font-size: 1rem;
  }

  .category-description {
    font-size: 0.8rem;
  }
}

/* Mobile Large: 1列 */
@media (max-width: 576px) {
  .container {
    padding: 0 1rem;
  }

  .categories-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .category-section {
    max-height: 500px;
    padding: 0.75rem;
  }

  .site-item {
    padding: 0.375rem;
    gap: 0.5rem;
  }

  .site-number {
    min-width: 1.75rem;
    height: 1.75rem;
    font-size: 0.8rem;
  }

  .site-favicon {
    width: 28px;
    height: 28px;
  }

  .site-name {
    font-size: 0.9rem;
  }

  .site-domain {
    font-size: 0.75rem;
  }

  .hero {
    padding: 2rem 0;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  /* Tooltip 移动端适配 */
  .site-tooltip {
    max-width: calc(100vw - 2rem);
    font-size: 0.75rem;
  }
}

/* Mobile Small */
@media (max-width: 375px) {
  .container {
    padding: 0 0.75rem;
  }

  .categories-grid {
    gap: 0.75rem;
  }

  .category-section {
    max-height: 450px;
    padding: 0.625rem;
  }

  .category-title {
    font-size: 0.95rem;
  }

  .site-item {
    gap: 0.4rem;
  }

  .site-number {
    min-width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
    padding: 0 0.25rem;
  }

  .site-favicon {
    width: 24px;
    height: 24px;
  }

  .site-name {
    font-size: 0.85rem;
  }
}
