/**
 * CV / Résumé Builder — split-pane live preview layout.
 * Scoped under .cv-* so it never fights the global design system in style.css.
 * Tokens match :root in style.css (--navy, --teal, --gold, --grey-*, --radius).
 */

.cv-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 1.25rem;
  align-items: start;
}

.cv-editor { min-width: 0; }

.cv-preview-pane {
  position: sticky;
  top: 1rem;
  background: var(--grey-100);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  box-shadow: var(--shadow);
}

.cv-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem 1rem;
  background: var(--navy);
  color: var(--white);
  font-size: .8rem;
  font-weight: 600;
}

.cv-preview-toolbar .cv-live-total {
  color: var(--teal-bright);
}

.cv-preview-scroll {
  overflow: auto;
  padding: 1rem;
  flex: 1;
}

.cv-preview-paper {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.1rem;
  min-height: 420px;
}

.cv-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin: 0 0 .55rem;
}

.cv-pro-link {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--teal);
  text-decoration: none;
}

.cv-pro-link:hover,
.cv-pro-link:focus-visible {
  text-decoration: underline;
}

.cv-pro-link:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cv-theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
}

.cv-theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .35rem;
  padding: .45rem;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.cv-theme-swatch:hover {
  border-color: var(--teal);
}

.cv-theme-swatch:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cv-theme-swatch.is-active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 110, 86, 0.18);
}

.cv-theme-swatch.is-locked {
  opacity: .72;
}

.cv-theme-swatch__chip {
  display: block;
  height: 28px;
  border-radius: calc(var(--radius) - 1px);
  background: linear-gradient(110deg, var(--swatch) 0 55%, var(--swatch2) 55% 100%);
}

.cv-theme-swatch__name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}

.cv-font-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.cv-font-chip {
  border: 1.5px solid var(--grey-200);
  background: var(--white);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  color: var(--navy);
  transition: border-color var(--transition), background var(--transition);
}

.cv-font-chip:hover {
  border-color: var(--teal);
}

.cv-font-chip:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cv-font-chip.is-active {
  border-color: var(--teal);
  background: #f0fdf9;
  font-weight: 600;
}

.cv-font-chip.is-locked { opacity: .7; }

.cv-pro-pill {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  font-size: .65rem;
  font-weight: 700;
  color: var(--gold);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: .05rem .35rem;
  letter-spacing: 0;
  text-transform: none;
}

.cv-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.cv-items-table th {
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--grey-500);
  padding: .35rem .35rem .45rem;
  border-bottom: 1px solid var(--grey-200);
}

.cv-items-table td {
  padding: .3rem .25rem;
  vertical-align: middle;
}

.cv-items-table .form-input {
  width: 100%;
  font-size: .85rem;
  padding: .45rem .55rem;
}

.cv-row-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--red);
  cursor: pointer;
  padding: .35rem;
  border-radius: var(--radius);
  line-height: 0;
}

.cv-row-del svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

.cv-row-del:hover {
  background: #fef2f2;
}

