/* ============================================================
 * common.css - 全局变量 / 重置 / 通用组件
 * 纯前端工具箱公共样式，深色现代主题
 * ============================================================ */

:root {
  /* 颜色 */
  --bg: #0b0d12;
  --bg-elevated: #12151d;
  --surface: #171b25;
  --surface-2: #1e2330;
  --border: #2a3040;
  --border-strong: #3a4155;

  --text: #e8ecf4;
  --text-muted: #9aa4b8;
  --text-dim: #69738a;

  --primary: #6c8cff;
  --primary-600: #5574e8;
  --primary-soft: rgba(108, 140, 255, 0.14);
  --accent: #37d6b0;
  --accent-soft: rgba(55, 214, 176, 0.14);
  --danger: #ff6b7a;
  --danger-soft: rgba(255, 107, 122, 0.14);
  --warning: #f5b94a;

  /* 渐变 */
  --grad-brand: linear-gradient(135deg, #7c9cff 0%, #a06cff 100%);
  --grad-accent: linear-gradient(135deg, #37d6b0 0%, #3aa0ff 100%);

  /* 圆角与阴影 */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  /* 尺寸 */
  --header-h: 64px;
  --maxw: 1200px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- 布局辅助 ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.hidden {
  display: none !important;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.3px;
}

.topbar .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--grad-brand);
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(108, 140, 255, 0.45);
}

.topbar .spacer {
  flex: 1;
}

.topbar .nav-link {
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: 0.18s;
}

.topbar .nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 20px rgba(108, 140, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 26px rgba(108, 140, 255, 0.5);
  filter: brightness(1.08);
}

.btn-accent {
  background: var(--grad-accent);
  border-color: transparent;
  color: #08221c;
  box-shadow: 0 6px 20px rgba(55, 214, 176, 0.25);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

/* ---------- 表单 ---------- */
input[type="text"],
input[type="number"],
select,
textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: 0.18s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

label {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- 卡片 / 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
}

/* ---------- 上传拖拽区 ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: 0.2s;
  cursor: pointer;
  background: var(--bg-elevated);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone .dz-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.dropzone .dz-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.dropzone .dz-hint {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- 提示条 ---------- */
.note {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid;
}

.note-info {
  background: var(--primary-soft);
  border-color: rgba(108, 140, 255, 0.35);
  color: #c4d2ff;
}

.note-warn {
  background: rgba(245, 185, 74, 0.1);
  border-color: rgba(245, 185, 74, 0.35);
  color: #f7d28a;
}

.note-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 107, 122, 0.35);
  color: #ffb3bc;
}

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
}

.toast.success {
  border-left-color: var(--accent);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.warning {
  border-left-color: var(--warning);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---------- Loading 遮罩 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-box {
  text-align: center;
}

.loader-box .loader-text {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge-soon {
  background: rgba(245, 185, 74, 0.12);
  border-color: rgba(245, 185, 74, 0.3);
  color: var(--warning);
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty .empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .container {
    padding: 0 16px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
}
