/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #3b82f6;
  --secondary-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --text-color: #1f2937;
  --border-color: #e5e7eb;
  --hover-bg: #f3f4f6;
}

body.dark-mode {
  --card-bg: #374151;
  --input-bg: #4b5563;
  --text-color: #f3f4f6;
  --border-color: #4b5563;
  --hover-bg: #4b5563;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #f3f4f6;
  color: #1f2937;
  transition: background-color 0.3s, color 0.3s;
}

/* 暗黑模式 */
body.dark-mode {
  background-color: #1f2937;
  color: #f3f4f6;
}

/* 主容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 通用按钮样式 */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background-color: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background-color: #2563eb;
}

.btn-secondary {
  background-color: #10b981;
  color: white;
}

.btn-secondary:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* 工具卡片样式 */
.tool-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

body.dark-mode .tool-card {
  background-color: #374151;
  border-color: var(--border-color);
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body.dark-mode .tool-card:hover {
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
}

.tool-card h3 {
  margin-bottom: 0.5rem;
  color: #3b82f6;
  font-size: 1.125rem;
}

.tool-card p {
  color: #6b7280;
  font-size: 0.875rem;
  line-height: 1.5;
}

body.dark-mode .tool-card p {
  color: #9ca3af;
}

/* 顶部导航栏 */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

body.dark-mode .navbar {
  border-color: var(--border-color);
}

.navbar-brand {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #3b82f6;
  text-decoration: none;
}

.navbar-brand svg {
  margin-right: 0.5rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

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

/* 搜索框 */
.search-box {
  position: relative;
}

.search-box input {
  padding: 0.5rem 1rem 0.5rem 2rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  width: 200px;
  transition: all 0.3s ease;
  background-color: var(--input-bg);
  color: var(--text-color);
}

.search-box input:focus {
  outline: none;
  border-color: #3b82f6;
  width: 250px;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-box svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

/* 分类标题 */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  color: #1f2937;
}

body.dark-mode .section-title {
  color: #f3f4f6;
}

/* 工具网格 */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* 最近使用工具 */
.recent-tools {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.recent-tool-card {
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  min-width: 150px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

body.dark-mode .recent-tool-card {
  background-color: #374151;
  border-color: var(--border-color);
}

.recent-tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.recent-tool-card h4 {
  margin-bottom: 0.25rem;
  color: #3b82f6;
  font-size: 0.875rem;
}

.recent-tool-card p {
  color: #6b7280;
  font-size: 0.75rem;
}

body.dark-mode .recent-tool-card p {
  color: #9ca3af;
}

/* 无结果提示 */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #6b7280;
}

body.dark-mode .no-results {
  color: #9ca3af;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 1rem;
  }
  
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .search-box input {
    width: 150px;
  }
  
  .search-box input:focus {
    width: 180px;
  }
  
  .recent-tools {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }
  
  .container {
    padding: 0 0.5rem;
  }
  
  .section-title {
    font-size: 1.25rem;
  }
}

/* 模态框样式 */
.modal {
  display: block;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 0;
  border-radius: 0.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: modalopen 0.3s;
}

body.dark-mode .modal-content {
  background-color: #374151;
}

@keyframes modalopen {
  from {opacity: 0; transform: translateY(-60px);}
  to {opacity: 1; transform: translateY(0);}
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dark-mode .modal-header {
  border-color: #4b5563;
}

.modal-header h2 {
  margin: 0;
  color: #1f2937;
}

body.dark-mode .modal-header h2 {
  color: #f3f4f6;
}

.close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: #000;
}

body.dark-mode .close {
  color: #9ca3af;
}

body.dark-mode .close:hover,
body.dark-mode .close:focus {
  color: #f3f4f6;
}

.modal-body {
  padding: 1.5rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #1f2937;
}

body.dark-mode .form-group label {
  color: #f3f4f6;
}

.form-group input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
}

body.dark-mode .form-group input {
  background-color: #4b5563;
  border-color: #6b7280;
  color: white;
}

.form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-help {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

body.dark-mode .form-help {
  color: #9ca3af;
}

.message {
  padding: 0.75rem;
  border-radius: 0.375rem;
  margin-top: 1rem;
  text-align: center;
}

.message.success {
  background-color: #d1fae5;
  color: #065f46;
}

body.dark-mode .message.success {
  background-color: #065f46;
  color: #d1fae5;
}

.message.error {
  background-color: #fee2e2;
  color: #991b1b;
}

body.dark-mode .message.error {
  background-color: #991b1b;
  color: #fee2e2;
}

/* 验证码容器 */
.captcha-group .captcha-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.captcha-code {
  padding: 0.5rem;
  background-color: #e5e7eb;
  border-radius: 0.375rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 0.2rem;
  user-select: none;
}

body.dark-mode .captcha-code {
  background-color: #4b5563;
  color: white;
}

/* 登录/注册页面 */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.login-form {
  background: white;
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

body.dark-mode .login-form {
  background-color: #374151;
}

.login-form h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #1f2937;
}

body.dark-mode .login-form h2 {
  color: #f3f4f6;
}

.login-form .form-group p {
  text-align: center;
  margin: 1rem 0;
}

.login-form .form-group a {
  color: #3b82f6;
  text-decoration: none;
}

.login-form .form-group a:hover {
  text-decoration: underline;
}

/* 个人中心页面 */
.dashboard-container {
  padding: 2rem 0;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #1f2937;
}

body.dark-mode .dashboard-header h1 {
  color: #f3f4f6;
}

.dashboard-header p {
  color: #6b7280;
}

body.dark-mode .dashboard-header p {
  color: #9ca3af;
}

.user-info {
  background: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

body.dark-mode .user-info {
  background-color: #374151;
}

.user-info h2 {
  margin-bottom: 1rem;
  color: #1f2937;
}

body.dark-mode .user-info h2 {
  color: #f3f4f6;
}

.user-info-item {
  display: flex;
  margin-bottom: 0.5rem;
}

.user-info-label {
  font-weight: 500;
  width: 100px;
  color: #1f2937;
}

body.dark-mode .user-info-label {
  color: #f3f4f6;
}

.saved-content {
  background: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.dark-mode .saved-content {
  background-color: #374151;
}

.saved-content h2 {
  margin-bottom: 1rem;
  color: #1f2937;
}

body.dark-mode .saved-content h2 {
  color: #f3f4f6;
}

.content-item {
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

body.dark-mode .content-item {
  background-color: #4b5563;
}

.content-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.content-item-title {
  font-weight: 500;
  color: #1f2937;
}

body.dark-mode .content-item-title {
  color: #f3f4f6;
}

.content-item-date {
  font-size: 0.875rem;
  color: #6b7280;
}

body.dark-mode .content-item-date {
  color: #9ca3af;
}

.content-item-content {
  font-size: 0.875rem;
  color: #6b7280;
  white-space: pre-wrap;
  word-break: break-word;
}

body.dark-mode .content-item-content {
  color: #9ca3af;
}

.no-content {
  text-align: center;
  color: #6b7280;
  padding: 1rem;
}

body.dark-mode .no-content {
  color: #9ca3af;
}

/* 底部 */
.footer {
  text-align: center;
  padding: 2rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  color: #6b7280;
}

body.dark-mode .footer {
  border-color: var(--border-color);
  color: #9ca3af;
}

.footer a {
  color: #3b82f6;
  text-decoration: none;
}

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

.footer .stats {
  margin-bottom: 1rem;
}

.footer strong {
  color: #1f2937;
}

body.dark-mode .footer strong {
  color: #f3f4f6;
}