/* ============================================================
   Resume Builder — uaejobnest.com
   Uses the site's existing design tokens (variables.css). Only this
   page's own layout + the three CV templates live here — nothing
   global is touched.
   ============================================================ */

.rb-wrap { padding: var(--sp-6) 0 var(--sp-8); }

.rb-head { max-width: 680px; margin: 0 auto var(--sp-6); text-align: center; }
.rb-head h1 { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--text-heading); margin: var(--sp-3) 0 var(--sp-2); }
.rb-head p { color: var(--text-secondary); font-size: var(--fs-base); margin: 0; }
.rb-badge {
  display: inline-block; background: var(--color-teal-100); color: var(--color-teal-600);
  font-size: var(--fs-xs); font-weight: 600; padding: 4px 14px; border-radius: var(--radius-pill);
}

/* ---- Progress steps ------------------------------------------ */
.rb-progress { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: var(--sp-5); }
.rb-progress button {
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary);
  font-size: var(--fs-xs); font-weight: 600; padding: 6px 12px; border-radius: var(--radius-pill);
  cursor: pointer; transition: var(--transition-fast);
}
.rb-progress button.is-active { background: var(--color-teal); border-color: var(--color-teal); color: #fff; }
.rb-progress button.is-done { border-color: var(--color-teal); color: var(--color-teal); }

/* ---- Layout ---------------------------------------------------- */
.rb-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.rb-panel {
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  padding: var(--sp-6); box-shadow: var(--shadow-sm);
}
.rb-step { display: none; }
.rb-step.is-active { display: block; }
.rb-step h2 { font-family: var(--font-display); font-size: var(--fs-lg); margin: 0 0 4px; color: var(--text-heading); }
.rb-hint { color: var(--text-muted); font-size: var(--fs-sm); margin: 0 0 var(--sp-4); }

.rb-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.rb-field { margin-bottom: var(--sp-4); }
.rb-field label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.rb-req { color: var(--color-error); }
.rb-opt { color: var(--text-muted); font-weight: 400; }
.rb-field input, .rb-field select, .rb-field textarea {
  width: 100%; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg);
  color: var(--input-text); font-family: var(--font-body); font-size: var(--fs-base); padding: 10px 12px;
}
.rb-field input:focus, .rb-field select:focus, .rb-field textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.rb-field textarea { resize: vertical; }
.rb-help { display: block; color: var(--text-muted); font-size: var(--fs-xs); margin-top: 4px; }
.rb-field.has-error input, .rb-field.has-error textarea { border-color: var(--color-error); }
.rb-error-msg { color: var(--color-error); font-size: var(--fs-xs); margin-top: 4px; }

/* ---- Buttons ---------------------------------------------------- */
.rb-btn {
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-sm); border-radius: var(--radius-sm);
  padding: 10px 18px; cursor: pointer; border: 1px solid transparent; transition: var(--transition-fast);
}
.rb-btn-primary { background: var(--color-primary); color: var(--color-primary-text); }
.rb-btn-primary:hover { background: var(--color-primary-hover); }
.rb-btn-outline { background: transparent; border-color: var(--border-default); color: var(--text-primary); }
.rb-btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.rb-btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.rb-btn-lg { padding: 14px 28px; font-size: var(--fs-base); }
.rb-btn-danger { background: transparent; color: var(--color-error); border: none; padding: 4px 8px; }

.rb-nav { display: flex; justify-content: space-between; margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border-default); }

/* ---- Repeatable entry cards (experience/education/lang/cert) ---- */
.rb-entry {
  border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--sp-4); margin-bottom: var(--sp-4);
  position: relative; background: var(--bg-page);
}
.rb-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.rb-entry-head strong { font-size: var(--fs-sm); color: var(--text-secondary); }
.rb-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); margin: var(--sp-2) 0; }
.rb-empty-hint { color: var(--text-muted); font-size: var(--fs-sm); padding: var(--sp-3) 0; }

/* ---- Tag inputs (skills) ----------------------------------------- */
.rb-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-3); }
.rb-tag {
  display: inline-flex; align-items: center; gap: 6px; background: var(--color-teal-100); color: var(--color-teal-600);
  border-radius: var(--radius-pill); padding: 6px 10px 6px 14px; font-size: var(--fs-sm);
}
.rb-tag button { border: none; background: none; color: inherit; cursor: pointer; font-size: var(--fs-md); line-height: 1; }
.rb-tag-add { display: flex; gap: 8px; }
.rb-tag-add input { flex: 1; }

/* ---- Photo upload ---------------------------------------------- */
.rb-photo-row { display: flex; gap: var(--sp-4); align-items: center; }
.rb-photo-preview {
  width: 72px; height: 72px; border-radius: 50%; background: var(--bg-page) center/cover no-repeat;
  border: 1px solid var(--border-default); flex-shrink: 0;
}

