/* ==========================================================================
   ШАБЛОНЫ РЕЗЮМЕ
   Общая разметка одна для всех шаблонов (см. app.js -> renderResume),
   а внешний вид полностью определяется классом .template-XXX на .resume-doc.
   ========================================================================== */

.resume-doc {
  --r-accent: #2563eb;
  width: 794px;           /* ширина А4 при 96dpi */
  min-height: 1123px;     /* высота А4 при 96dpi */
  background: #fff;
  color: #1a1a1a;
  box-sizing: border-box;
  font-family: 'Inter', Arial, sans-serif;
  line-height: 1.45;
  overflow: hidden;
}

.resume-doc * { box-sizing: border-box; }

.resume-doc .r-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.resume-doc .r-photo {
  overflow: hidden;
  background: #e5e7eb;
  flex-shrink: 0;
}
.resume-doc .r-photo.empty { display: none; }

.resume-doc .r-name { font-weight: 800; margin: 0 0 2px; }
.resume-doc .r-title-text { margin: 0; opacity: .85; font-weight: 500; }
.resume-doc .r-personal-meta { display: flex; gap: 12px; margin-top: 6px; font-size: .82em; opacity: .75; flex-wrap: wrap; }
.resume-doc .r-meta-item { display: flex; align-items: center; gap: 5px; }

.resume-doc .r-contact ul { list-style: none; margin: 0; padding: 0; }
.resume-doc .r-contact li { margin-bottom: 4px; word-break: break-word; display: flex; align-items: center; gap: 6px; }
.resume-doc .r-contact li svg { flex-shrink: 0; opacity: .8; }
.resume-doc .r-contact a { color: inherit; text-decoration: none; }
.resume-doc .r-contact a:hover { text-decoration: underline; }

.resume-doc .r-social { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.resume-doc .r-social a { display: flex; align-items: center; gap: 5px; text-decoration: none; color: inherit; font-size: .85em; padding: 4px 9px; border-radius: 14px; background: rgba(0,0,0,.06); }
.resume-doc .r-social a svg { flex-shrink: 0; }

.resume-doc .r-section p { white-space: pre-line; }

.resume-doc .r-section { margin-bottom: 16px; }
.resume-doc .r-section:last-child { margin-bottom: 0; }
.resume-doc .r-section h2 { margin: 0 0 8px; }
.resume-doc .r-section.empty { display: none; }

.resume-doc .r-item { margin-bottom: 12px; }
.resume-doc .r-item:last-child { margin-bottom: 0; }
.resume-doc .r-item-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.resume-doc .r-item-role { font-weight: 700; }
.resume-doc .r-item-org { font-weight: 500; opacity: .85; }
.resume-doc .r-item-dates { font-size: .85em; opacity: .65; white-space: nowrap; }
.resume-doc .r-item-desc { margin: 4px 0 0; white-space: pre-line; font-size: .93em; opacity: .9; }

.resume-doc .r-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.resume-doc .r-tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .82em; }

