/* ============================================
   在线工具箱 - 主样式文件
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-nav: rgba(255, 255, 255, 0.85);
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-light: #1e1b4b;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-nav: rgba(15, 23, 42, 0.9);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* ========== 导航栏 ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.navbar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

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

/* ========== 首页头部 ========== */
.hero {
  padding: 120px 0 60px;
  text-align: center;
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

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

.hero-stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.hero-stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========== 工具卡片网格 ========== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 0 0 80px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

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

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.tool-card-icon.purple { background: #eef2ff; color: #6366f1; }
.tool-card-icon.blue { background: #e0f2fe; color: #0ea5e9; }
.tool-card-icon.green { background: #d1fae5; color: #10b981; }
.tool-card-icon.orange { background: #fed7aa; color: #f97316; }
.tool-card-icon.pink { background: #fce7f3; color: #ec4899; }
.tool-card-icon.teal { background: #ccfbf1; color: #14b8a6; }

[data-theme="dark"] .tool-card-icon.purple { background: #1e1b4b; color: #818cf8; }
[data-theme="dark"] .tool-card-icon.blue { background: #0c4a6e; color: #38bdf8; }
[data-theme="dark"] .tool-card-icon.green { background: #064e3b; color: #34d399; }
[data-theme="dark"] .tool-card-icon.orange { background: #7c2d12; color: #fb923c; }
[data-theme="dark"] .tool-card-icon.pink { background: #831843; color: #f472b6; }
[data-theme="dark"] .tool-card-icon.teal { background: #134e4a; color: #2dd4bf; }

.tool-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.tool-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  margin-top: 12px;
}

/* ========== 工具页面通用 ========== */
.tool-page {
  padding: 100px 0 60px;
  max-width: 900px;
  margin: 0 auto;
}

.tool-header {
  margin-bottom: 32px;
}

.tool-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.tool-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.tool-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  transition: background var(--transition), border-color var(--transition);
}

.tool-body textarea,
.tool-body input[type="text"],
.tool-body select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}

.tool-body textarea:focus,
.tool-body input[type="text"]:focus,
.tool-body select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.tool-body textarea {
  resize: vertical;
  min-height: 200px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  line-height: 1.5;
}

.tool-body label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ========== 输出区域 ========== */
.output-area {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 60px;
  transition: background var(--transition), border-color var(--transition);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.88rem;
  line-height: 1.5;
}

.output-area.has-content {
  border-color: var(--success);
}

.output-stats {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ========== 文件上传 ========== */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.file-upload-area:hover,
.file-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-area .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.file-upload-area p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.file-upload-area .file-name {
  color: var(--primary);
  font-weight: 500;
  margin-top: 8px;
}

.file-upload-area input[type="file"] {
  display: none;
}

/* ========== 预览区域 ========== */
.preview-container {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.preview-box {
  flex: 1;
  min-width: 250px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.preview-box h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-box img,
.preview-box canvas {
  max-width: 100%;
  max-height: 300px;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

.file-info {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ========== Tab 切换 ========== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  font-family: inherit;
}

.tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab:hover:not(.active) {
  color: var(--text);
}

/* ========== 页脚 ========== */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer a { color: var(--text-secondary); }

/* ========== 分割面板 ========== */
.split-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .split-panel {
    grid-template-columns: 1fr;
  }
}

/* ========== 提示 ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .alert-success { background: #064e3b; color: #34d399; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fca5a5; }

/* ========== 搜索栏 ========== */
.search-bar input:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 4px rgba(79,70,229,0.1); }
.category-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.category-btn.active { background: var(--primary) !important; color: #fff !important; }
#searchInput::placeholder { color: var(--text-muted); }

/* ========== 无结果提示 ========== */
#noResults { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .hero { padding: 100px 0 40px; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .tools-grid { grid-template-columns: 1fr; }
  .tool-body { padding: 20px; }
  .tool-page { padding: 80px 16px 40px; }
  .preview-container { flex-direction: column; }
  .hero-stats { gap: 20px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ========== 加载动画 ========== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 图片压缩滑块 ========== */
.range-control {
  display: flex;
  align-items: center;
  gap: 16px;
}

.range-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}

.range-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.range-value {
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
  text-align: right;
}

/* ========== AdSense 广告占位 ========== */
.ad-container {
  text-align: center;
  padding: 16px;
  margin: 24px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== 工具计数标识 ========== */
.tool-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 20px;
}

/* ========== 颜色标签 ========== */
.color-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.color-tag.free { background: #d1fae5; color: #065f46; }
.color-tag.new { background: #e0f2fe; color: #0369a1; }

[data-theme="dark"] .color-tag.free { background: #064e3b; color: #34d399; }
[data-theme="dark"] .color-tag.new { background: #0c4a6e; color: #38bdf8; }

/* ========== 行内代码 ========== */
code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* ========== Diff 样式 ========== */
.diff-added { background: #d1fae5; color: #065f46; }
.diff-removed { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .diff-added { background: #064e3b; color: #34d399; }
[data-theme="dark"] .diff-removed { background: #7f1d1d; color: #fca5a5; }

/* ========== 广告区域说明 ========== */
.ad-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0;
}

/* ========== 复制提示 ========== */
.copy-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
}

/* ========== SEO友好 ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
