/* ====== 灵创简历 · Design System ====== */
/* 参考: OpResume 的视觉语言 + Linear/Vercel 的精致感 */

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-hover: #F5F5F5;
  --border: #E5E5E5;
  --border-light: #F0F0F0;
  --accent: #0F766E;
  --accent-hover: #0D6B63;
  --accent-muted: #F0FDFA;
  --text: #171717;
  --text-secondary: #525252;
  --text-muted: #A3A3A3;
  --danger: #DC2626;
  --success: #16A34A;
  --warning: #F59E0B;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.08), 0 8px 40px rgba(0,0,0,0.04);
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* ====== 密钥门 ====== */
.gate-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(23,23,23,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.gate-overlay.hidden { display: none; }

.gate-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 44px 36px;
  width: 400px; max-width: 92vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: gateIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes gateIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.gate-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent-muted);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.gate-card h2 { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; letter-spacing: -0.01em; }
.gate-card > p { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }

.gate-input-group {
  display: flex; gap: 8px;
}
.gate-input-group input {
  flex: 1; padding: 11px 14px;
  font-size: 15px; text-align: center;
  letter-spacing: 1.5px; text-transform: uppercase;
  font-family: var(--font-mono);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: all var(--transition);
}
.gate-input-group input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15,118,110,0.1);
}
.gate-input-group button {
  padding: 11px 20px;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.gate-input-group button:hover { background: var(--accent-hover); }
.gate-input-group button:disabled { opacity: 0.5; cursor: not-allowed; }
.gate-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 20px; }
.gate-buy-hint { margin-top: 18px; font-size: 13px; color: var(--text-muted); display: none; }
.gate-buy-hint a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ====== 顶部导航 ====== */
.topnav {
  height: 48px; flex-shrink: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}
.topnav.hidden { display: none; }
.topnav-inner {
  max-width: 1400px; margin: 0 auto;
  height: 100%; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.topnav-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em;
}
.topnav-brand svg { color: var(--accent); }
.topnav-center { display: flex; align-items: center; gap: 12px; }
.nav-badge {
  padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--accent-muted); color: var(--accent);
}
.nav-stat { font-size: 13px; color: var(--text-secondary); }
.nav-stat strong { color: var(--text); font-weight: 600; }
.topnav-right { display: flex; align-items: center; gap: 10px; }
.nav-expiry { font-size: 12px; color: var(--text-muted); }
.nav-btn {
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.nav-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ====== 主布局 ====== */
.app-main {
  flex: 1; display: flex;
  overflow: hidden;
}
.app-main.hidden { display: none; }

/* ====== 左侧输入面板 ====== */
.panel-input {
  width: 440px; min-width: 440px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border-light);
  background: var(--surface);
  overflow-y: auto;
}

.input-card {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.input-card-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.step-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.input-card-header h3 {
  font-size: 14px; font-weight: 600;
  color: var(--text);
}
.input-hint {
  font-size: 12px; color: var(--text-muted);
  margin-left: auto;
}
.input-field {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; font-family: var(--font);
  line-height: 1.7; color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-field:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15,118,110,0.08);
}
.input-field::placeholder { color: var(--text-muted); }

