/* 
 * Merged & Optimized CSS
 * Combines light and dark themes with responsive design
 */

:root {
  /* Light theme (default) */
  --primary-color: #4a6cf7;
  --text-color: #333;
  --bg-color: #f5f7ff;
  --card-bg: #fff;
  --border-color: rgba(0, 0, 0, 0.05);
  --shadow-color: rgba(0, 0, 0, 0.05);
  --text-secondary: #666;
  --accent-color: #3955d0;
  --success-color: #4caf50;
  --error-color: #f44336;

  /* Layout variables */
  --sidebar-width: 230px;
  --sidebar-mobile-width: 80%;
  --transition-speed: 0.3s;
}

/* Dark theme class - can be toggled */
.dark-theme {
  --primary-color: #00bcd4;
  --text-color: #ffffff;
  --bg-color: #1a1a1a;
  --card-bg: #2d2d2d;
  --border-color: #404040;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --text-secondary: #b0b0b0;
  --accent-color: #00e5ff;
  --success-color: #00e676;
  --error-color: #ff1744;
}

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

body {
  font-family: 'Segoe UI', 'Roboto', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--card-bg);
  box-shadow: 0 0 15px var(--shadow-color);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-speed);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.logo {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.site-logo {
  max-width: 80%;
  height: auto;
  max-height: 45px;
  display: block;
  margin: 0 auto 0.5rem;
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--primary-color);
}

/* Stats section */
.stats {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat-item {
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.2s;
}

.stat-item:hover {
  transform: translateY(-2px);
  background-color: rgba(255, 255, 255, 0.08);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

/* Navigation links */
.navigation {
  margin-top: 0.75rem;
}

.nav-title {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

/* 导航链接文本居中的样式 */
.nav-link {
  display: flex;
  align-items: center;
  justify-content: center; /* 使文本居中 */
  text-align: center; /* 文本居中对齐 */
  padding: 0.625rem 0.875rem;
  text-decoration: none;
  color: var(--text-color);
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 调整图标和文本间距，确保居中布局看起来更美观 */
.nav-icon {
  margin-right: 8px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow-color);
}

.nav-link:active {
  transform: translateY(1px);
}

.nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  font-weight: 500;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: currentColor;
  border-radius: 0 3px 3px 0;
}

/* Themed nav links */
.nav-link.nav-home { color: #64b5f6; }
.nav-link.nav-api { color: #2eccc6; }
.nav-link.nav-docs { color: #ba68c8; }
.nav-link.nav-github { color: #f48fb1; }
.nav-link.nav-tutorial { color: #81c784; }
.nav-link.nav-faq { color: #ffb74d; }

.nav-link.featured {
  position: relative;
  z-index: 1;
  color: #ffffff;
}

.nav-link.featured::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  border-radius: 10px;
  z-index: -1;
  width: auto;
}

.nav-link.featured::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  background: var(--bg-color);
  border-radius: 7px;
  z-index: -1;
}

.nav-link.featured.active::after {
  background: rgba(33, 33, 33, 0.8);
}

.nav-link.featured.active::before {
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Main content area */
.main-content {
  flex: 1;
  padding: 1.5rem;
  margin-left: var(--sidebar-width);
  transition: margin var(--transition-speed);
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.content-header h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 500;
}

.page-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.card-item {
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 6px var(--shadow-color);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

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

.card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 12px var(--shadow-color);
}

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

.card-content {
  font-size: 1.125rem;
  text-align: center;
  word-break: break-all;
}

.card-item.masked .card-content {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--primary-color);
  padding: 0.5rem;
  border-radius: 6px;
}

.mask-text {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  font-size: 0.875rem;
}

.card-meta {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.pagination a {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 35px;
  height: 35px;
  text-decoration: none;
  color: var(--text-color);
  background-color: var(--card-bg);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.pagination a.active {
  background-color: var(--primary-color);
  color: white;
}

.pagination a:hover:not(.active) {
  background-color: rgba(255, 255, 255, 0.1);
}

.page-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.page-ellipsis {
  padding: 0 0.3rem;
  color: var(--text-secondary);
  min-width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 998;
}

.verify-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  width: 90%;
  max-width: 400px;
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px var(--shadow-color);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  margin: -0.5rem;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 1.5rem;
  text-align: center;
}

#captchaText {
  font-size: 2.5rem;
  font-family: monospace;
  text-align: center;
  letter-spacing: 8px;
  margin: 1.25rem 0;
  padding: 1.25rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  user-select: none;
  color: var(--primary-color);
}

#captchaInput {
  width: 100%;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1.25rem;
  text-align: center;
  letter-spacing: 4px;
  margin: 1rem 0;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

#captchaInput:focus {
  outline: none;
  border-color: var(--primary-color);
}

.hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.verify-btn {
  width: 100%;
  padding: 0.875rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.verify-btn:hover {
  background-color: var(--accent-color);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--card-bg);
  color: var(--text-color);
  padding: 0.875rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-color);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 200;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--shadow-color);
  padding: 0;
  justify-content: center;
  align-items: center;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  fill: white;
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--card-bg);
  color: var(--text-color);
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--shadow-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 90;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  transform: rotate(30deg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Responsive styles */
@media screen and (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }
  
  .main-content {
    margin-left: 220px;
    padding: 1.25rem;
  }
  
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media screen and (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-mobile-width);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 1.25rem;
  }
  
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }
  
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
  }
  
  .card-item {
    padding: 1rem;
  }
  
  .pagination a,
  .page-ellipsis {
    min-width: 32px;
    height: 32px;
  }
  
  /* 主题切换按钮在移动端的样式调整 */
  .theme-toggle {
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    /* 确保在移动端上，主题切换按钮不会被其他元素覆盖 */
    z-index: 101;
  }
  
  /* 当侧边栏激活时，确保主题切换按钮仍然可见 */
  .sidebar.active + .main-content .theme-toggle {
    right: 15px; /* 保持在右侧可见 */
  }
}

@media screen and (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
  
  .nav-link {
    padding: 8px;
    font-size: 0.9rem;
  }
  
  .stat-item {
    height: 65px;
    padding: 0.75rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .modal-body {
    padding: 1.25rem;
  }
  
  #captchaText {
    font-size: 2rem;
    padding: 1rem;
    letter-spacing: 4px;
  }
  
  /* 极小屏幕的进一步调整 */
  .theme-toggle {
    width: 35px;
    height: 35px;
    bottom: 10px;
    right: 10px;
  }
  
  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }
}

@media screen and (max-width: 320px) {
  .sidebar {
    width: 85%;
    padding: 1rem 0.75rem;
  }
  
  .verify-modal {
    width: 95%;
  }
  
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }
}