/* CSS变量定义 */
:root {
  /* 浅色主题 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* 深色主题 */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-primary: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: #1e3a8a;
  --border-color: #374151;
}

/* 基础样式重置 */
* {
  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-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.3s ease;
}

/* 导航栏 */
.navbar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

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

.theme-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.theme-btn:hover {
  background: var(--bg-tertiary);
}

.login-btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.3s;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.username {
  font-weight: 500;
}

.dropdown {
  position: relative;
}

.dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-secondary);
}

.dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  min-width: 120px;
  z-index: 1000;
  display: none;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.3s;
}

.dropdown-content a:hover {
  background: var(--bg-tertiary);
}

/* 主要内容区域 */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Hero区域 */
.hero {
  text-align: center;
  margin-bottom: 3rem;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  background: var(--gradient-primary);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

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

/* 搜索容器 */
.search-container {
  max-width: 600px;
  margin: 0 auto;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.search-btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.3s;
}

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

.search-options {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}



.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

/* 通用section样式 */
section {
  background: var(--bg-primary);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

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

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.clear-btn, .sync-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background-color 0.3s;
}

.sync-btn {
  background: var(--accent-primary);
}

.clear-btn:hover {
  background: #dc2626;
}

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

/* 搜索历史 */
.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-item {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid var(--border-color);
}

.history-item:hover {
  background: var(--accent-primary);
  color: white;
  transform: translateY(-1px);
}

/* 搜索结果 */
.search-info {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.result-item {
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.result-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.result-image {
  width: 100%;
  height: 120px;
  background: var(--bg-tertiary);
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.result-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--accent-primary);
}

.result-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.3s;
}

.visit-btn {
  background: var(--accent-primary);
  color: white;
}

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

.favorite-btn {
  background: #f59e0b;
  color: white;
}

.favorite-btn:hover {
  background: #d97706;
}

.favorite-btn.favorited {
  background: #10b981;
}

/* 收藏夹 */
.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.favorite-item {
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  transition: all 0.3s;
  position: relative;
}

.favorite-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.favorite-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.favorite-url {
  font-size: 0.875rem;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 1rem;
}

.favorite-actions {
  display: flex;
  gap: 0.5rem;
}

.remove-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background-color 0.3s;
}

.remove-btn:hover {
  background: #dc2626;
}

/* 站点导航 */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.site-category h3 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent-primary);
  padding-bottom: 0.5rem;
}

.site-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.site-item {
  display: block;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  transition: all 0.3s;
}

.site-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-primary);
}

.site-info strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--accent-primary);
}

.site-info span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: 1rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.3s;
}

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

.form-group {
  margin-bottom: 1rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.submit-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.3s;
}

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

/* === 添加按钮禁用样式在这里 === */
.submit-btn.submitting {
  opacity: 0.7;
  cursor: not-allowed;
}

.form-links {
  text-align: center;
  margin-top: 1rem;
}

.form-links a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.3s;
}

.form-links a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Toast通知 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--accent-primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  z-index: 1001;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: #ef4444;
}

.toast.success {
  background: #10b981;
}

/* Loading动画 */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1002;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-tertiary);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 动画 */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translate(-50%, -60%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
  }
  
  .nav-brand .brand-text {
    display: none;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .search-box {
    flex-direction: column;
  }
  
  .search-options {
    flex-direction: column;
    gap: 1rem;
  }
  
  .results-grid, .favorites-grid {
    grid-template-columns: 1fr;
  }
  
  .sites-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.75rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .section-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .history-list {
    justify-content: center;
  }
}