/* ===== 公共样式：主题变量、基础布局、通用组件 ===== */

/* ===== 引入 MiSans 字体 ===== */
@font-face {
  font-family: 'MiSans';
  src: url('../assets/fonts/MiSans-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'MiSans';
  src: url('../assets/fonts/MiSans-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* ===== 亮色主题变量（默认） ===== */
:root {
  --bg-body: #f5f7fb;
  --bg-container: #ffffff;
  --text-primary: #1a2634;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --shadow: 0 8px 20px rgba(0,0,0,0.06);
  --radius: 12px;
  --font: 'MiSans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --primary: #2a7de1;
  --primary-light: #e8f0fe;
  --primary-dark: #1a5bbf;
  --success: #28a745;
  --error: #dc3545;
  --gray: #6c757d;
  --input-bg: #ffffff;
  --input-border: #dee2e6;
  --input-focus-shadow: rgba(42, 125, 225, 0.15);
  --message-bg: #f8f9fa;
  --message-border: #dee2e6;
  --result-bg: #f8f9fa;
  --code-bg: #ffffff;
  --tab-bg: #f1f3f5;
  --tab-active-bg: #ffffff;
  --tab-text: #495057;
  --tab-active-text: #2a7de1;
}

/* ===== 暗色主题 ===== */
[data-theme="dark"] {
  --bg-body: #1a1a2e;
  --bg-container: #16213e;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #8a8a8a;
  --border: #2d3a5e;
  --shadow: 0 8px 20px rgba(0,0,0,0.4);
  --primary: #4a9eff;
  --primary-light: #1e3a5f;
  --primary-dark: #1a5bbf;
  --success: #2d8f47;
  --error: #c0392b;
  --gray: #8a8a8a;
  --input-bg: #1e2a4a;
  --input-border: #3a4a6e;
  --input-focus-shadow: rgba(74, 158, 255, 0.25);
  --message-bg: #1e2a4a;
  --message-border: #3a4a6e;
  --result-bg: #1e2a4a;
  --code-bg: #0d1b2a;
  --tab-bg: #0f1b33;
  --tab-active-bg: #1e2a4a;
  --tab-text: #8a9bb5;
  --tab-active-text: #4a9eff;
}

/* ===== 基础重置 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: 820px;
  width: 100%;
  background: var(--bg-container);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 35px 40px;
  transition: background 0.3s, box-shadow 0.3s;
}

/* ===== 标题 ===== */
h1 {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}
h1 small {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
}

.sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
  border-left: 4px solid var(--primary);
  padding-left: 14px;
  background: var(--primary-light);
  border-radius: 0 6px 6px 0;
  line-height: 1.6;
  transition: background 0.3s;
}

/* ===== 夜间模式切换按钮 ===== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transition: background 0.3s, color 0.3s, transform 0.2s;
  padding: 0;
}
.theme-toggle:hover {
  transform: scale(1.05);
}
.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== 表单通用 ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 30px;
  margin-bottom: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.field input,
.field select {
  padding: 8px 12px;
  border: 1.5px solid var(--input-border);
  border-radius: 8px;
  font-size: 14px;
  transition: 0.15s;
  background: var(--input-bg);
  color: var(--text-primary);
  width: 100%;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus-shadow);
}
.field .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== 按钮 ===== */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(42, 125, 225, 0.3);
}
.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  filter: brightness(0.85);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}
.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover {
  filter: brightness(0.85);
  transform: translateY(-1px);
}

/* ===== 消息 ===== */
.message {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 16px;
  border-left: 4px solid var(--border);
  background: var(--message-bg);
  color: var(--text-secondary);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.message.info {
  border-left-color: var(--primary);
  background: var(--primary-light);
}
.message.success {
  border-left-color: var(--success);
  background: #d4edda;
  color: #155724;
}
.message.error {
  border-left-color: var(--error);
  background: #f8d7da;
  color: #721c24;
}
.message a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.message a:hover {
  text-decoration: underline;
}
/* 暗色下适配消息 */
[data-theme="dark"] .message.success {
  background: #1e3a2a;
  color: #b0e0b0;
}
[data-theme="dark"] .message.error {
  background: #3a1e1e;
  color: #f0b0b0;
}
[data-theme="dark"] .message.info {
  background: #1e2a4a;
  color: #b0c4f0;
}

/* ===== 结果框 ===== */
.result-box {
  margin-top: 18px;
  padding: 16px 20px;
  background: var(--result-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.3s, border-color 0.3s;
}
.result-box .label {
  font-weight: 500;
  color: var(--text-secondary);
  margin-right: 10px;
}
.result-box .code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
  background: var(--code-bg);
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
  margin: 4px 0;
  color: var(--text-primary);
}
.result-box .copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s;
  margin-left: 10px;
  color: var(--text-secondary);
}
.result-box .copy-btn:hover {
  background: var(--primary-light);
}

/* ===== 页脚 ===== */
.footer-note {
  margin-top: 30px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  transition: border-color 0.3s;
}
.footer-note .github-link {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}
.footer-note .github-link:hover {
  color: var(--primary);
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .container { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  h1 { font-size: 22px; flex-wrap: wrap; }
  h1 small { margin-left: 0; }
  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
}