/* ============================================================
   AI在线工具站 - 全局样式
   设计原则: 简洁、响应式、广告友好
   ============================================================ */

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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

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

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

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header .logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .logo span { font-size: 28px; }

.header nav a {
  margin-left: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.header nav a:hover { color: var(--primary); text-decoration: none; }

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

/* ============================================================
   Hero Section (首页)
   ============================================================ */
.hero {
  text-align: center;
  padding: 60px 20px 40px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

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

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

.tool-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
  display: block;
  color: var(--text);
}

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

.tool-card .tool-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

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

.tool-card p {
  font-size: 14px;
  color: var(--text-secondary);
}

.tool-card .tool-badge {
  display: inline-block;
  background: #ede9fe;
  color: var(--primary);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 10px;
}

/* ============================================================
   Ad Container (广告位)
   ============================================================ */
.ad-container {
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin: 20px 0;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ad-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: var(--radius);
  text-align: center;
  margin: 16px 0;
}

/* ============================================================
   Tool Page Layout
   ============================================================ */
.tool-page {
  padding: 30px 0;
}

.tool-page .tool-header {
  text-align: center;
  margin-bottom: 30px;
}

.tool-page .tool-header h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.tool-page .tool-header p {
  color: var(--text-secondary);
}

.tool-main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

@media (max-width: 768px) {
  .tool-main { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
}

/* ============================================================
   Tool Form / Input Area
   ============================================================ */
.tool-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.tool-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.tool-form input[type="text"],
.tool-form input[type="file"],
.tool-form textarea,
.tool-form select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.tool-form input:focus,
.tool-form textarea:focus,
.tool-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.tool-form textarea {
  min-height: 120px;
  resize: vertical;
}

.btn {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ============================================================
   Result Area
   ============================================================ */
.result-area {
  margin-top: 20px;
  padding: 16px;
  background: #f0fdf4;
  border-radius: var(--radius);
  border: 1px solid #bbf7d0;
  display: none;
  word-break: break-all;
}

.result-area.show { display: block; }

.result-area pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
}

/* ============================================================
   Sidebar (广告位 + 相关工具)
   ============================================================ */
.sidebar .ad-container {
  margin: 0 0 20px;
  min-height: 250px;
  position: sticky;
  top: 80px;
}

.sidebar .related-tools {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.sidebar .related-tools h4 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.sidebar .related-tools a {
  display: block;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
}
.sidebar .related-tools a:hover { color: var(--primary); text-decoration: none; }

/* ============================================================
   Upload Zone (拖拽上传)
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: #eef2ff;
}

.upload-zone .upload-icon { font-size: 48px; margin-bottom: 10px; }
.upload-zone p { color: var(--text-secondary); font-size: 14px; }

.preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 16px;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

.loading-overlay {
  display: none;
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
}
.loading-overlay.show { display: block; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ============================================================
   Toast / Notification
   ============================================================ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  z-index: 9999;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error { background: #ef4444; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   404 Page
   ============================================================ */
.error-page {
  text-align: center;
  padding: 100px 20px;
}
.error-page h1 { font-size: 72px; color: var(--border); margin-bottom: 16px; }
.error-page p { color: var(--text-secondary); margin-bottom: 24px; }

/* ============================================================
   Naming tool cards
   ============================================================ */
.name-card {
  display: inline-block;
  background: #eef2ff;
  color: var(--primary);
  padding: 8px 16px;
  border-radius: 20px;
  margin: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.name-card:hover { background: var(--primary); color: white; transform: scale(1.05); }

.name-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

/* ============================================================
   Mic Button (语音工具)
   ============================================================ */
.mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: white;
  font-size: 36px;
  cursor: pointer;
  transition: all 0.3s;
  margin: 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-btn:hover { transform: scale(1.1); }
.mic-btn.recording {
  background: #ef4444;
  border-color: #ef4444;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
}