/* ============================================
   小程序短链生成工具 - 样式表
   移动端优先，自适应桌面
   ============================================ */

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

:root {
  --wx-green: #1890ff;
  --wx-green-dark: #0070e8;
  --wx-green-light: #e8f4ff;
  --blue: #10aeff;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-hint: #999;
  --bg-page: #f5f6f8;
  --bg-card: #ffffff;
  --border: #e8e8e8;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);
  --radius: 14px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- 顶部导航 ---- */
.header {
  background: var(--wx-green);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(7, 193, 96, 0.2);
}

.header-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.version-badge {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: 20px;
}

/* ---- 主体容器 ---- */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* ---- 介绍区 ---- */
.intro {
  text-align: center;
  padding: 20px 0 24px;
}

.intro h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.intro p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

/* ---- 卡片 ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 4px;
  height: 18px;
  background: var(--wx-green);
  border-radius: 2px;
}

/* ---- 表单 ---- */
.form-group {
  margin-bottom: 18px;
}

/* ---- 输入模式切换 ---- */
.input-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.input-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.input-tab.active {
  background: #fff;
  color: var(--wx-green-dark);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.input-tab svg {
  flex-shrink: 0;
}

/* ---- 字段提示 ---- */
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 6px;
  line-height: 1.4;
}

/* ---- 解析信息卡片 ---- */
.resolve-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resolve-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.resolve-label {
  flex-shrink: 0;
  width: 70px;
  font-size: 12px;
  color: var(--text-hint);
  padding-top: 8px;
}

.resolve-row code {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-page);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-primary);
  word-break: break-all;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  line-height: 1.5;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.required {
  color: #ee0a24;
}

.optional {
  font-size: 12px;
  color: var(--text-hint);
  font-weight: 400;
  background: var(--bg-page);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23999' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--wx-green);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

.input-with-toggle {
  position: relative;
}

.input-with-toggle input {
  padding-right: 48px;
}

.toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-hint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-btn:active {
  color: var(--wx-green);
}

/* ---- Logo Toggle 开关 ---- */
.logo-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-left: 4px;
}

.logo-toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.logo-toggle-hint {
  font-size: 12px;
  color: var(--text-hint);
  margin-left: 4px;
}

/* ---- Logo 上传区 ---- */
.logo-upload-area {
  margin-bottom: 12px;
}

.logo-upload-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, background 0.2s;
}

.logo-upload-inner.has-logo {
  border-style: solid;
  border-color: var(--wx-green);
  background: var(--wx-green-light);
}

.logo-upload-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}