/* ---------- 1. CLASSIC — строгое, ATS-дружелюбное, чёрно-белое ---------- */
.resume-doc.template-classic {
  font-family: Georgia, 'Times New Roman', serif;
  padding: 46px 52px;
}
.template-classic .r-header { display: flex; align-items: center; gap: 18px; border-bottom: 3px solid #1a1a1a; padding-bottom: 14px; margin-bottom: 18px; }
.template-classic .r-photo { width: 84px; height: 84px; border-radius: 4px; }
.template-classic .r-name { font-size: 26px; letter-spacing: .5px; }
.template-classic .r-title-text { font-size: 14px; font-style: italic; }
.template-classic .r-contact { margin-top: 6px; font-size: 12.5px; }
.template-classic .r-contact ul { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.template-classic .r-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; border-bottom: 1px solid #999; padding-bottom: 4px; }
.template-classic .r-tag { background: #eee; color: #1a1a1a; border-radius: 3px; }

/* ---------- 2. MODERN — тёмный сайдбар слева ---------- */
.resume-doc.template-modern {
  display: grid;
  grid-template-columns: 260px 1fr;
  font-family: 'Inter', Arial, sans-serif;
}
.template-modern .r-sidebar { background: #1f2937; color: #fff; padding: 36px 26px; grid-row: 1 / span 6; }
.template-modern .r-main { padding: 40px 38px; }
.template-modern .r-photo { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 18px; border: 3px solid rgba(255,255,255,.25); }
.template-modern .r-sidebar .r-contact { margin-bottom: 26px; font-size: 12.5px; word-break: break-all; }
.template-modern .r-sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: #93c5fd; margin-bottom: 10px; }
.template-modern .r-sidebar .r-tag { background: rgba(255,255,255,.12); color: #fff; }
.template-modern .r-sidebar .r-item-dates { color: rgba(255,255,255,.55); }
.template-modern .r-sidebar .r-social a { background: rgba(255,255,255,.12); }
.template-modern .r-name { font-size: 27px; color: #111827; }
.template-modern .r-title-text { color: var(--r-accent); font-size: 14px; margin-bottom: 20px; }
.template-modern .r-main .r-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.3px; color: #1f2937; border-bottom: 2px solid var(--r-accent); display: inline-block; padding-bottom: 3px; }
.template-modern .r-main .r-item-desc, .template-modern .r-main .r-item-org { color: #374151; }

/* ---------- 3. MINIMAL — много воздуха, без цвета ---------- */
.resume-doc.template-minimal {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  padding: 56px 60px;
}
.template-minimal .r-header { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.template-minimal .r-photo { width: 70px; height: 70px; border-radius: 50%; }
.template-minimal .r-name { font-size: 24px; font-weight: 300; letter-spacing: .5px; }
.template-minimal .r-title-text { font-size: 13px; letter-spacing: .5px; text-transform: uppercase; color: #666; }
.template-minimal .r-contact ul { display: flex; gap: 16px; font-size: 12px; color: #555; margin-top: 8px; }
.template-minimal .r-section { border-top: 1px solid #ddd; padding-top: 10px; margin-bottom: 22px; }
.template-minimal .r-section h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: #999; font-weight: 600; }
.template-minimal .r-tag { background: transparent; border: 1px solid #ccc; color: #444; }

/* ---------- 4. CREATIVE — цветная шапка + сайдбар ---------- */
.resume-doc.template-creative {
  font-family: 'Poppins', 'Inter', Arial, sans-serif;
}
.template-creative .r-header {
  background: linear-gradient(120deg, #0f766e, #4338ca);
  color: #fff;
  padding: 40px 42px 54px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.template-creative .r-photo { width: 96px; height: 96px; border-radius: 50%; border: 4px solid rgba(255,255,255,.5); }
.template-creative .r-name { font-size: 26px; }
.template-creative .r-title-text { font-size: 14px; opacity: .9; }
.template-creative .r-body { display: grid; grid-template-columns: 220px 1fr; }
.template-creative .r-sidebar { background: #f1f5f9; padding: 26px 22px; }
.template-creative .r-main { padding: 26px 32px; }
.template-creative .r-sidebar h2, .template-creative .r-main h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #0f766e; margin-bottom: 10px; }
.template-creative .r-sidebar .r-contact { font-size: 12px; margin-bottom: 22px; word-break: break-all; }
.template-creative .r-tag { background: #ccfbf1; color: #0f766e; }

/* ---------- 5. CORPORATE — деловой, с плашкой сверху ---------- */
.resume-doc.template-corporate {
  font-family: 'Inter', Arial, sans-serif;
}
.template-corporate .r-header {
  background: #0b2545;
  color: #fff;
  padding: 30px 46px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.template-corporate .r-photo { width: 78px; height: 78px; border-radius: 4px; }
.template-corporate .r-name { font-size: 24px; }
.template-corporate .r-title-text { font-size: 13px; color: #93c5fd; }
.template-corporate .r-contact ul { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; margin-top: 6px; color: #cbd5e1; }
.template-corporate .r-body { padding: 30px 46px; }
.template-corporate .r-section h2 { font-size: 13px; color: #0b2545; text-transform: uppercase; letter-spacing: 1px; border-left: 4px solid #0b2545; padding-left: 8px; }
.template-corporate .r-tag { background: #e2e8f0; color: #0b2545; }

/* ---------- 6. COMPACT — плотное, для длинного опыта ---------- */
.resume-doc.template-compact {
  font-family: 'Inter', Arial, sans-serif;
  font-size: 12.5px;
  padding: 34px 40px;
}
.template-compact .r-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.template-compact .r-photo { width: 60px; height: 60px; border-radius: 6px; }
.template-compact .r-name { font-size: 20px; }
.template-compact .r-title-text { font-size: 12px; color: #555; }
.template-compact .r-contact ul { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 11px; color: #555; margin-top: 4px; }
.template-compact .r-section { margin-bottom: 10px; }
.template-compact .r-section h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #111; border-bottom: 1px solid #333; padding-bottom: 2px; margin-bottom: 6px; }
.template-compact .r-item { margin-bottom: 7px; }
.template-compact .r-item-desc { font-size: .92em; }
.template-compact .r-bottom-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
.template-compact .r-tag { background: #f0f0f0; color: #222; padding: 2px 8px; font-size: .8em; }

/* ---------- 7. ELEGANT — классика с золотыми линиями, всё по центру ---------- */
.resume-doc.template-elegant { --r-accent: #a8844e; font-family: Georgia, 'Times New Roman', serif; padding: 50px 64px; color: #222; }
.template-elegant .r-header { text-align: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--r-accent); position: relative; }
.template-elegant .r-header::after { content: ''; position: absolute; left: 50%; bottom: -4px; width: 7px; height: 7px; margin-left: -3.5px; background: var(--r-accent); transform: rotate(45deg); }
.template-elegant .r-photo { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 12px; border: 2px solid var(--r-accent); padding: 3px; background: #fff; }
.template-elegant .r-photo img { border-radius: 50%; }
.template-elegant .r-name { font-size: 30px; font-weight: 400; letter-spacing: 3px; text-transform: uppercase; }
.template-elegant .r-title-text { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--r-accent); margin-top: 4px; }
.template-elegant .r-personal-meta { justify-content: center; }
.template-elegant .r-contact { margin-top: 10px; font-size: 12px; font-family: 'Inter', Arial, sans-serif; }
.template-elegant .r-contact ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.template-elegant .r-social { justify-content: center; }
.template-elegant .r-section h2 { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 400; letter-spacing: 3px; text-transform: uppercase; color: var(--r-accent); }
.template-elegant .r-section h2::before, .template-elegant .r-section h2::after { content: ''; flex: 1; height: 1px; background: #e2d6c3; }
.template-elegant .r-item-role { font-size: 14.5px; }
.template-elegant .r-item-org { font-style: italic; }
.template-elegant .r-item-desc { font-family: 'Inter', Arial, sans-serif; font-size: 12.5px; }
.template-elegant .r-section > p { font-size: 13.5px; text-align: center; }
.template-elegant .r-tags { justify-content: center; }
.template-elegant .r-tag { border: 1px solid #e2d6c3; background: #fbf8f3; color: #6b5532; font-family: 'Inter', Arial, sans-serif; }

/* ---------- 8. TIMELINE — опыт на вертикальной линии времени ---------- */
.resume-doc.template-timeline { --r-accent: #7c3aed; font-family: 'Inter', Arial, sans-serif; padding: 44px 50px; }
.template-timeline .r-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding: 20px 22px; border-radius: 16px; background: linear-gradient(120deg, #f5f3ff, #eef2ff); }
.template-timeline .r-photo { width: 86px; height: 86px; border-radius: 20px; }
.template-timeline .r-heading { flex: 1; min-width: 0; }
.template-timeline .r-name { font-size: 27px; color: #1e1b4b; letter-spacing: -.3px; }
.template-timeline .r-title-text { color: var(--r-accent); font-weight: 600; font-size: 14px; }
.template-timeline .r-contact { font-size: 12px; max-width: 230px; flex-shrink: 0; }
.template-timeline .r-section h2 { font-size: 14px; color: #1e1b4b; text-transform: uppercase; letter-spacing: 1.2px; display: flex; align-items: center; gap: 10px; }
.template-timeline .r-section h2::before { content: ''; width: 18px; height: 4px; border-radius: 4px; background: var(--r-accent); }
.template-timeline .r-section .r-item { position: relative; padding-left: 22px; margin-bottom: 0; padding-bottom: 14px; border-left: 2px solid #ddd6fe; margin-left: 6px; }
.template-timeline .r-section .r-item:last-child { padding-bottom: 2px; }
.template-timeline .r-section .r-item::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--r-accent); }
.template-timeline .r-item-dates { color: var(--r-accent); opacity: 1; font-weight: 600; }
.template-timeline .r-tag { background: #ede9fe; color: #5b21b6; }

/* ---------- 9. ASIDE — колонка навыков справа ---------- */
.resume-doc.template-aside { --r-accent: #0284c7; font-family: 'Inter', Arial, sans-serif; }
.template-aside .r-header { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: center; padding: 40px 44px 26px; border-bottom: 1px solid #e2e8f0; }
.template-aside .r-photo { width: 96px; height: 96px; border-radius: 50%; grid-row: span 2; box-shadow: 0 0 0 4px #e0f2fe; }
.template-aside .r-name { font-size: 29px; color: #0f172a; letter-spacing: -.4px; }
.template-aside .r-title-text { color: var(--r-accent); font-weight: 600; }
.template-aside .r-contact { font-size: 12px; color: #475569; }
.template-aside .r-contact ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.template-aside .r-body { display: grid; grid-template-columns: 1fr 236px; }
.template-aside .r-main { padding: 26px 30px 30px 44px; }
.template-aside .r-sidebar { background: #f0f9ff; padding: 26px 26px 30px; border-left: 1px solid #e0f2fe; }
.template-aside .r-section h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--r-accent); padding-bottom: 6px; border-bottom: 2px solid #bae6fd; }
.template-aside .r-sidebar .r-item-top { flex-direction: column; gap: 0; }
.template-aside .r-tag { background: #fff; border: 1px solid #bae6fd; color: #075985; }

/* ---------- 10. BOLD — крупное имя и яркая полоса слева ---------- */
.resume-doc.template-bold { --r-accent: #e11d48; font-family: 'Poppins', 'Inter', Arial, sans-serif; padding: 46px 52px 46px 66px; border-left: 14px solid var(--r-accent); }
.template-bold .r-header { display: flex; align-items: flex-start; gap: 22px; margin-bottom: 26px; }
.template-bold .r-photo { width: 104px; height: 104px; border-radius: 18px; order: 2; margin-left: auto; transform: rotate(3deg); box-shadow: 0 8px 20px -10px rgba(0,0,0,.45); }
.template-bold .r-heading { flex: 1; min-width: 0; }
.template-bold .r-name { font-size: 36px; line-height: 1.05; font-weight: 800; text-transform: uppercase; color: #111; letter-spacing: -.5px; }
.template-bold .r-title-text { display: inline-block; margin-top: 8px; padding: 3px 12px; background: var(--r-accent); color: #fff; border-radius: 6px; font-size: 13px; font-weight: 600; opacity: 1; }
.template-bold .r-contact { font-size: 12px; margin-top: 12px; }
.template-bold .r-contact ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.template-bold .r-header { flex-wrap: wrap; }
.template-bold .r-header > .r-contact { order: 3; flex-basis: 100%; margin-top: 0; padding-top: 12px; border-top: 1px solid #fecdd3; }
.template-bold .r-section h2 { font-size: 15px; font-weight: 800; text-transform: uppercase; color: #111; display: flex; align-items: center; gap: 10px; }
.template-bold .r-section h2::before { content: ''; width: 12px; height: 12px; background: var(--r-accent); border-radius: 3px; transform: rotate(45deg); }
.template-bold .r-item-role { font-size: 14.5px; }
.template-bold .r-item-dates { color: var(--r-accent); opacity: 1; font-weight: 700; }
.template-bold .r-tag { background: #ffe4e6; color: #9f1239; font-weight: 600; }

/* ---------- 11. EXECUTIVE — тёмная шапка, золото, две колонки ---------- */
.resume-doc.template-executive { --r-accent: #c08a3e; font-family: 'Inter', Arial, sans-serif; }
.template-executive .r-header { display: flex; align-items: center; gap: 24px; padding: 38px 46px; background: #0f172a; color: #fff; }
.template-executive .r-photo { width: 104px; height: 104px; border-radius: 50%; border: 3px solid var(--r-accent); }
.template-executive .r-name { font-size: 30px; letter-spacing: .5px; font-family: Georgia, 'Times New Roman', serif; font-weight: 700; }
.template-executive .r-title-text { color: #e9c58e; font-size: 13.5px; letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }
.template-executive .r-contact-bar { background: #f8f5ef; border-bottom: 2px solid var(--r-accent); padding: 10px 46px; font-size: 12px; color: #334155; }
.template-executive .r-contact-bar ul { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.template-executive .r-contact-bar .r-social { margin-top: 6px; }
.template-executive .r-body { display: grid; grid-template-columns: 1fr 220px; }
.template-executive .r-main { padding: 28px 30px 30px 46px; }
.template-executive .r-sidebar { padding: 28px 30px 30px 24px; border-left: 1px solid #ece4d6; }
.template-executive .r-section h2 { font-family: Georgia, 'Times New Roman', serif; font-size: 16px; color: #0f172a; border-bottom: 1px solid var(--r-accent); padding-bottom: 4px; }
.template-executive .r-sidebar .r-item-top { flex-direction: column; gap: 0; }
.template-executive .r-item-dates { color: #8a6a3a; opacity: 1; }
.template-executive .r-tag { background: #f8f5ef; color: #5a4220; border: 1px solid #ece4d6; border-radius: 4px; }

/* ---------- 12. TECH — для IT: моноширинный акцент, «код»-заголовки ---------- */
.resume-doc.template-tech { --r-accent: #059669; font-family: 'Inter', Arial, sans-serif; padding: 44px 50px; color: #0f172a; }
.template-tech .r-header { display: flex; align-items: center; gap: 18px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 2px dashed #a7f3d0; }
.template-tech .r-photo { width: 80px; height: 80px; border-radius: 12px; border: 2px solid var(--r-accent); }
.template-tech .r-heading { flex: 1; min-width: 0; }
.template-tech .r-name { font-family: 'Courier New', Consolas, monospace; font-size: 28px; }
.template-tech .r-name::before { content: '> '; color: var(--r-accent); }
.template-tech .r-title-text { font-family: 'Courier New', Consolas, monospace; color: var(--r-accent); font-weight: 700; font-size: 14px; }
.template-tech .r-contact { font-size: 12px; max-width: 240px; flex-shrink: 0; font-family: 'Courier New', Consolas, monospace; }
.template-tech .r-section h2 { font-family: 'Courier New', Consolas, monospace; font-size: 15px; color: #0f172a; }
.template-tech .r-section h2::before { content: '// '; color: var(--r-accent); }
.template-tech .r-item { padding: 10px 14px; border-radius: 10px; background: #f8fafc; border: 1px solid #e2e8f0; }
.template-tech .r-item-dates { font-family: 'Courier New', Consolas, monospace; color: var(--r-accent); opacity: 1; }
.template-tech .r-tag { font-family: 'Courier New', Consolas, monospace; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; border-radius: 6px; }

/* Печать / PDF: без теней и границ страницы */
@media print {
  .resume-doc { box-shadow: none !important; }
}

/* Длинные слова/ссылки без пробелов (например «ffffffff…» или длинный URL)
   переносятся, а не вылезают за край листа — в превью, PDF и мини-превью. */
.resume-doc,
.resume-doc p,
.resume-doc .r-name,
.resume-doc .r-title-text,
.resume-doc .r-item-role,
.resume-doc .r-item-org,
.resume-doc .r-item-desc,
.resume-doc .r-tag,
.resume-doc .r-contact a,
.resume-doc .r-social a span { overflow-wrap: anywhere; word-break: break-word; }
.resume-doc .r-item-top > div,
.resume-doc .r-heading,
.resume-doc .r-main,
.resume-doc .r-sidebar,
.resume-doc .r-section { min-width: 0; max-width: 100%; }
.resume-doc .r-tag { max-width: 100%; }
.resume-doc .r-item-dates { flex-shrink: 0; }

/* Имя, должность и заголовки переносятся только по словам (не «Константинопол-ьская»);
   разрыв внутри слова — лишь если слово длиннее всей строки. */
.resume-doc .r-name,
.resume-doc .r-title-text,
.resume-doc .r-item-role,
.resume-doc .r-item-org,
.resume-doc .r-section h2 { overflow-wrap: break-word; word-break: normal; hyphens: manual; }
/* Шапки «фото + имя + контакты в ряд»: если места мало, контакты уходят на новую строку */
.template-classic .r-header, .template-timeline .r-header, .template-tech .r-header { flex-wrap: wrap; }
.template-classic .r-heading { flex: 1 1 300px; min-width: 0; }
.template-classic .r-contact { flex: 1 1 250px; min-width: 0; }
.template-timeline .r-contact, .template-tech .r-contact { flex: 0 1 240px; min-width: 200px; }

/* Модерн: отступ между шапкой (с датой рождения/полом) и первым разделом */
.template-modern .r-title-text { margin-bottom: 0; }
.template-modern .r-main > .r-heading { margin-bottom: 22px; }

