/* CV Studio - app styles + CV page styles + print */
:root {
  --bg: #F4F5F9; --panel: #FFFFFF; --panel-2: #F8FAFC; --text: #0F172A; --muted: #64748B;
  --line: #E2E8F0; --brand: #2563EB; --brand-2: #7C3AED; --danger: #DC2626;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --nav-bg: #0F172A; --nav-text: #CBD5E1; --nav-active: rgba(255,255,255,.1);
  --preview-bg: #E9ECF3;
  --grad: linear-gradient(135deg, #2563EB, #7C3AED);
}
:root[data-theme="dark"] {
  --bg: #0B1120; --panel: #111A2E; --panel-2: #0D1527; --text: #E5E9F2; --muted: #8B98B1;
  --line: #1F2A44; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --nav-bg: #080D1A; --preview-bg: #0A0F1D;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 250px minmax(360px, 1fr) minmax(420px, 46%); height: 100vh; }
.nav { background: var(--nav-bg); color: var(--nav-text); display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; }
.brand img { width: 40px; height: 40px; }
.brand b { display: block; color: #fff; font-size: 18px; letter-spacing: .2px; }
.brand span { font-size: 11.5px; color: #94A3B8; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: var(--nav-text); padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: left; font-size: 14px; }
.nav-btn:hover { background: rgba(255,255,255,.06); }
.nav-btn.active { background: var(--nav-active); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-ui, var(--brand)); }
.nav-btn .ico { width: 18px; text-align: center; opacity: .9; }
.nav h4 { margin: 18px 8px 6px; font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: #64748B; font-weight: 600; }
.swatches { display: flex; gap: 8px; padding: 2px 8px; flex-wrap: wrap; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.sw.on { outline: 2px solid #fff; outline-offset: 2px; }
.seg { display: inline-flex; background: rgba(148,163,184,.18); border-radius: 10px; padding: 3px; gap: 2px; }
.nav .seg { margin: 0 8px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: inherit; font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); font-weight: 600; }
.nav .seg button { color: #CBD5E1; } .nav .seg button.on { color: #0F172A; background: #fff; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; }
.switch { position: relative; width: 40px; height: 22px; background: #475569; border-radius: 22px; border: 0; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch.on { background: var(--brand); } .switch.on::after { transform: translateX(18px); }
.nav-spacer { flex: 1; min-height: 12px; }
.act { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); color: #E2E8F0; cursor: pointer; margin-top: 6px; font-weight: 500; }
.act:hover { background: rgba(255,255,255,.1); }
.act.primary { background: var(--grad); border: 0; color: #fff; font-weight: 600; }
.act.primary:hover { filter: brightness(1.08); }
.act.danger:hover { background: rgba(220,38,38,.25); border-color: rgba(220,38,38,.5); }

.editor { overflow-y: auto; padding: 28px 32px 60px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p { margin: 0 0 20px; color: var(--muted); }
.page { display: none; max-width: 760px; } .page.active { display: block; }

/* ---------- form */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .lbl-s { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], textarea, select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; outline: none; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--brand); }
.btn.solid { background: var(--grad); color: #fff; border: 0; font-weight: 600; }
.btn.add { width: 100%; border-style: dashed; color: var(--brand); padding: 11px; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.x { color: var(--danger); }

.photo-box { display: flex; gap: 18px; align-items: center; }
.photo-prev { width: 104px; height: 104px; background: var(--panel-2); border: 2px dashed var(--line); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; text-align: center; flex: none; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-prev.shape-circle { border-radius: 50%; } .photo-prev.shape-rounded { border-radius: 18px; } .photo-prev.shape-square { border-radius: 0; }
.photo-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.photo-actions .row { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-actions .seg { background: var(--panel-2); border: 1px solid var(--line); }

.entry-card { position: relative; }
.entry-card .top-actions { position: absolute; top: 10px; right: 10px; }
.date-row { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; margin-bottom: 12px; }
.date-row .dl { font-size: 12px; font-weight: 600; color: var(--muted); }
.date-pick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.date-pick select { width: auto; min-width: 92px; padding: 7px 9px; }
.date-pick label.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; margin-left: 4px; }
.compact-add { display: flex; gap: 8px; margin-bottom: 10px; }
.compact-add input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 5px 6px 5px 12px; }
.chip button { border: 0; background: rgba(148,163,184,.25); border-radius: 50%; width: 20px; height: 20px; line-height: 18px; cursor: pointer; padding: 0; color: var(--muted); }
.chip button:hover { background: var(--danger); color: #fff; }
.link-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; }
.link-list .chip { display: flex; border-radius: 10px; padding: 7px 8px 7px 12px; margin-bottom: 6px; justify-content: space-between; }
.link-list .chip small { color: var(--muted); margin-left: 8px; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tpl-card { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; text-align: center; }
.tpl-card:hover { border-color: var(--brand); }
.tpl-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
.tpl-thumb { width: 100%; aspect-ratio: 794 / 1122; position: relative; overflow: hidden; border-radius: 6px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); pointer-events: none; }
.tpl-thumb .cv-page { transform-origin: top left; position: absolute; left: 0; top: 0; margin: 0; box-shadow: none; }
.tpl-card b { display: block; margin-top: 8px; }

/* ---------- preview */
.preview { background: var(--preview-bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; font-weight: 600; }
.preview-head small { color: var(--muted); font-weight: 400; }
.preview-scroll { flex: 1; overflow: auto; padding: 4px 20px 30px; }
#previewPages { transform-origin: top left; }
.pv-wrap { margin: 0 auto 18px; position: relative; }
.pv-wrap .cv-page { position: absolute; left: 0; top: 0; transform-origin: top left; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.fab { display: none; }
.menu-btn { display: none; }
.mobile-bar { display: none; }

/* ---------- modals / toast */
.overlay { position: fixed; inset: 0; background: rgba(2,6,23,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; padding: 22px; width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.modal h3 { margin: 0 0 6px; } .modal p { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.modal .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.crop-stage { position: relative; width: 340px; height: 340px; max-width: 100%; margin: 0 auto; background: #0F172A; border-radius: 10px; overflow: hidden; touch-action: none; cursor: grab; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-stage .mask { position: absolute; inset: 0; pointer-events: none; }
.zoom { width: 100%; margin-top: 14px; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: #0F172A; color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 80; max-width: 90vw; text-align: center; pointer-events: none; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- responsive */
@media (max-width: 1180px) { .app { grid-template-columns: 220px 1fr minmax(340px, 42%); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .25s; }
  .nav.open { transform: none; }
  .editor { padding: 70px 16px 90px; }
  .preview { position: fixed; inset: 0; z-index: 30; transform: translateY(100%); transition: transform .25s; }
  .preview.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: 58px; padding: 0 12px; z-index: 35; background: var(--panel); border-bottom: 1px solid var(--line); }
  .mb-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
  .mb-brand img { width: 30px; height: 30px; }
  .menu-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--nav-bg); color: #fff; font-size: 20px; cursor: pointer; }
  .photo-box { flex-direction: column; align-items: center; text-align: center; }
  .photo-actions { width: 100%; align-items: stretch; }
  .photo-actions .row { justify-content: center; }
  .photo-actions .seg { display: flex; } .photo-actions .seg button { flex: 1; padding: 7px 4px; }
  .fab { display: block; position: fixed; right: 16px; bottom: 16px; z-index: 36; border: 0; background: var(--grad); color: #fff; padding: 13px 20px; border-radius: 30px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
  .grid2, .link-row { grid-template-columns: 1fr; }
  .preview-head { padding-left: 66px; }
}

/* =====================================================================
   CV PAGES (A4 794 x 1122) - used by preview, thumbnails and print
   ===================================================================== */
.cv-page { width: 794px; height: 1122px; background: #fff; position: relative; overflow: hidden; color: #374151; font-family: Calibri, 'Segoe UI', Carlito, Arial, sans-serif; font-size: 13.3px; line-height: 1.38; text-align: left; }
.cv-page *, .cv-page *::before, .cv-page *::after { box-sizing: border-box; }
.cv-page a, .cv-page a:hover, .cv-page a:visited { color: inherit; text-decoration: none !important; }
.cv-page .col { position: absolute; }
.cv-page h1, .cv-page h2, .cv-page h3 { margin: 0; }
.cv-page .photo { object-fit: cover; display: block; }
.cv-page .shape-circle { border-radius: 50%; } .cv-page .shape-rounded { border-radius: 18%; } .cv-page .shape-square { border-radius: 0; }
.cv-page .entry { padding-bottom: 12px; }
.cv-page .e-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.cv-page .e-role { font-weight: 700; font-size: 14.5px; color: #111827; }
.cv-page .e-date { font-size: 12px; color: #6B7280; white-space: nowrap; }
.cv-page .e-sub { font-weight: 600; font-size: 12.8px; color: #6B7280; margin: 1px 0 4px; }
.cv-page .e-sub a { color: var(--accent); }
.cv-page .ln { font-size: 13.3px; margin-bottom: 2px; line-height: 1.42; }
.cv-page .ln.bul { padding-left: 14px; position: relative; }
.cv-page .ln.bul::before { content: '•'; position: absolute; left: 3px; }
.cv-page .sec-h { font-size: 13.5px; letter-spacing: 1.7px; text-transform: uppercase; font-weight: 700; margin: 18px 0 8px; color: var(--accent); border-bottom: 1px solid #E5E7EB; padding-bottom: 3px; }
.cv-page .blk:first-child .sec-h { margin-top: 0; }
.cv-page .inline { font-size: 13.3px; line-height: 1.5; }
.cv-page .inline .sep { color: var(--accent); }

/* sidebar + light */
.tpl-sidebar .side, .tpl-light .side { position: absolute; left: 0; top: 0; bottom: 0; width: 250px; background: var(--side-bg); color: var(--side-text); padding: 46px 24px 24px; }
.tpl-sidebar .side .photo, .tpl-light .side .photo { width: 150px; height: 150px; margin: 0 auto 6px; }
.cv-page .side h3 { font-size: 12.5px; letter-spacing: 1.7px; text-transform: uppercase; color: var(--side-head); border-bottom: 1px solid var(--side-line); padding-bottom: 4px; margin: 22px 0 6px; }
.cv-page .side .lbl { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700; color: var(--side-lbl); margin-top: 9px; }
.cv-page .side .val { font-size: 12.6px; word-break: break-word; }
.cv-page .side .val a { color: var(--side-link); }
.cv-page .side .it { font-size: 12.6px; margin-bottom: 4px; }
.cv-page .side .it.bul::before { content: '•  '; }
.tpl-sidebar .nameblk h1, .tpl-light .nameblk h1 { font-size: 36px; font-weight: 800; color: #111827; line-height: 1.1; }
.tpl-sidebar .nameblk .title, .tpl-light .nameblk .title { font-size: 17px; color: var(--accent); margin-top: 4px; }
.tpl-sidebar .nameblk .bar, .tpl-light .nameblk .bar { width: 48px; height: 4px; background: var(--accent); border-radius: 2px; margin: 12px 0 16px; }

/* banner */
.tpl-banner .band { position: absolute; left: 0; top: 0; right: 0; background: var(--accent); color: #fff; display: flex; align-items: center; padding: 0 58px; gap: 26px; }
.tpl-banner .band-photo { width: 124px; height: 124px; border: 3px solid rgba(255,255,255,.85); flex: none; }
.tpl-banner .band h1 { font-size: 34px; font-weight: 800; line-height: 1.1; }
.tpl-banner .band .title { font-size: 17px; opacity: .95; margin-top: 3px; }
.tpl-banner .band .contact { font-size: 12.3px; margin-top: 10px; opacity: .97; }
.tpl-banner .band a { color: #fff; }
.tpl-banner .csep { margin: 0 9px; opacity: .8; }
.tpl-banner .sec-h { border: 0; border-left: 4px solid var(--accent); padding: 0 0 0 10px; color: #111827; line-height: 1.1; }

/* classic */
.tpl-classic { font-family: Georgia, 'Times New Roman', Times, serif; font-size: 13px; }
.tpl-classic .classic-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 2px solid #111827; padding-bottom: 14px; margin-bottom: 4px; }
.tpl-classic .classic-head h1 { font-size: 37px; color: #111827; font-weight: 700; line-height: 1.1; }
.tpl-classic .classic-head .title { font-size: 17px; font-style: italic; color: var(--accent); margin-top: 3px; }
.tpl-classic .classic-head .contact { font-size: 12.2px; color: #6B7280; margin-top: 9px; }

.tpl-classic .csep { margin: 0 8px; }
.tpl-classic .ch-photo { width: 108px; height: 108px; flex: none; }
.tpl-classic .sec-h { color: #111827; border-bottom: 1px solid #111827; letter-spacing: 1.4px; }

/* ---------- print: only the CV pages */
#printRoot { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { height: auto; background: #fff; }
  body > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block; }
  #printRoot .cv-page { box-shadow: none; page-break-after: always; break-after: page; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printRoot .cv-page:last-child { page-break-after: auto; break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
