/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #1a3a5c;
  --primary-light: #ebf0f7;
  --accent: #2d6da8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── Header ─── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  flex-shrink: 0;
}
.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}
.logo span { color: var(--accent); font-weight: 300; }
.tagline { font-size: 13px; color: var(--text-muted); }

/* ─── Body Layout ─── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Left Form Panel ─── */
.form-panel {
  width: 420px;
  min-width: 380px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
.form-scroll { padding: 20px 24px; }

.form-section {
  margin-bottom: 24px;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title-repeater { margin-bottom: 10px; }

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,109,168,0.12);
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-group.half { flex: 1; }

/* ─── Buttons ─── */
.btn-add {
  background: var(--primary-light);
  border: 1px dashed var(--accent);
  color: var(--accent);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}
.btn-add:hover { background: var(--accent); color: #fff; border-style: solid; }

.btn-sm {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-sm:hover { background: var(--accent); }

.btn-remove {
  background: none;
  border: none;
  color: #e53e3e;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.btn-remove:hover { opacity: 1; background: #fff5f5; }

/* ─── Toolbar ─── */
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar-label { font-weight: 500; font-size: 13px; color: var(--text-muted); }
.toolbar-right { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}
.btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-export { border: none; color: #fff; }
.btn-word { background: #2b5797; }
.btn-word:hover { background: #1e3f73; }
.btn-png { background: #16a34a; }
.btn-png:hover { background: #15803d; }
.btn-pdf { background: #dc2626; }
.btn-pdf:hover { background: #b91c1c; }

/* ─── Template Selector ─── */
.template-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.template-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
}
.template-option:hover { border-color: var(--accent); background: var(--primary-light); }
.template-option.active { border-color: var(--accent); background: var(--primary-light); box-shadow: 0 0 0 2px rgba(45,109,168,0.15); }
.tmpl-icon { font-size: 18px; }

/* ─── Skills Tags ─── */
.skills-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.skills-input-wrapper input { flex: 1; }
.skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
}
.tag-remove {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1;
  margin-left: 2px;
}
.tag-remove:hover { color: #e53e3e; }

/* ─── Repeatable Items ─── */
.repeat-item {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  position: relative;
}
.repeat-item .btn-remove {
  position: absolute;
  top: 8px;
  right: 8px;
}
.repeat-item .form-group { margin-bottom: 8px; }
.repeat-item .form-group:last-child { margin-bottom: 0; }

/* ─── Color Picker ─── */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-picker-row input[type="color"] {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
}
.color-picker-row label { font-size: 13px; color: var(--text-muted); }

/* ─── Photo Upload ─── */
input[type="file"] { font-size: 12px; padding: 6px 0; }

/* ─── Preview Panel ─── */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.resume-preview-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  justify-content: center;
}
.resume-page {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a202c;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

/* ─── Scrollbar ─── */
.form-panel::-webkit-scrollbar,
.resume-preview-container::-webkit-scrollbar {
  width: 6px;
}
.form-panel::-webkit-scrollbar-track,
.resume-preview-container::-webkit-scrollbar-track {
  background: transparent;
}
.form-panel::-webkit-scrollbar-thumb,
.resume-preview-container::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}
.form-panel::-webkit-scrollbar-thumb:hover,
.resume-preview-container::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .form-panel { width: 360px; min-width: 320px; }
}
@media (max-width: 768px) {
  .app-body { flex-direction: column; }
  .form-panel { width: 100%; min-width: 0; max-height: 50vh; border-right: none; border-bottom: 1px solid var(--border); }
  .resume-preview-container { padding: 16px; }
  .resume-page { width: 100%; min-height: auto; }
  .header-inner { flex-direction: column; gap: 4px; }
  .tagline { display: none; }
  .preview-toolbar { flex-direction: column; gap: 8px; }
  .toolbar-right { flex-wrap: wrap; justify-content: center; }
}

/* ─── Template Styles (live inside resume-page) ─── */
.resume-page { font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; }

.tmpl-classic { padding: 0; }
.tmpl-modern { padding: 0; }
.tmpl-elegant { padding: 0; }
.tmpl-creative { padding: 0; }

/* ─── Loading Spinner ─── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  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); } }

/* ─── Print Styles ─── */
@media print {
  .app-header, .form-panel, .preview-toolbar { display: none; }
  .preview-panel { overflow: visible; }
  .resume-page { box-shadow: none; border-radius: 0; }
}
/* ─── Loading overlay ─── */
.export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.export-overlay .spinner-lg {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
/* ─── Focus placeholder for photo ─── */
.photo-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #a0aec0;
  overflow: hidden;
  object-fit: cover;
}
.photo-placeholder img { width: 100%; height: 100%; object-fit: cover; }
/* small text helper */
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
/* ─── PDF export ─── */
.resume-page.pdf-export {
  position: absolute;
  left: -9999px;
  top: 0;
}
/* Make sure table-like layouts work in previews */
.resume-grid { display: flex; height: 100%; }
.resume-grid .left-col { width: 35%; padding: 32px 24px; }
.resume-grid .right-col { width: 65%; padding: 32px 28px; }
@media (max-width: 768px) {
  .resume-grid { flex-direction: column; }
  .resume-grid .left-col { width: 100%; }
  .resume-grid .right-col { width: 100%; }
}
/* section dividers */
.section-divider { height: 2px; background: var(--border); margin: 12px 0 16px; }
.section-divider.accent { background: var(--accent); }
.bullet-item { padding-left: 16px; position: relative; margin-bottom: 4px; }
.bullet-item::before { content: "•"; position: absolute; left: 0; color: var(--accent); }
.exp-item, .edu-item { margin-bottom: 14px; }
.exp-header, .edu-header { display: flex; justify-content: space-between; align-items: baseline; }
.exp-date, .edu-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.contact-row { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); }
