/* CV Designer · Diginova — app UI + CV templates + print rules */

:root {
  --navy: #182036;
  --cyan: #5ce6ff;
  --pink: #ff6fe0;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel2: #f7f9fd;
  --tx: #182036;
  --mut: #5a6478;
  --bd: #dbe1ec;
  --focus: #0e8aa3;
  --danger: #c93a5a;
  --shadow: 0 6px 24px rgba(24, 32, 54, .10);
  --f-head: 'Unbounded', 'Manrope', 'Noto Sans Devanagari', system-ui, sans-serif;
  --f-body: 'Manrope', 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0e1424;
  --panel: #182036;
  --panel2: #1e2844;
  --tx: #eaf0ff;
  --mut: #9aa6c2;
  --bd: #2c3856;
  --focus: #5ce6ff;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tx);
  font-family: var(--f-body); font-size: 15px; line-height: 1.5;
}
:lang(hi) { line-height: 1.65; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* header */
.hdr {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--navy); color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand-logo { border-radius: 8px; display: block; }
.brand-name { font-family: var(--f-head); font-weight: 600; font-size: 15px; letter-spacing: .02em; }
.product {
  font-family: var(--f-mono); font-size: 12px; color: var(--cyan);
  border-left: 1px solid rgba(255,255,255,.25); padding-left: 12px; white-space: nowrap;
}
.hdr-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; overflow: hidden; }
.seg button { background: transparent; color: #fff; border: 0; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; min-height: 34px; }
.seg button[aria-pressed="true"] { background: var(--cyan); color: var(--navy); }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* intro + toolbar */
.intro { max-width: 1400px; margin: 0 auto; padding: 18px 16px 6px; }
.intro-h { font-family: var(--f-head); font-weight: 600; font-size: clamp(20px, 3.4vw, 28px); margin: 0 0 6px; line-height: 1.25; }
.intro p { margin: 0 0 4px; color: var(--mut); max-width: 70ch; }
.intro .privacy-line { color: var(--tx); font-weight: 600; font-size: 14px; }
.intro .privacy-line::before { content: "🔒 "; }

.toolbar {
  max-width: 1400px; margin: 0 auto; padding: 8px 16px 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.btn {
  border: 1px solid var(--bd); background: var(--panel); color: var(--tx);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; min-height: 40px;
}
.btn:hover { border-color: var(--focus); }
.btn.primary { background: linear-gradient(90deg, var(--cyan), var(--pink)); color: var(--navy); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }
.save-state { margin-left: auto; font-size: 12.5px; color: var(--mut); font-family: var(--f-mono); }

/* tabs (mobile) */
.tabs { display: none; max-width: 1400px; margin: 0 auto; padding: 0 16px 8px; gap: 8px; }
.tabs button { flex: 1; padding: 10px; border: 1px solid var(--bd); background: var(--panel); border-radius: 10px; font-weight: 700; cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
:root[data-theme="dark"] .tabs button[aria-selected="true"] { background: var(--cyan); color: var(--navy); }

/* workspace */
.workspace { max-width: 1400px; margin: 0 auto; padding: 0 16px 24px; display: grid; grid-template-columns: minmax(340px, 34rem) minmax(0, 1fr); gap: 16px; align-items: start; }
.editor { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.preview-col { position: sticky; top: 66px; min-width: 0; max-height: calc(100vh - 80px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--bd); border-radius: 14px; overflow: hidden; }
.pv-bar { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--bd); font-weight: 700; font-size: 14px; }
.pv-pages { font-family: var(--f-mono); font-size: 12.5px; color: var(--mut); font-weight: 500; }
.pv-scroll { overflow: auto; padding: 16px; background: #8a93a8; background: color-mix(in srgb, var(--bg) 70%, #6b7592); flex: 1 1 auto; }
.pv-wrap { margin: 0 auto; position: relative; }
.pv-hint { margin: 0; padding: 8px 14px; font-size: 12.5px; color: var(--mut); border-top: 1px solid var(--bd); }

.sheet {
  position: relative; background: #fff; color: #1c2230;
  width: 210mm; min-height: 297mm; padding: 18mm 14mm 20mm;
  transform-origin: top left; box-shadow: var(--shadow);
}
.sheet.letter { width: 215.9mm; min-height: 279.4mm; }
#guides .g {
  position: absolute; left: 0; right: 0; border-top: 1.5px dashed #e0457b; pointer-events: none;
}
#guides .g span { position: absolute; right: 6px; top: 2px; font: 500 10px var(--f-mono); color: #e0457b; background: #fff; padding: 0 4px; }

/* cards + form */
.card { background: var(--panel); border: 1px solid var(--bd); border-radius: 14px; }
.card-t { font-family: var(--f-head); font-weight: 500; font-size: 15px; margin: 0; padding: 14px 16px 6px; }
.design { padding-bottom: 14px; }
.design > *:not(.card-t) { margin-left: 16px; margin-right: 16px; }
.tpls { border: 0; padding: 0; margin-top: 6px; margin-bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.tpls legend { font-size: 13px; font-weight: 700; color: var(--mut); padding: 0 0 6px; }
.tpl { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 2px solid var(--bd); border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 700; text-align: center; background: var(--panel2); }
.tpl input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tpl:has(input:checked) { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.tpl:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.thumb { width: 46px; height: 60px; background: #fff; border: 1px solid #cfd6e4; border-radius: 3px; position: relative; display: block; overflow: hidden; }
.thumb i { position: absolute; background: #c5ccdb; height: 3px; border-radius: 2px; }
.th-classic i:nth-child(1) { top: 7px; left: 12px; right: 12px; height: 4px; background: #182036; }
.th-classic i:nth-child(2) { top: 15px; left: 6px; right: 6px; height: 1.5px; background: #0e8aa3; }
.th-classic i:nth-child(3) { top: 22px; left: 6px; right: 14px; }
.th-classic i:nth-child(4) { top: 30px; left: 6px; right: 8px; box-shadow: 0 8px 0 #c5ccdb, 0 16px 0 #c5ccdb; }
.th-modern i:nth-child(1) { top: 0; left: 0; right: 0; height: 5px; background: #d02fae; border-radius: 0; }
.th-modern i:nth-child(2) { top: 10px; left: 6px; width: 24px; height: 5px; background: #d02fae; }
.th-modern i:nth-child(3) { top: 22px; left: 6px; width: 3px; height: 8px; background: #d02fae; }
.th-modern i:nth-child(4) { top: 24px; left: 13px; right: 8px; box-shadow: 0 9px 0 #c5ccdb, 0 18px 0 #c5ccdb; }
.th-sidebar i:nth-child(1) { top: 0; bottom: 0; right: 0; width: 16px; height: auto; background: #f6dfae; border-radius: 0; }
.th-sidebar i:nth-child(2) { top: 7px; left: 5px; width: 20px; height: 5px; background: #182036; }
.th-sidebar i:nth-child(3) { top: 18px; left: 5px; width: 22px; }
.th-sidebar i:nth-child(4) { top: 26px; left: 5px; width: 22px; box-shadow: 0 8px 0 #c5ccdb, 0 16px 0 #c5ccdb; }

.ctl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 14px; }
.ctl { min-width: 0; }
.ctl > label { display: block; font-size: 13px; font-weight: 700; color: var(--mut); margin-bottom: 4px; }
.ctl output { font-family: var(--f-mono); color: var(--tx); }
.ctl input[type=range] { width: 100%; accent-color: var(--focus); }
.accent-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.accent-row input[type=color] { width: 40px; height: 36px; padding: 0; border: 1px solid var(--bd); border-radius: 8px; background: none; cursor: pointer; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--bd); cursor: pointer; padding: 0; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--tx); }
select, input[type=text], input[type=email], input[type=tel], input[type=url], textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--bd); border-radius: 8px; background: var(--panel); min-height: 40px;
}
textarea { resize: vertical; line-height: 1.45; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form details.card > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; font-family: var(--f-head); font-weight: 500; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px;
}
.form details.card > summary::-webkit-details-marker { display: none; }
.form details.card > summary::after { content: "▾"; color: var(--mut); transition: transform .15s; }
.form details[open].card > summary::after { transform: rotate(180deg); }
.form .body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld { min-width: 0; grid-column: span 2; }
.fld.half { grid-column: span 1; }
.fld label { display: block; font-size: 12.5px; font-weight: 700; color: var(--mut); margin-bottom: 3px; }
.fld.chk label { display: flex; align-items: center; gap: 8px; color: var(--tx); font-size: 14px; margin: 0; min-height: 40px; }
.fld.chk input { width: 18px; height: 18px; accent-color: var(--focus); }
.ent { border: 1px solid var(--bd); border-radius: 12px; padding: 10px 12px 12px; background: var(--panel2); }
.ent-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ent-t { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ent-b { display: flex; gap: 4px; flex-shrink: 0; }
.ent-b button { width: 34px; height: 34px; border: 1px solid var(--bd); background: var(--panel); border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1; }
.ent-b button:hover { border-color: var(--focus); }
.ent-b button[data-act="del"]:hover { border-color: var(--danger); color: var(--danger); }
.ent-b button:disabled { opacity: .35; cursor: default; }
.photo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-prev { width: 64px; height: 64px; border-radius: 50%; background: var(--panel2) center/cover no-repeat; border: 1px solid var(--bd); flex-shrink: 0; }

.note { background: color-mix(in srgb, var(--cyan) 22%, var(--panel)); border: 1px solid color-mix(in srgb, var(--cyan) 60%, var(--bd)); padding: 10px 14px; border-radius: 12px; font-size: 14px; }

.ftr { max-width: 1400px; margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--mut); font-size: 13.5px; border-top: 1px solid var(--bd); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 60; max-width: min(92vw, 520px); box-shadow: var(--shadow); font-size: 14px; border: 1px solid var(--cyan); }
.dlg { border: 1px solid var(--bd); border-radius: 16px; padding: 22px; max-width: min(92vw, 460px); background: var(--panel); color: var(--tx); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(10, 14, 28, .6); }
.dlg h2 { font-family: var(--f-head); font-weight: 500; font-size: 17px; margin: 0 0 10px; }
.dlg p { margin: 0 0 10px; color: var(--mut); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }

/* responsive */
@media (max-width: 959px) {
  .tabs { display: flex; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  body[data-tab="edit"] .preview-col { display: none; }
  body[data-tab="preview"] .editor { display: none; }
  .preview-col { position: static; max-height: none; }
  .pv-scroll { padding: 10px; }
  .save-state { margin-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .product { display: none; }
  .ctl-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .fld, .fld.half { grid-column: span 1; }
  .tpl { font-size: 12px; }
  .btn { flex: 1 1 calc(50% - 8px); }
  .btn.primary { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* =========================================================
   CV TEMPLATES (render targets — neutral print styling)
   ========================================================= */
.cv {
  --acc: #0e8aa3; --fs: 10; --sp: 1;
  font-family: 'Manrope', 'Noto Sans Devanagari', 'Noto Naskh Arabic', Arial, Helvetica, sans-serif;
  font-size: calc(var(--fs) * 1pt); line-height: 1.45; color: #1c2230;
  text-align: start; overflow-wrap: anywhere;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cv *, .cv *::before, .cv *::after { box-sizing: border-box; }
.cv:lang(hi), .cv:lang(ar) { line-height: 1.6; }
.cv:lang(hi) *, .cv:lang(ar) * { letter-spacing: 0 !important; text-transform: none !important; }
.cv h1, .cv h2, .cv h3, .cv p, .cv ul, .cv dl, .cv dd { margin: 0; padding: 0; }
.cv ul { list-style: none; }
.cv a { color: inherit; text-decoration: none; }
.cv .ph { color: #9aa3b5; }
.cv h1 { font-size: 2.2em; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
.cv .headline { font-size: 1.15em; font-weight: 600; color: var(--acc); margin-top: .15em; }
.cv .contact { display: flex; flex-wrap: wrap; gap: .15em 1.1em; margin-top: .6em; font-size: .95em; color: #3a4357; }
.cv .contact li { margin: 0; padding: 0; }
.cv .contact li::before { content: none; }
.cv .photo { width: 26mm; height: 26mm; object-fit: cover; border-radius: 50%; display: block; flex: 0 0 auto; }
.cv .sec { margin-top: calc(var(--sp) * 1.45em); }
.cv .sec-t { font-size: .95em; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--acc); margin-bottom: calc(var(--sp) * .5em); }
.cv .entry { margin-top: calc(var(--sp) * .8em); }
.cv .sec-t + .entry, .cv .sec-t + p, .cv .sec-t + .skillgrp { margin-top: 0; }
.cv .row { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; }
.cv h3 { font-size: 1.02em; font-weight: 700; }
.cv .dates { font-size: .92em; color: #4b566c; white-space: nowrap; flex: 0 0 auto; }
.cv .sub { color: #3a4357; font-size: .97em; }
.cv .sub a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--acc) 50%, transparent); }
.cv .entry ul { margin-top: .3em; }
.cv li { position: relative; padding-inline-start: 1.05em; margin-top: calc(var(--sp) * .22em); }
.cv li::before { content: "•"; position: absolute; inset-inline-start: .1em; color: var(--acc); font-weight: 700; }
.cv .desc { margin-top: .25em; }
.cv .skillgrp { margin-top: calc(var(--sp) * .35em); }
.cv .skillgrp b { font-weight: 700; }
.cv .chip { display: inline; }
.cv .langs { display: flex; flex-wrap: wrap; gap: .2em 1.4em; }
.cv .langs li { padding: 0; margin: 0; }
.cv .langs li::before { content: none; }
.cv .kv { display: flex; gap: .6em; margin-top: .2em; }
.cv .kv b { min-width: 9em; font-weight: 700; }
.cv .photo-box { flex: 0 0 auto; }

/* Classic */
.t-classic .head { display: flex; align-items: center; justify-content: space-between; gap: 6mm; padding-bottom: .7em; border-bottom: 2px solid var(--acc); }
.t-classic .head-txt { flex: 1 1 auto; min-width: 0; text-align: center; }
.t-classic .head .photo { border-radius: 4px; }
.t-classic .contact { justify-content: center; }
.t-classic .contact { gap: .15em 0; }
.t-classic .contact li:not(:last-child)::after { content: "|"; margin-inline: .9em; color: #9aa3b5; }
.t-classic .sec-t { color: #182036; border-bottom: 1px solid var(--acc); padding-bottom: .2em; }
.t-classic .chip:not(:last-child)::after { content: ", "; }

/* Modern */
.t-modern .head { display: flex; align-items: center; justify-content: space-between; gap: 6mm; border-top: 6px solid var(--acc); padding-top: 1em; }
.t-modern .head-txt { flex: 1 1 auto; min-width: 0; }
.t-modern h1 { color: var(--acc); }
.t-modern .headline { color: #182036; }
.t-modern .contact { gap: .25em 1.2em; }
.t-modern .sec-t { border-inline-start: 4px solid var(--acc); padding-inline-start: .55em; color: #182036; }
.t-modern .chip { display: inline-block; padding: .08em .65em; margin: .15em .25em .15em 0; border-radius: 999px; background: #e8eef4; background: color-mix(in srgb, var(--acc) 14%, #fff); font-size: .95em; }
.t-modern[dir="rtl"] .chip { margin: .15em 0 .15em .25em; }
.t-modern .skillgrp { display: flex; gap: .6em; align-items: baseline; }
.t-modern .skillgrp b { flex: 0 0 8.5em; }

/* Sidebar right */
.t-sidebar .cols {
  display: grid; grid-template-columns: minmax(0, 1fr) 64mm; column-gap: 0;
  background: linear-gradient(to left, color-mix(in srgb, var(--acc) 11%, #fff) 0, color-mix(in srgb, var(--acc) 11%, #fff) 64mm, #fff 64mm);
}
.t-sidebar[dir="rtl"] .cols { background: linear-gradient(to right, color-mix(in srgb, var(--acc) 11%, #fff) 0, color-mix(in srgb, var(--acc) 11%, #fff) 64mm, #fff 64mm); }
.t-sidebar .main { padding-inline-end: 6mm; padding-top: 5mm; min-width: 0; }
.t-sidebar .side { padding: 5mm 5mm 5mm; min-width: 0; }
.t-sidebar .main h1 { color: #182036; }
.t-sidebar .photo { width: 34mm; height: 34mm; margin: 0 auto 4mm; }
.t-sidebar .side .sec:first-child { margin-top: 0; }
.t-sidebar .side .contact { flex-direction: column; margin-top: 0; gap: .35em; }
.t-sidebar .side .sec-t { border-bottom: 2px solid var(--acc); padding-bottom: .2em; color: #182036; }
.t-sidebar .main .sec-t { color: var(--acc); border-bottom: 1px solid #d6dbe6; padding-bottom: .2em; }
.t-sidebar .skillgrp { margin-top: calc(var(--sp) * .5em); }
.t-sidebar .skillgrp b { display: block; }
.t-sidebar .side .chip { display: block; }
.t-sidebar .side .chip::before { content: "• "; color: var(--acc); }
.t-sidebar .side .langs { flex-direction: column; gap: .15em; }
.t-sidebar .side .kv { flex-direction: column; gap: 0; margin-top: .4em; }
.t-sidebar .side .kv b { min-width: 0; font-size: .92em; }
.t-sidebar .side .entry .row { display: block; }
.t-sidebar .head-main { padding-bottom: .4em; }
.t-sidebar .cv-lbl { font-size: .85em; color: #4b566c; display: block; }

/* header/footer fallback for browsers without @page margin boxes */
.print-header, .print-footer { display: none; }

/* =========================================================
   PRINT / PDF
   ========================================================= */
#printRoot { display: none; }

@page { size: A4; margin: 18mm 14mm 20mm; }

@media print {
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  body > *:not(#printRoot) { display: none !important; }
  .no-print { display: none !important; }
  #printRoot { display: block !important; }
  #printRoot .cv { width: auto; }

  tr, li, .entry, .job, .edu-row, .cert, .card, .skillgrp, .kv { break-inside: avoid; page-break-inside: avoid; }
  h2, h3, .section-title, .sec-t { break-after: avoid; page-break-after: avoid; }
  p { orphans: 2; widows: 2; }
  thead { display: table-header-group; }
  /* a section title must stay with its first entry */
  .sec-t + .entry, .sec-t + p, .sec-t + .skillgrp { break-before: avoid; }

  .cv .ph { display: none; }

  /* fixed header/footer: used only when margin boxes are unsupported (JS adds html.pm-fixed) */
  html.pm-fixed .print-header { position: fixed; top: -12mm; left: 0; right: 0; font-size: 9pt; color: #555; display: flex; justify-content: space-between; }
  html.pm-fixed .print-footer { position: fixed; bottom: -14mm; left: 0; right: 0; font-size: 9pt; color: #555; display: flex; justify-content: space-between; }
}