/* ---- Template chooser -------------------------------------------- */
.rb-template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-5); }
.rb-template-opt {
  border: 2px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface);
  padding: var(--sp-3); cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.rb-template-opt.is-selected { border-color: var(--color-teal); color: var(--color-teal-600); }
.rb-template-swatch { width: 100%; height: 46px; border-radius: 6px; display: block; }
.tpl-classic-swatch { background: linear-gradient(180deg, #0D1B2A 0 30%, #fff 30%); }
.tpl-modern-swatch { background: linear-gradient(90deg, #0A5F6A 0 30%, #fff 30%); }
.tpl-minimal-swatch { background: #fff; border: 1px solid var(--border-default); }

.rb-download-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.rb-privacy-note { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--sp-3); }

/* ---- Live preview column ------------------------------------------ */
.rb-preview-col { position: sticky; top: var(--sp-4); }
.rb-preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.rb-preview-toolbar h3 { font-size: var(--fs-base); margin: 0; color: var(--text-secondary); }
.rb-preview-close { display: none; background: none; border: none; color: var(--color-teal); font-weight: 600; cursor: pointer; }
.rb-preview-frame { max-height: 82vh; overflow-y: auto; border-radius: var(--radius-md); background: #dfe3e8; padding: var(--sp-4); }

/* Sized by JS (updatePreviewFitScale in resume-builder.js) to exactly
   match #cvPage's true size × the current fit scale, so the scaled
   page never leaves extra blank space or gets clipped inside it. */
.cv-page-viewport { position: relative; margin: 0 auto; overflow: hidden; }

/* The CV page itself — this is exactly what gets printed. Its size is
   always the true A4 size (210mm x 297mm), on every screen size; JS
   scales #cvPage visually (via transform) to fit the column, and
   never changes these dimensions, so "one page" always really means
   one page, on screen and in the downloaded PDF. See --cv-scale
   below for how content is auto-shrunk to fit inside this fixed
   height instead of overflowing it. */
.cv-page {
  --cv-scale: 1;
  position: absolute; top: 0; left: 0; transform-origin: top left;
  width: 210mm; height: 297mm; background: #fff; color: #1a1a1a;
  box-shadow: var(--shadow-lg); padding: 16mm 14mm; box-sizing: border-box;
  overflow: hidden; font-family: Georgia, 'Times New Roman', serif;
}
.cv-empty { color: #9aa0a6; font-size: 13px; text-align: center; padding-top: 40%; }

.cv-name { font-size: calc(26px * var(--cv-scale)); font-weight: 700; margin: 0; }
.cv-title { font-size: calc(14px * var(--cv-scale)); color: #0A5F6A; margin: calc(2px * var(--cv-scale)) 0 calc(10px * var(--cv-scale)); font-weight: 600; }
.cv-contact { font-size: calc(11px * var(--cv-scale)); color: #444; margin-bottom: calc(16px * var(--cv-scale)); }
.cv-contact span { margin-right: 10px; }
.cv-section { margin-bottom: calc(14px * var(--cv-scale)); }
.cv-section h3 {
  font-size: calc(12px * var(--cv-scale)); text-transform: uppercase; letter-spacing: 1px; color: #0A5F6A;
  border-bottom: 1px solid #ccc; padding-bottom: calc(3px * var(--cv-scale)); margin: 0 0 calc(8px * var(--cv-scale));
}
.cv-summary { font-size: calc(12.5px * var(--cv-scale)); line-height: 1.5; }
.cv-item { margin-bottom: calc(10px * var(--cv-scale)); }
.cv-item-head { display: flex; justify-content: space-between; font-size: calc(12.5px * var(--cv-scale)); font-weight: 700; }
.cv-item-sub { font-size: calc(11.5px * var(--cv-scale)); color: #555; margin-bottom: calc(3px * var(--cv-scale)); }
.cv-item-desc { font-size: calc(11.5px * var(--cv-scale)); line-height: 1.45; white-space: pre-line; }
.cv-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-skill-pill { font-size: calc(11px * var(--cv-scale)); background: #eef2f3; border-radius: 4px; padding: 3px 8px; }
.cv-photo { width: calc(70px * var(--cv-scale)); height: calc(70px * var(--cv-scale)); border-radius: 50%; object-fit: cover; float: right; }

/* Classic: centered header, serif */
.tpl-classic .cv-name, .tpl-classic .cv-title { text-align: center; }
.tpl-classic .cv-contact { text-align: center; }

/* Modern: sans-serif, colored section bands, single column (kept
   single-column deliberately — this is what the printed PDF
   reproduces exactly, page-break issues and all avoided) */
.tpl-modern { font-family: 'Inter', Arial, sans-serif; }
.tpl-modern .cv-header { border-left: 5px solid #0A5F6A; padding-left: 12px; margin-bottom: calc(16px * var(--cv-scale)); }
.tpl-modern .cv-section h3 { color: #fff; background: #0A5F6A; padding: 4px 8px; border: none; }

/* Keep list/section items from being awkwardly split if content ever
   sits right at the one-page limit — belt-and-suspenders alongside
   the --cv-scale auto-fit above. */
.cv-item, .cv-section { break-inside: avoid; page-break-inside: avoid; }

/* Minimal ATS: plain, no color, single column, no photo */
.tpl-minimal { font-family: Arial, Helvetica, sans-serif; }
.tpl-minimal .cv-section h3 { color: #000; border-bottom: 1px solid #000; text-transform: none; letter-spacing: 0; }
.tpl-minimal .cv-title { color: #000; }
.tpl-minimal .cv-photo { display: none; }
.tpl-minimal .cv-skill-pill { background: none; border: 1px solid #ccc; }

.rb-preview-fab {
  display: none; position: fixed; bottom: var(--sp-4); right: var(--sp-4); z-index: 40;
  background: var(--color-primary); color: #fff; border: none; border-radius: var(--radius-pill);
  padding: 12px 22px; font-weight: 600; box-shadow: var(--shadow-md); cursor: pointer;
}

.rb-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--color-navy); color: #fff; padding: 10px 20px; border-radius: var(--radius-pill);
  font-size: var(--fs-sm); opacity: 0; pointer-events: none; transition: var(--transition-base); z-index: 60;
}
.rb-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Mobile --------------------------------------------------------
   Scoped to "screen" only: this must never leak into the print/"Save
   as PDF" output (a plain max-width query without a media type can
   otherwise match the print page's width too, in some browsers). */
@media screen and (max-width: 980px) {
  .rb-grid { grid-template-columns: 1fr; }
  .rb-row { grid-template-columns: 1fr; }
  .rb-preview-col {
    position: fixed; inset: 0; z-index: 50; background: #dfe3e8; padding: var(--sp-4);
    overflow-y: auto; transform: translateX(100%); transition: transform var(--transition-base); display: none;
  }
  .rb-preview-col.is-open { display: block; transform: translateX(0); }
  .rb-preview-close { display: block; }
  .rb-preview-fab { display: block; }
  /* .cv-page itself stays at its true 210mm x 297mm size on every
     screen size — JS (updatePreviewFitScale) scales it down visually
     to fit here, same as on desktop, instead of this stylesheet
     redefining the page as a different, non-A4 size. */
  .rb-template-grid { grid-template-columns: 1fr; }
  /* Download/Print/Start-over: stack full-width and roomy so they're
     easy, unambiguous thumb targets instead of three squeezed
     side-by-side buttons. */
  .rb-download-row { flex-direction: column; }
  .rb-download-row .rb-btn { width: 100%; min-height: 48px; }
}

/* ---- Print / "Download PDF" ---------------------------------------
   The Download button calls window.print() on the already-rendered
   #cvPage — this is a real, native, vector PDF via the browser's own
   "Save as PDF" destination, not a screenshot.

   Right before printing, printResume() in resume-builder.js moves
   #cvPage out to be the only element directly under <body> (and adds
   the .rb-printing class below), then puts everything back once the
   print dialog closes. That — not visibility:hidden — is what keeps
   the site header/nav/footer/form panel out of the PDF: an element
   set to visibility:hidden is invisible but still reserves its full
   height in the page, and it was exactly that reserved-but-invisible
   height (from the rest of the site around the builder) spilling
   past one A4 page that produced the blank extra page on download.
   display:none removes an element from layout entirely, so nothing
   is left to overflow onto a second page.

   #cvPage itself always has a fixed 297mm height, and resume-
   builder.js auto-shrinks its type size (the --cv-scale variable) so
   the content fits inside that one page — that's what keeps the
   resume itself to a single page. */
.rb-print-watermark { display: none; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; height: auto !important; }
  body.rb-printing > *:not(#cvPage):not(.rb-print-watermark) { display: none !important; }
  #cvPage {
    position: absolute; left: 0; top: 0; margin: 0; box-shadow: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; color-adjust: exact;
  }
  .rb-print-watermark {
    display: block !important; position: fixed; bottom: 6mm; right: 8mm;
    font-size: 8pt; color: #999999; z-index: 9999;
  }
}

/* ---- Touch targets (phones / small tablets) ----------------------
   .rb-btn ~44px, .rb-btn-sm ~33px, .rb-btn-danger (Remove) ~27px and the
   preview "Close" text button ~22px tall — all brought to 44px so they're
   easy to hit with a thumb. Desktop sizes are unchanged. */
@media screen and (max-width: 980px) {
  .rb-btn { min-height: 44px; }
  .rb-btn-danger { padding: 8px 12px; }
  .rb-preview-close { min-height: 44px; padding: 0 12px; }
}
