/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --editor-bg: #ffffff;
  --preview-bg: #e2e8f0;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-light: #64748b;
  --paper-w: 210mm;
  --paper-h: 297mm;
}

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

/* ===== 顶部工具栏 ===== */
.toolbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.toolbar-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 20px; font-weight: 700; color: var(--primary); }
.tagline { font-size: 12px; color: var(--text-light); }

.toolbar-right { display: flex; gap: 8px; }

.btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-select { padding-right: 28px; }

/* ===== 主体双栏 ===== */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ===== 编辑区 ===== */
.editor {
  width: 46%;
  background: var(--editor-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.editor-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.block { margin-bottom: 28px; }
.block-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.block-title { font-size: 15px; font-weight: 600; color: var(--text); border-left: 3px solid var(--primary); padding-left: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-item { display: flex; flex-direction: column; gap: 4px; }
.form-item label { font-size: 12px; color: var(--text-light); }
.form-item input, .block input, .block textarea {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border 0.15s;
}
.form-item input:focus, .block input:focus, .block textarea:focus { border-color: var(--primary); }
.block textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.6; }

.btn-add {
  height: 28px;
  padding: 0 12px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-add:hover { background: rgba(37,99,235,0.06); }

/* ===== 照片上传区域 ===== */
.photo-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.photo-placeholder {
  width: 100px;
  height: 130px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-light);
  text-align: center;
}

.photo-placeholder:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(37,99,235,0.04);
}

.photo-icon { font-size: 24px; }
.photo-text { font-size: 13px; }
.photo-tip { font-size: 11px; opacity: 0.7; }

.photo-preview {
  width: 100px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-clear {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #ef4444;
  border-radius: 6px;
  background: transparent;
  color: #ef4444;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.photo-clear:hover { background: rgba(239,68,68,0.08); }

.hidden { display: none !important; }

/* 经历条目卡片 */
.entry-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}
.entry-card .form-grid { margin-bottom: 8px; }
.entry-card .entry-actions { display: flex; justify-content: flex-end; }
.entry-card .btn-del {
  height: 26px; padding: 0 10px; border: none; background: transparent;
  color: #ef4444; font-size: 12px; cursor: pointer; border-radius: 4px;
}
.entry-card .btn-del:hover { background: rgba(239,68,68,0.1); }

/* ===== 预览区 ===== */
.preview {
  width: 54%;
  background: var(--preview-bg);
  display: flex;
  flex-direction: column;
}

.preview-toolbar {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-label { font-size: 13px; color: var(--text-light); }
.preview-zoom { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-light); }
.btn-sm {
  width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; cursor: pointer; font-size: 14px; line-height: 1; color: var(--text);
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }

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

/* ===== 简历纸张 ===== */
.resume-page {
  width: var(--paper-w);
  min-height: var(--paper-h);
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  padding: 40px 48px;
  font-size: 14px;
  line-height: 1.7;
  color: #222;
  transform-origin: top center;
  transition: transform 0.2s;
}

/* ===== 经典商务模板 ===== */
.template-classic .rp-header { text-align: center; border-bottom: 2px solid #333; padding-bottom: 12px; margin-bottom: 20px; }
.template-classic .rp-header.has-photo { display: flex; align-items: center; gap: 20px; text-align: left; }
.template-classic .rp-header.has-photo .rp-contact { justify-content: flex-start; }
.template-classic .rp-header-info { flex: 1; min-width: 0; }
.template-classic .rp-avatar { width: 80px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; flex-shrink: 0; }
.template-classic .rp-name { font-size: 26px; font-weight: 700; letter-spacing: 2px; white-space: nowrap; }
.template-classic .rp-jobtitle { font-size: 15px; color: #555; margin-top: 4px; }
.template-classic .rp-contact { font-size: 12px; color: #666; margin-top: 8px; display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.template-classic .rp-section { margin-bottom: 18px; }
.template-classic .rp-section-title { font-size: 15px; font-weight: 700; border-left: 3px solid #333; padding-left: 8px; margin-bottom: 10px; }
.template-classic .rp-entry { margin-bottom: 12px; }
.template-classic .rp-entry-head { display: flex; justify-content: space-between; align-items: baseline; }
.template-classic .rp-entry-title { font-weight: 600; }
.template-classic .rp-entry-org { color: #555; }
.template-classic .rp-entry-date { font-size: 12px; color: #888; }
.template-classic .rp-entry-desc { font-size: 13px; color: #444; margin-top: 4px; white-space: pre-line; }
.template-classic .rp-skills { font-size: 13px; white-space: pre-line; }
.template-classic .rp-summary { font-size: 13px; color: #444; }

/* ===== 现代简约模板 ===== */
.template-modern { padding: 0; }
.template-modern .rp-header { background: #2563eb; color: #fff; padding: 32px 48px 24px; }
.template-modern .rp-header.has-photo { display: flex; align-items: center; gap: 20px; }
.template-modern .rp-avatar { width: 80px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid rgba(255,255,255,0.3); flex-shrink: 0; }
.template-modern .rp-name { font-size: 28px; font-weight: 700; }
.template-modern .rp-jobtitle { font-size: 15px; opacity: 0.9; margin-top: 4px; }
.template-modern .rp-contact { font-size: 12px; opacity: 0.85; margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
.template-modern .rp-body { padding: 24px 48px 40px; }
.template-modern .rp-section { margin-bottom: 20px; }
.template-modern .rp-section-title { font-size: 15px; font-weight: 700; color: #2563eb; border-bottom: 1px solid #dbeafe; padding-bottom: 6px; margin-bottom: 10px; }
.template-modern .rp-entry { margin-bottom: 12px; }
.template-modern .rp-entry-head { display: flex; justify-content: space-between; align-items: baseline; }
.template-modern .rp-entry-title { font-weight: 600; }
.template-modern .rp-entry-org { color: #555; }
.template-modern .rp-entry-date { font-size: 12px; color: #888; }
.template-modern .rp-entry-desc { font-size: 13px; color: #444; margin-top: 4px; white-space: pre-line; }
.template-modern .rp-skills { font-size: 13px; white-space: pre-line; }
.template-modern .rp-summary { font-size: 13px; color: #444; }

/* ===== 空状态 ===== */
.rp-empty { text-align: center; color: #aaa; padding: 120px 0; font-size: 14px; }

/* ===== 极简专业模板 ===== */
.template-minimal { padding: 48px 56px; }
.template-minimal .rp-header { text-align: left; border-bottom: 1px solid #999; padding-bottom: 10px; margin-bottom: 24px; }
.template-minimal .rp-header.has-photo { display: flex; align-items: center; gap: 20px; }
.template-minimal .rp-avatar { width: 80px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; flex-shrink: 0; }
.template-minimal .rp-name { font-size: 24px; letter-spacing: 1px; }
.template-minimal .rp-jobtitle { font-size: 14px; color: #555; margin-top: 2px; }
.template-minimal .rp-contact { justify-content: flex-start; margin-top: 6px; font-size: 12px; }
.template-minimal .rp-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; border-left: none; border-bottom: 1px solid #ddd; padding: 0 0 4px 0; margin-bottom: 12px; color: #333; }
.template-minimal .rp-entry { margin-bottom: 14px; }

/* ===== 双栏设计模板 ===== */
.template-twocol { padding: 0; }
.template-twocol .rp-header { background: #1e293b; color: #fff; padding: 32px 32px 24px; border: none; }
.template-twocol .rp-header.has-photo { display: flex; align-items: center; gap: 20px; }
.template-twocol .rp-avatar { width: 80px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0; }
.template-twocol .rp-name { color: #fff; font-size: 24px; }
.template-twocol .rp-jobtitle { color: #94a3b8; }
.template-twocol .rp-contact { color: #cbd5e1; flex-direction: column; gap: 4px; align-items: flex-start; }
.template-twocol .rp-body { display: flex; gap: 0; }
.template-twocol .rp-sidebar { width: 34%; background: #f1f5f9; padding: 24px 20px; }
.template-twocol .rp-main { flex: 1; padding: 24px 28px; }
.template-twocol .rp-sidebar .rp-section-title { color: #1e293b; border-left: 3px solid #1e293b; border-bottom: none; padding-left: 8px; padding-bottom: 0; font-size: 13px; }
.template-twocol .rp-main .rp-section-title { color: #1e293b; border-left: none; border-bottom: 1px solid #e2e8f0; padding: 0 0 4px 0; font-size: 14px; }

/* ===== 学术科研模板 ===== */
.template-academic { padding: 48px 56px; font-family: "Times New Roman", "SimSun", serif; }
.template-academic .rp-header { text-align: center; border-bottom: 1px solid #333; padding-bottom: 14px; margin-bottom: 22px; }
.template-academic .rp-header.has-photo { display: flex; align-items: center; gap: 20px; text-align: left; }
.template-academic .rp-header.has-photo .rp-contact { justify-content: flex-start; }
.template-academic .rp-avatar { width: 80px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; flex-shrink: 0; }
.template-academic .rp-name { font-size: 24px; letter-spacing: 3px; }
.template-academic .rp-jobtitle { font-size: 14px; color: #555; margin-top: 4px; }
.template-academic .rp-contact { justify-content: center; font-size: 11px; }
.template-academic .rp-section-title { font-size: 14px; font-weight: 700; border-left: none; border-bottom: 1px solid #333; padding: 0 0 3px 0; margin-bottom: 10px; }
.template-academic .rp-entry { margin-bottom: 10px; }
.template-academic .rp-entry-desc { font-size: 12px; }

/* ===== 传统学术模板 ===== */
.template-chinese-classic {
  padding: 50px 56px;
  font-family: "SimSun", "宋体", "Times New Roman", serif;
  color: #000;
  font-size: 14px;
  line-height: 1.75;
}
.template-chinese-classic .rp-header {
  border-bottom: 2.5px solid #000;
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.template-chinese-classic .rp-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.template-chinese-classic .rp-name {
  font-size: 24px;
  font-weight: 700;
  flex: 0 0 auto;
  letter-spacing: 0;
}
.template-chinese-classic .rp-jobtitle-center {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  padding-top: 4px;
}
.template-chinese-classic .rp-avatar {
  width: 90px;
  height: 115px;
  object-fit: cover;
  border: 1px solid #999;
  flex-shrink: 0;
}
.template-chinese-classic .rp-contact {
  font-size: 13px;
  color: #000;
  margin-top: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.template-chinese-classic .rp-contact .phone {
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-weight: 500;
}
.template-chinese-classic .rp-section {
  margin-bottom: 18px;
}
.template-chinese-classic .rp-section-title {
  font-size: 15px;
  font-weight: 700;
  border-bottom: 2px solid #000;
  border-left: none;
  padding: 0 0 5px 0;
  margin-bottom: 14px;
  letter-spacing: 0;
}
.template-chinese-classic .rp-entry {
  margin-bottom: 16px;
}
.template-chinese-classic .rp-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 12px;
}
.template-chinese-classic .rp-entry-date {
  font-size: 12px;
  color: #000;
  font-weight: 500;
  flex: 0 0 100px;
  white-space: nowrap;
}
.template-chinese-classic .rp-entry-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  flex: 1;
  letter-spacing: 0;
  min-width: 0;
}
.template-chinese-classic .rp-entry-org {
  font-size: 13px;
  color: #000;
  text-align: right;
  flex: 0 0 280px;
  white-space: nowrap;
}
.template-chinese-classic .rp-entry-desc {
  font-size: 13px;
  color: #000;
  margin-top: 4px;
  white-space: normal;
}
.template-chinese-classic .rp-bullets {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 0 0;
}
.template-chinese-classic .rp-bullets li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 3px;
  line-height: 1.75;
}
.template-chinese-classic .rp-bullets li::before {
  content: "●";
  position: absolute;
  left: 0;
  top: 0;
  color: #000;
  font-size: 11px;
}
.template-chinese-classic .rp-skill-line {
  margin-bottom: 5px;
  font-size: 13px;
}
.template-chinese-classic .rp-skill-line strong {
  font-weight: 700;
}
.template-chinese-classic .rp-summary {
  font-size: 13px;
  color: #000;
  white-space: normal;
}
.template-chinese-classic .kw {
  color: #c00;
  text-decoration: underline;
  text-decoration-color: #c00;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .main { flex-direction: column; }
  .editor { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .preview { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 0 12px; }
  .tagline { display: none; }
  .form-item-full { grid-column: 1 !important; }
}

/* ===== 岗位预设弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-overlay.visible { opacity: 1; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 680px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.visible .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px; border: none; background: transparent;
  font-size: 20px; cursor: pointer; border-radius: 6px; color: var(--text-light);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f1f5f9; }

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-tab {
  padding: 10px 14px;
  font-size: 13px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.modal-tab:hover { color: var(--primary); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.preset-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,0.08); }
.preset-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.preset-card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.preset-card-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: #eff6ff; color: var(--primary); }
.preset-card-desc { font-size: 13px; color: var(--text-light); line-height: 1.6; margin-bottom: 10px; }
.preset-card-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-skill-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-light);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.preset-preview {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.preset-preview-title { font-size: 12px; color: var(--text-light); margin-bottom: 8px; font-weight: 600; }
.preset-preview-content { font-size: 12px; color: var(--text); line-height: 1.7; white-space: pre-line; }

.preset-detail-panel {
  display: none;
}
.preset-detail-panel.visible { display: block; }
.preset-list-panel.hidden-panel { display: none; }