/* 操作按钮 */
.action-bar {
  padding: 16px 24px;
  display: flex; gap: 10px;
  border-bottom: 1px solid var(--border-light);
}
.btn-generate {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 0;
  background: var(--text); color: white;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
}
.btn-generate:hover { background: #2d2d2d; transform: translateY(-1px); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.5; transform: none; cursor: not-allowed; }
.btn-icon { flex-shrink: 0; }

.btn-export {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  background: var(--surface); color: var(--text-secondary);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.btn-export:hover { background: var(--surface-hover); border-color: var(--text-muted); }

/* 匹配分析卡片 */
.match-card {
  padding: 20px 24px;
  display: flex; align-items: flex-start; gap: 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--accent-muted);
  animation: slideUp 0.3s ease;
}
.match-card.hidden { display: none; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.match-score-ring {
  position: relative;
  width: 72px; height: 72px;
  flex-shrink: 0;
}
.match-score-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.match-score-inner span {
  font-size: 20px; font-weight: 800; color: var(--accent);
  line-height: 1.1;
}
.match-score-inner small {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase;
}
.match-keywords {
  flex: 1; display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12px;
}
.match-keywords .kw-tag {
  padding: 3px 10px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ====== 右侧预览面板 ====== */
.panel-preview {
  flex: 1; display: flex; flex-direction: column;
  background: #E8E8E8;
  overflow: hidden;
}

.preview-toolbar {
  height: 44px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.gen-status {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.gen-status::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: var(--success);
}
.gen-status.loading::before {
  background: var(--accent);
  animation: pulse 1.2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.preview-actions { display: flex; gap: 2px; background: var(--bg); border-radius: var(--radius-sm); padding: 2px; }
.tool-btn {
  padding: 5px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
  border: none; cursor: pointer;
  background: transparent; color: var(--text-muted);
  transition: all var(--transition);
}
.tool-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.preview-scroll {
  flex: 1; overflow: auto;
  padding: 32px;
  display: flex; justify-content: center;
}
.preview-scroll.hidden { display: none; }

/* ====== A4 纸简历 ====== */
.resume-paper {
  width: 210mm;
  min-height: 297mm;
  background: white;
  box-shadow: var(--shadow-lg);
  padding: 20mm 18mm;
  font-size: 10.5pt;
  line-height: 1.6;
  color: #1a1a1a;
}
.paper-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; min-height: 240mm;
  color: var(--text-muted);
}
.empty-icon { opacity: 0.3; margin-bottom: 16px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-desc { font-size: 13px; }

/* 简历内容排版 */
.resume-paper h1 {
  font-size: 22pt; font-weight: 700;
  text-align: center; margin-bottom: 2mm;
  letter-spacing: 0.02em;
}
.resume-paper .contact-line {
  text-align: center; font-size: 9pt; color: #555;
  margin-bottom: 6mm; padding-bottom: 4mm;
  border-bottom: 1.5px solid var(--accent);
}
.resume-paper h2 {
  font-size: 13pt; font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid #ddd;
  padding-bottom: 1mm; margin: 5mm 0 3mm;
  letter-spacing: 0.03em;
}
.resume-paper h3 { font-size: 11pt; font-weight: 600; margin: 3mm 0 1mm; }
.resume-paper ul, .resume-paper ol { padding-left: 5mm; margin: 2mm 0; }
.resume-paper li { margin-bottom: 1.5mm; }
.resume-paper strong { color: #1a1a1a; }
.resume-paper em { color: #555; }
.resume-paper hr { border: none; border-top: 0.5px solid #ddd; margin: 3mm 0; }
.resume-paper .job-header {
  display: flex; justify-content: space-between;
  font-size: 10pt;
}
.resume-paper .job-title { font-weight: 600; }
.resume-paper .job-date { color: #777; font-size: 9pt; }
.resume-paper .job-company { color: #555; font-size: 9.5pt; }

/* ====== Diff 对比视图 ====== */
.diff-container {
  display: flex; gap: 0;
  max-width: 1100px; width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.diff-panel { flex: 1; min-width: 0; }
.diff-label {
  padding: 12px 16px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}
.diff-content {
  padding: 20px;
  font-size: 13px; line-height: 1.8;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  white-space: pre-wrap;
}
.diff-divider {
  width: 1px;
  background: var(--border-light);
  flex-shrink: 0;
}

/* ====== 流式加载 ====== */
.stream-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(4px);
}
.stream-overlay.hidden { display: none; }
.stream-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 40px; max-width: 500px; width: 90%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.stream-spinner {
  margin-bottom: 16px;
  animation: spin 1.2s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stream-card > p {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 12px;
}
.stream-text {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.7; text-align: left;
  max-height: 200px; overflow-y: auto;
  padding: 12px; background: var(--bg);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
}
.stream-text:empty { display: none; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; z-index: 300;
  background: var(--text); color: white;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.hidden {
  opacity: 0; transform: translateX(-50%) translateY(16px);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ====== 响应式 ====== */
@media (max-width: 900px) {
  .app-main { flex-direction: column; }
  .panel-input { width: 100%; min-width: 100%; max-height: 55vh; border-right: none; border-bottom: 1px solid var(--border-light); }
  .panel-preview { min-height: 45vh; }
  .resume-paper { width: 100%; min-height: auto; padding: 12mm; }
  .diff-container { flex-direction: column; }
  .diff-divider { width: 100%; height: 1px; }
}

@media print {
  body { background: white; }
  .panel-input, .topnav, .preview-toolbar, .toast, .stream-overlay { display: none !important; }
  .panel-preview { background: white; }
  .preview-scroll { padding: 0; }
  .resume-paper { box-shadow: none; width: 100%; min-height: auto; }
}