.logo-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-upload-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.logo-upload-btn {
  align-self: flex-start;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.logo-upload-btn:active {
  background: var(--wx-green-light);
  border-color: var(--wx-green);
  color: var(--wx-green-dark);
}

.logo-upload-tip {
  font-size: 11px;
  color: var(--text-hint);
  line-height: 1.4;
}

.logo-upload-status {
  font-size: 11px;
  color: var(--wx-green-dark);
  line-height: 1.4;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background-color: #ccc;
  border-radius: 26px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.switch input:checked + .slider {
  background-color: var(--wx-green);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.hint {
  display: block;
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 5px;
  line-height: 1.4;
}

/* ---- 示例按钮 ---- */
.examples {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.examples-label {
  font-size: 12px;
  color: var(--text-hint);
}

.example-btn {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.example-btn:active {
  background: var(--wx-green-light);
  border-color: var(--wx-green);
  color: var(--wx-green-dark);
}

/* ---- 模式选择器 ---- */
.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.mode-option {
  flex: 1;
  cursor: pointer;
}

.mode-option input {
  display: none;
}

.mode-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  text-align: center;
}

.mode-option input:checked + .mode-inner {
  border-color: var(--wx-green);
  background: var(--wx-green-light);
}

.mode-option input:checked + .mode-inner code {
  color: var(--wx-green-dark);
  font-weight: 600;
}

.mode-inner strong {
  font-size: 13px;
  color: var(--text-primary);
}

.mode-inner code {
  font-size: 11px;
  font-family: "SF Mono", Consolas, monospace;
  color: var(--text-secondary);
  background: transparent;
  padding: 0;
}

.mode-inner span {
  font-size: 10px;
  color: var(--text-hint);
  line-height: 1.3;
}

/* 配置提示条 */
.config-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff8ec;
  border: 1px solid #f0d9a0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #c67d00;
  margin-bottom: 16px;
  line-height: 1.5;
}

.config-hint svg { flex-shrink: 0; }

/* ---- 对比表格 ---- */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.compare-table th,
.compare-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.compare-table th {
  background: var(--bg-page);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
}

.compare-table td:first-child,
.compare-table th:first-child {
  text-align: left;
  color: var(--text-secondary);
  white-space: nowrap;
}

.compare-table code {
  font-size: 10px;
  background: transparent;
  padding: 0;
  display: block;
  margin-top: 2px;
}

.tag-purple {
  background: #f0e8ff;
  color: #7c3aed;
}

@media (max-width: 480px) {
  .mode-selector { flex-direction: column; }
  .compare-table { font-size: 11px; }
  .compare-table th, .compare-table td { padding: 7px 4px; }
}

/* ---- 主按钮 ---- */
.btn-primary {
  width: 100%;
  height: 50px;
  background: var(--wx-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 6px;
}

.btn-primary:active {
  background: var(--wx-green-dark);
  transform: scale(0.98);
}

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

.btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ---- 错误提示 ---- */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.alert-error {
  background: #fff0f0;
  color: #ee0a24;
  border: 1px solid #ffd6d6;
}

/* ---- 结果卡片 ---- */
.result-card {
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 8px;
}

.result-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-icon {
  font-size: 18px;
}

.result-desc {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 12px;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-green {
  background: var(--wx-green-light);
  color: var(--wx-green-dark);
}

.tag-blue {
  background: #e8f4ff;
  color: #0091d7;
}

.result-content {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.result-content code {
  flex: 1;
  min-height: 46px;
  padding: 12px 14px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  display: flex;
  align-items: center;
  line-height: 1.4;
}

.btn-copy {
  flex-shrink: 0;
  padding: 0 18px;
  background: var(--wx-green-light);
  color: var(--wx-green-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-copy:active {
  background: #d0efd9;
}

.btn-copy.copied {
  background: var(--wx-green);
  color: #fff;
}

/* ---- 二维码区域 ---- */
.qr-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.qr-card {
  text-align: center;
}

.qr-display {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.qr-display img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.btn-download {
  width: 100%;
  height: 42px;
  background: #fff;
  color: var(--wx-green);
  border: 1.5px solid var(--wx-green);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-download:active {
  background: var(--wx-green-light);
}

/* ---- 说明卡片 ---- */
.tips-card {
  background: #fafbfc;
  border: 1px solid var(--border);
}

.tips-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.tips-list {
  list-style: none;
  padding: 0;
}

.tips-list li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 6px 0;
  padding-left: 18px;
  position: relative;
}

.tips-list li::before {
  content: "•";
  color: var(--wx-green);
  position: absolute;
  left: 4px;
  font-weight: bold;
}

.tips-list strong {
  color: var(--text-primary);
}

/* ---- 底部 ---- */
.footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-hint);
}

/* ---- Toast 提示 ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   桌面端适配（≥768px）
   ============================================ */
@media (min-width: 768px) {
  .container {
    padding: 24px;
  }

  .intro {
    padding: 28px 0 32px;
  }

  .intro h1 {
    font-size: 28px;
  }

  .intro p {
    font-size: 15px;
  }

  .card {
    padding: 28px;
  }

  .card-title {
    font-size: 18px;
  }

  .form-group input,
  .form-group select {
    height: 50px;
    font-size: 15px;
  }

  .btn-primary {
    height: 54px;
    font-size: 17px;
  }

  .qr-grid {
    grid-template-columns: 1fr 1fr;
  }

  .qr-display img {
    width: 220px;
    height: 220px;
  }

  .result-header h3 {
    font-size: 16px;
  }

  .result-content code {
    font-size: 14px;
  }
}

/* 大屏居中 */
@media (min-width: 1024px) {
  .header-inner {
    max-width: 720px;
  }
}
