/* ============================================================
 * shared.css — 飞书转发器用户端共享样式 v2
 * 参考: MDN / Google Web.dev / W3C CSS Specifications
 * 原则: CSS变量 / 移动优先 / 无障碍 / 零依赖
 * ============================================================ */

/* ---- Design Tokens ---- */
:root {
  --p: #3B82F6;
  --pd: #2563EB;
  --pl: #EFF6FF;
  --success: #10B981;
  --success-l: #ECFDF5;
  --warning: #F59E0B;
  --warning-l: #FFFBEB;
  --danger: #EF4444;
  --danger-l: #FEF2F2;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: rgba(0, 0, 0, 0.1);
  --border-2: rgba(0, 0, 0, 0.15);
  --text: #0F172A;
  --text-2: #64748B;
  --text-3: #94A3B8;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --sh-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --sh-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.04);
  --sh-p: 0 4px 14px rgba(59, 130, 246, 0.3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
button { border: none; background: none; cursor: pointer; font-family: inherit; color: inherit; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; font-weight: 500; }
img { max-width: 100%; height: auto; }

/* ---- Layout ---- */
.page-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease), opacity .15s var(--ease);
  -webkit-user-select: none; user-select: none;
  position: relative; overflow: hidden;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.95); opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--p); color: #fff; border-color: var(--p); box-shadow: var(--sh-p); }
.btn--primary:hover { background: var(--pd); border-color: var(--pd); box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4); }
.btn--primary:active { box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3); }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--success:hover { background: #0CA672; border-color: #0CA672; box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35); }
.btn--warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn--warning:hover { background: #D97F08; border-color: #D97F08; box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35); }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--sm { font-size: 12px; padding: 6px 12px; }

/* ---- Ripple 效果 ---- */
.btn .ripple {
  position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.4);
  transform: scale(0); animation: rippleAnim .5s var(--ease); pointer-events: none;
}
.btn--ghost .ripple, .btn:not(.btn--primary):not(.btn--success):not(.btn--warning) .ripple { background: rgba(0, 0, 0, 0.08); }
@keyframes rippleAnim { to { transform: scale(2.5); opacity: 0; } }

/* ---- Focus visible (无障碍) ---- */
.btn:focus-visible, .field__input:focus-visible, .link:focus-visible {
  outline: 2px solid var(--p);
  outline-offset: 2px;
}

/* ---- Form ---- */
.field { margin-bottom: 12px; }
.field__label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field__input {
  width: 100%; padding: 13px 14px; border: 1px solid var(--border-2);
  border-radius: var(--r-sm); font-size: 16px; background: var(--surface);
  transition: border-color .2s var(--ease);
  -webkit-appearance: none; appearance: none;
}
.field__input:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); }
.field__input::placeholder { color: var(--text-3); }
.field__input--mono { font-family: var(--mono); letter-spacing: 0.5px; }

/* ---- Card ---- */
.card {
  background: var(--surface); border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--sh-sm); border: 1px solid var(--border);
}
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card__title { font-size: 15px; font-weight: 500; }
.card__sub { font-size: 12px; color: var(--text-3); }

/* ---- Badge ---- */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.badge--ok { background: var(--success-l); color: var(--success); }
.badge--warn { background: var(--warning-l); color: var(--warning); }
.badge--info { background: var(--pl); color: var(--p); }
.badge--gray { background: var(--surface-2); color: var(--text-3); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 16px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal-overlay--show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 28px 24px; width: 100%; max-width: 360px; text-align: center;
  box-shadow: var(--sh-lg); animation: modalIn .2s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- QR 弹窗 ---- */
.qr-modal { max-width: 300px; padding: 32px 24px; }
.qr-modal__img { width: 200px; height: 200px; max-width: 100%; margin: 0 auto 16px; display: block; border-radius: var(--r-sm); }
.qr-modal__title { font-size: 15px; font-weight: 500; color: var(--p); margin-bottom: 8px; }
.qr-modal__status { font-size: 13px; color: var(--warning); display: flex; align-items: center; justify-content: center; gap: 6px; }
.qr-modal__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); animation: blink 1.5s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- 成功弹窗 ---- */
.success-modal { max-width: 280px; padding: 32px 24px 24px; }
.success-modal__check { width: 56px; height: 56px; border-radius: 50%; background: var(--success-l); margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; }
.success-modal__check svg { width: 28px; height: 28px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: #fff; padding: 10px 20px;
  border-radius: var(--r-sm); font-size: 13px; z-index: 300;
  opacity: 0; transition: opacity .2s var(--ease); pointer-events: none;
  max-width: 90vw; text-align: center;
}
.toast--show { opacity: 1; }

/* ---- States ---- */
.loading { text-align: center; padding: 30px; color: var(--text-2); font-size: 13px; }
.empty { text-align: center; color: var(--text-3); padding: 24px; font-size: 13px; }

/* ---- Link ---- */
.link { color: var(--p); font-size: 13px; cursor: pointer; }
.link:hover { text-decoration: underline; }
