/* ===== Resume Builder — NewVisual ===== */
:root {
  --bg: #0f1420;
  --panel: #161d2c;
  --panel-2: #1b2434;
  --border: #29344a;
  --text: #e6ebf5;
  --muted: #93a1bd;
  --brand: #2f9bb3;      /* teal, matches resume accent */
  --brand-ink: #1f7d92;
  --danger: #d05a5a;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  /* Resume (print) palette */
  --r-accent: #1f7d92;
  --r-text: #1a1a1a;
  --r-muted: #555;
  --r-rule: #cfd6dd;
  --r-font: "Calibri", "Segoe UI", Candara, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font-ui); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.home-link { color: var(--muted); text-decoration: none; font-size: 20px; line-height: 1; }
.home-link:hover { color: var(--text); }
.brand { font-weight: 700; letter-spacing: .02em; }
.save-state { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; }
.save-state.dirty { color: #e6b45a; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 14px; cursor: pointer; transition: .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--brand-ink); border-color: var(--brand); }

.btn {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; transition: .12s;
}
.btn:hover { border-color: var(--brand); background: #202a3d; }
.btn-primary { background: var(--brand-ink); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); }
.btn-wide { width: 100%; padding: 10px; }
.btn-mini { font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.btn-danger:hover { border-color: var(--danger); color: #ffb4b4; }

/* ---------- Layout ---------- */
/* Editor is the primary work surface (large); preview is a small,
   scaled-to-fit verification thumbnail on the right. */
.layout { display: grid; grid-template-columns: 1fr 560px; height: calc(100vh - 55px); }
.editor { overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg); }
.over-banner {
  position: sticky; top: 0; z-index: 5;
  background: #4a1f24; border-bottom: 1px solid #7a3a40; color: #ffd0d0;
  font-size: 13px; font-weight: 600; padding: 10px 22px; text-align: center;
}
.over-banner strong { color: #fff; }
.editor-inner { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }

/* tab panel container */
#tabPanel { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }
.panel-hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: -2px 0 4px; }

/* resume switcher */
.resume-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.resume-chip {
  font-family: inherit; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; color: var(--text); transition: .12s; min-width: 120px;
  display: flex; flex-direction: column; gap: 2px;
}
.resume-chip:hover { border-color: var(--brand); }
.resume-chip.active { border-color: var(--brand); background: #17303a; box-shadow: 0 0 0 1px var(--brand) inset; }
.resume-chip .rc-name { font-weight: 700; font-size: 13px; }
.resume-chip .rc-role { font-size: 11px; color: var(--muted); }
.resume-actions { display: flex; gap: 8px; }

/* include pickers */
.pick-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.pick-group:last-child { margin-bottom: 0; }
.pick-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 2px 0; }
.pick-row {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 9px; cursor: pointer;
}
.pick-row.muted { opacity: .72; }
.pick-row.muted:hover { opacity: 1; }
.pick-row input[type="checkbox"], .pick-row input[type="radio"] { width: 15px; height: 15px; accent-color: var(--brand); flex: none; cursor: pointer; }
.pick-row .pick-name { flex: 1; font-size: 12.5px; color: var(--text); }
.pick-meta { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.pick-meta .pick-name { font-weight: 600; }
.pick-meta .pick-sub { font-size: 11px; color: var(--muted); }

/* section order rows */
.order-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
}
.order-row .order-name { flex: 1; font-size: 12.5px; }

/* foot actions */
.foot-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.foot-actions .btn { flex: 1; min-width: 160px; padding: 10px; }

/* AI Assist */
.ai-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.ai-steps li { font-size: 13px; line-height: 1.5; color: var(--text); }
.prompt-box {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; max-height: 220px; overflow-y: auto;
}
.prompt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.prompt-actions .btn { padding: 9px 14px; }

/* selectable section rows */
.ai-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; margin-bottom: 6px; transition: border-color .12s, background .12s; }
.ai-row:hover { border-color: var(--brand); }
.ai-row.active { border-color: var(--brand); background: #17303a; box-shadow: 0 0 0 1px var(--brand) inset; }
.ai-row-jd { border-left: 3px solid var(--brand-ink); }
.ai-row-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ai-row-snip { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-row-snip.empty { font-style: italic; opacity: .6; }

/* big right-hand editor (replaces resume preview on the AI tab) */
.ai-pane { display: none; flex: 1; min-height: 0; width: 100%; flex-direction: column; gap: 10px; }
body.ai-active .preview-head { display: none; }
body.ai-active .page-holder { display: none; }
body.ai-active .ai-pane { display: flex; }
body.ai-active .preview-wrap { align-items: stretch; padding: 16px; }
.ai-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ai-pane-title { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .01em; }
.ai-pane-ta {
  flex: 1; width: 100%; resize: none; font-family: inherit; font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px;
}
.ai-pane-ta:focus { outline: none; border-color: var(--brand); }

/* ATS guide */
.ats-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.ats-list li { font-size: 13px; line-height: 1.5; color: var(--text); }

/* library-insert modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 520px; max-height: 80vh; overflow-y: auto; padding: 18px 20px; }
.modal-title { font-size: 15px; margin-bottom: 12px; color: var(--text); }
.modal-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; margin: 12px 0 5px; }
.modal-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); margin-bottom: 6px; }
.modal-row .modal-name { flex: 1; font-size: 12.5px; }
.modal-close { margin-top: 14px; width: 100%; padding: 9px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--brand-ink); color: #fff; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 999px; box-shadow: 0 6px 24px rgba(0,0,0,.4); opacity: 0; transition: opacity .25s, transform .25s; z-index: 120; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Disabled add buttons when content overflows one page */
.btn.js-add:disabled { opacity: .4; cursor: not-allowed; }
.btn.js-add:disabled:hover { border-color: var(--border); background: var(--panel-2); }
.editor-foot { padding: 0 24px 28px; }

.preview-wrap { overflow-y: auto; background: #3f4658; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 2px 4px; }
.preview-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #c7d0e2; font-weight: 700; }
.page-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.page-badge.ok { color: #b8f0cf; background: rgba(40,120,70,.35); border: 1px solid rgba(90,200,140,.5); }
.page-badge.over { color: #ffd0d0; background: rgba(150,50,50,.4); border: 1px solid rgba(230,110,110,.6); }

/* scaled thumbnail: JS sizes the holder to the scaled dimensions and
   applies the scale transform to the scaler */
.page-holder { position: relative; }
.page-scaler { transform-origin: top left; }

/* ---------- Editor blocks ---------- */
.block {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--panel-2); border-bottom: 1px solid transparent; cursor: pointer;
  transition: background .15s ease;
}
.block-head:hover { background: #202b3e; }
.block:not(.collapsed) .block-head { border-bottom-color: var(--border); }
.block-head .caret {
  color: var(--muted); font-size: 10px; width: 14px; text-align: center; user-select: none;
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
}
.block.collapsed .caret { transform: rotate(-90deg); }
.block-head .sec-title {
  flex: 1; font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px;
}
.block-head .sec-title:focus { outline: none; border-color: var(--border); background: var(--bg); }
.block-head .move { color: var(--muted); cursor: pointer; user-select: none; font-size: 13px; padding: 1px 3px; border-radius: 4px; transition: color .12s, background .12s; }
.block-head .move:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* smooth collapse/expand via animated grid row (0fr <-> 1fr) */
.block-body-wrap {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows .26s cubic-bezier(.4, 0, .2, 1);
}
.block.collapsed .block-body-wrap { grid-template-rows: 0fr; }
.block-body {
  overflow: hidden; min-height: 0;
  padding: 9px 10px; display: flex; flex-direction: column; gap: 7px;
  transition: opacity .2s ease, padding .26s cubic-bezier(.4, 0, .2, 1);
}
.block.collapsed .block-body { opacity: 0; padding-top: 0; padding-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 2px; }
.field label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
input.inp, textarea.inp {
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; width: 100%; line-height: 1.4;
}
input.inp:focus, textarea.inp:focus { outline: none; border-color: var(--brand); }
/* auto-grow textareas: start at one line, grow with content (sized via JS) */
textarea.inp { resize: none; overflow: hidden; min-height: 32px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

/* nested items sit indented under their group label, with a left accent */
.block-body > .item {
  margin-left: 14px;
  border-left: 3px solid var(--brand-ink);
  border-top-left-radius: 4px; border-bottom-left-radius: 4px;
}
.item {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px 8px 10px; background: var(--panel-2);
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.block-body > .item:hover {
  border-color: var(--border); border-left-color: var(--brand);
  box-shadow: 0 1px 8px rgba(0,0,0,.25);
}
/* item header: label + tools on ONE line */
.item-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.item-bar .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.item-tools { display: flex; gap: 3px; }
.bullets { display: flex; flex-direction: column; gap: 5px; }
.bullet-row { display: flex; gap: 5px; align-items: flex-start; }
.hint { font-size: 11px; color: var(--muted); }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }

/* layout dropdown tucked behind a toggle */
.layout-toggle { align-self: flex-start; }
.layout-wrap { display: none; }
.layout-wrap.open { display: flex; }

/* ---------- Resume page (preview + print) ---------- */
.page {
  width: 794px;            /* ~ A4 @96dpi */
  height: 1123px;          /* fixed A4 height — strict one page */
  overflow: hidden;        /* content beyond one page is clipped */
  background: #fff; color: var(--r-text);
  padding: 34px 46px; font-family: var(--r-font); font-size: 13px; line-height: 1.34;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.page.over { outline: 2px solid #e26a6a; outline-offset: -2px; }
.r-name { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: .06em; color: #111; }
.r-title { text-align: center; font-size: 16px; font-weight: 700; letter-spacing: .12em; color: var(--r-accent); margin-top: 2px; text-transform: uppercase; }
.r-contacts { text-align: center; font-size: 12.5px; color: #333; margin-top: 8px; }
.r-contacts .sep { color: #aaa; margin: 0 8px; }
.r-contacts .ico { color: var(--r-accent); margin-right: 3px; }

.r-section { margin-top: 10px; }
.r-sec-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--r-accent); border-bottom: 1.5px solid var(--r-rule); padding-bottom: 2px; margin-bottom: 5px;
}
.r-text { font-size: 12.8px; line-height: 1.4; text-align: justify; }

.r-labeled-row { font-size: 12.8px; line-height: 1.45; }
.r-labeled-row .lab { font-weight: 700; color: #111; }

.r-entry { margin-bottom: 6px; }
.r-entry:last-child { margin-bottom: 0; }
.r-entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.r-entry-title { font-weight: 700; font-size: 13px; color: #111; }
.r-entry-date { font-size: 11.5px; color: var(--r-muted); white-space: nowrap; font-weight: 600; }
.r-entry-role { font-weight: 600; font-size: 12.8px; color: #222; margin: 0 0 1px; }
.r-entry-meta { font-style: italic; font-size: 12px; color: var(--r-muted); margin: 1px 0 2px; }
.r-bullets { margin: 0; padding-left: 17px; }
.r-bullets li { font-size: 12.5px; line-height: 1.38; margin-bottom: 1px; }

.r-empty { color: #bbb; font-style: italic; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .editor { border-right: none; border-bottom: 1px solid var(--border); max-height: 60vh; }
  .preview-wrap { padding: 14px; }
  .page { width: 100%; padding: 28px 24px; }
}

/* ---------- Print → PDF ---------- */
@media print {
  /* margin:0 removes the browser's header/footer margin box (date, title,
     URL, page number). Page padding is applied to .page instead. */
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  .no-print { display: none !important; }
  .layout { display: block; height: auto; }
  .preview-wrap { padding: 0; background: #fff; display: block; overflow: visible; }
  .page-holder { width: auto !important; height: auto !important; display: block !important; }
  .page-scaler { transform: none !important; }
  .page {
    width: auto; box-shadow: none; margin: 0;
    font-size: 10.5pt; outline: none !important;
    /* strict single physical page: full A4 with internal padding (border-box) */
    padding: 12mm 13mm; height: 297mm; max-height: 297mm; overflow: hidden;
  }
  .r-name { font-size: 20pt; }
  .r-title { font-size: 12pt; }
  .r-entry, .r-section { page-break-inside: avoid; }
  .r-bullets li { page-break-inside: avoid; }
}