.cv-row-del:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Status labels — colour + word (never colour alone). */
.cv-status {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.cv-status--draft { background: var(--grey-100); color: var(--grey-600); }
.cv-status--sent { background: #e0f2fe; color: #0369a1; }
.cv-status--paid,
.cv-status--accepted { background: #dcfce7; color: #166534; }
.cv-status--overdue,
.cv-status--declined { background: #fee2e2; color: #991b1b; }
.cv-status--closed { background: var(--grey-200); color: var(--grey-600); }

/* Logo crop modal */
.cv-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 43, 79, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cv-crop-modal[hidden] { display: none !important; }

.cv-crop-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.cv-crop-dialog h3 {
  margin: 0 0 .35rem;
  color: var(--navy);
  font-size: 1.05rem;
}

.cv-crop-dialog p {
  margin: 0 0 .85rem;
  font-size: .85rem;
  color: var(--grey-500);
}

.cv-crop-canvas {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
  background: var(--grey-800);
}

.cv-crop-canvas:active { cursor: grabbing; }

.cv-crop-zoom {
  width: 100%;
  margin: .85rem 0 1rem;
}

.cv-crop-actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.cv-photo-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.cv-photo-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: 50%;
}

/* ── Section list: reorder, rename, hide ───────────────────────────────── */

.cv-hint {
  font-size: .75rem;
  color: var(--grey-500);
  line-height: 1.5;
  margin: .35rem 0 0;
}

.cv-sections {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.cv-sections__row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  border-bottom: 1px solid var(--grey-100, #f1f5f9);
  background: var(--white);
}

.cv-sections__row:last-child { border-bottom: 0; }
.cv-sections__row.is-off { background: var(--grey-50, #f8fafc); opacity: .6; }

.cv-sections__move { display: inline-flex; flex: 0 0 auto; gap: .15rem; }

.cv-sections__btn {
  border: 1px solid var(--grey-200);
  background: var(--white);
  color: var(--grey-600);
  border-radius: 4px;
  width: 1.55rem;
  height: 1.55rem;
  line-height: 1;
  cursor: pointer;
  font-size: .8rem;
}

.cv-sections__btn:hover { background: var(--grey-50, #f8fafc); color: var(--navy); }

.cv-sections__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .82rem;
  padding: .3rem .5rem;
}

.cv-sections__show {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .75rem;
  color: var(--grey-600);
  cursor: pointer;
}

.cv-sections__show input { width: .95rem; height: .95rem; }

/* Estimated page count in the preview toolbar. */
.cv-page-count {
  font-size: .72rem;
  color: var(--grey-500);
  font-weight: 500;
}
.cv-page-count.is-long { color: #b45309; }

/* ── "Start from your CV" import panel ─────────────────────────────────── */

.cv-import {
  margin: 0 0 1.25rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: var(--grey-50, #f8fafc);
}

.cv-import[open] { background: var(--white); }
.cv-import.is-busy { opacity: .6; pointer-events: none; }

.cv-import__summary {
  cursor: pointer;
  padding: .8rem 1rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .88rem;
  color: var(--navy);
}

.cv-import__summary::-webkit-details-marker { display: none; }
.cv-import__summary::after {
  content: "▾";
  position: absolute;
  right: 1rem;
  color: var(--grey-500);
}
.cv-import__summary { position: relative; }
.cv-import[open] .cv-import__summary::after { content: "▴"; }
.cv-import__summary span { font-size: .8rem; color: var(--grey-600); font-weight: 400; }

.cv-import__body { padding: 0 1rem 1rem; }

.cv-import__drop {
  border: 2px dashed var(--grey-300, #cbd5e1);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.cv-import__drop.is-over {
  border-color: var(--teal);
  background: #f0fdfa;
}

.cv-import__drop p { margin: 0 0 .5rem; font-size: .85rem; color: var(--grey-700); }

/* The real input is hidden but still focusable — the <label> is the control. */
.cv-import__file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.cv-import__hint { font-size: .75rem; color: var(--grey-500); margin: .6rem 0 0 !important; }
.cv-import__hint code { font-size: .72rem; }

.cv-import__or {
  text-align: center;
  margin: .9rem 0;
  border-top: 1px solid var(--grey-200);
  line-height: 0;
}
.cv-import__or span {
  background: var(--white);
  padding: 0 .6rem;
  font-size: .75rem;
  color: var(--grey-500);
  line-height: 1;
  display: inline-block;
}

.cv-import__privacy {
  font-size: .75rem;
  color: var(--grey-500);
  margin: .75rem 0 0;
  line-height: 1.5;
}

.cv-import__status {
  margin-top: .75rem;
  padding: .55rem .8rem;
  border-radius: var(--radius);
  font-size: .82rem;
  border: 1px solid var(--grey-200);
  background: var(--grey-50, #f8fafc);
  color: var(--grey-700);
}
.cv-import__status.is-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.cv-import__status.is-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.cv-import__status.is-busy { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.cv-import__notes { margin-top: .6rem; }

.cv-import__warn {
  font-size: .8rem;
  line-height: 1.5;
  color: var(--grey-700);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid #d97706;
  border-radius: var(--radius);
  padding: .55rem .8rem;
  margin: 0 0 .5rem;
}

.cv-import__unplaced summary {
  cursor: pointer;
  font-size: .8rem;
  color: var(--teal);
  font-weight: 600;
}
.cv-import__unplaced ul {
  margin: .5rem 0 0;
  padding-left: 1.1rem;
  max-height: 190px;
  overflow-y: auto;
  font-size: .78rem;
  color: var(--grey-600);
  line-height: 1.6;
}

/* A field the importer filled — cleared the moment the user edits it. */
.form-input.is-imported,
textarea.form-input.is-imported {
  background: #fffdf5;
  border-color: #fbbf24;
}

/* Parse-risk note under the theme picker — shown for any non-ATS layout. */
.cv-ats-note {
  margin: .75rem 0 0;
  padding: .65rem .85rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid #d97706;
  border-radius: var(--radius);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--grey-700);
}

.cv-ats-note[hidden] { display: none; }

.cv-complete {
  margin: .75rem 0 0;
  padding: .65rem .85rem;
  background: var(--grey-50, #f8fafc);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--grey-600);
}

.cv-complete__bar {
  height: 6px;
  background: var(--grey-200);
  border-radius: 3px;
  margin: .4rem 0 .35rem;
  overflow: hidden;
}

.cv-complete__fill {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
  transition: width .25s ease;
}

.cv-status--active { background: #dcfce7; color: #166534; }
.cv-status--archived { background: var(--grey-200); color: var(--grey-600); }

.cv-share {
  display: inline-block;
  position: relative;
}

.cv-share > summary {
  list-style: none;
  cursor: pointer;
}

.cv-share > summary::-webkit-details-marker { display: none; }

.cv-share-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 5;
  margin-top: .25rem;
  min-width: 8.5rem;
  padding: .45rem .55rem;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 43, 79, 0.12));
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-items: stretch;
}

.cv-share-menu a,
.cv-share-menu button {
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
  color: var(--teal);
  background: none;
  border: 0;
  padding: .15rem 0;
  cursor: pointer;
  text-decoration: none;
}

.cv-status-form { margin: 0; }

.cv-status-select {
  font-size: .78rem;
  padding: .25rem .4rem;
  border-radius: var(--radius);
  border: 1px solid var(--grey-200);
  background: var(--white);
  color: var(--navy);
  max-width: 9rem;
}

.cv-doc-link {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
}

.cv-doc-link:hover { text-decoration: underline; }

.cv-doc-link:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cv-doc-link--danger { color: var(--red); }

.cv-doc-sep { color: var(--grey-200); }

@media (max-width: 959px) {
  .cv-builder {
    grid-template-columns: 1fr;
  }
  .cv-preview-pane {
    position: relative;
    top: 0;
    max-height: none;
    order: -1;
  }
  .cv-preview-scroll {
    max-height: 420px;
  }
  .cv-theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* "Include my completed TradeCaravan courses" — the tick box above the
   Courses repeater. Only rendered when the learner actually has a certificate,
   so it never appears as a control that would do nothing. */
.cv-tc-courses {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  padding: .7rem .8rem;
  margin: 0 0 .7rem;
  border: 1px solid #A7F3D0;
  border-radius: 8px;
  background: #ECFDF5;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1.45;
}
.cv-tc-courses input[type="checkbox"] {
  margin: .18rem 0 0;
  flex: none;
  width: 16px;
  height: 16px;
  accent-color: #0F6E56;
  cursor: pointer;
}
.cv-tc-courses strong { display: block; color: #0F2B4F; }
.cv-tc-courses-note {
  display: block;
  margin-top: .18rem;
  color: #475569;
  font-size: .82rem;
}
