/* ============================================================
   CV Builder — app UI (wizard, workspace, editor)
   Rides on app.css tokens: --surface --border --muted --primary…
   Light + dark via existing theme classes. RTL-safe (logical props).
   ============================================================ */

/* ---------- Wizard option cards ---------- */
.cvw-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.cvw-option { position: relative; }
.cvw-option input { position: absolute; opacity: 0; inset: 0; }
.cvw-option label {
  display: flex; flex-direction: column; gap: .45rem; height: 100%;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem; cursor: pointer;
  background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cvw-option label:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.cvw-option input:checked + label { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.cvw-option .t { font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.cvw-option .d { color: var(--muted); font-size: .88rem; line-height: 1.5; }

.cvw-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; flex-wrap: wrap; }

/* ---------- Template mini previews (pure CSS mockups) ---------- */
.tplmini {
  width: 100%; aspect-ratio: 210 / 260; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; overflow: hidden;
  position: relative; direction: ltr; box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}
.tplmini i { display: block; position: absolute; border-radius: 2px; background: #d7dce6; }
.tplmini .ln-title { background: #39424f; }
.tplmini .ln-accent { background: var(--tpl-accent, #2563eb); }
.tplmini .ln-soft { background: #eceff4; }

/* ats-clear mini */
.tplmini.m-ats-clear .ln-title { top: 9%; left: 30%; width: 40%; height: 6%; }
.tplmini.m-ats-clear .l1 { top: 19%; left: 35%; width: 30%; height: 3%; }
.tplmini.m-ats-clear .hr { top: 26%; left: 10%; width: 80%; height: 1.4%; background: #39424f; }
.tplmini.m-ats-clear .s1 { top: 33%; left: 10%; width: 26%; height: 3.4%; background: #6b7686; }
.tplmini.m-ats-clear .p1 { top: 40%; left: 10%; width: 80%; height: 2.4%; }
.tplmini.m-ats-clear .p2 { top: 45%; left: 10%; width: 74%; height: 2.4%; }
.tplmini.m-ats-clear .s2 { top: 54%; left: 10%; width: 30%; height: 3.4%; background: #6b7686; }
.tplmini.m-ats-clear .p3 { top: 61%; left: 10%; width: 80%; height: 2.4%; }
.tplmini.m-ats-clear .p4 { top: 66%; left: 10%; width: 66%; height: 2.4%; }
.tplmini.m-ats-clear .p5 { top: 74%; left: 10%; width: 78%; height: 2.4%; }
.tplmini.m-ats-clear .p6 { top: 79%; left: 10%; width: 60%; height: 2.4%; }

/* ats-compact mini */
.tplmini.m-ats-compact .ln-title { top: 8%; left: 8%; width: 36%; height: 5.6%; }
.tplmini.m-ats-compact .l1 { top: 9%; right: 8%; left: auto; width: 26%; height: 2.4%; }
.tplmini.m-ats-compact .hr { top: 17%; left: 8%; width: 84%; height: 1.6%; background: #39424f; }
.tplmini.m-ats-compact .s1 { top: 23%; left: 8%; width: 22%; height: 3%; background: #6b7686; }
.tplmini.m-ats-compact .p1 { top: 29%; left: 8%; width: 84%; height: 2%; }
.tplmini.m-ats-compact .p2 { top: 33%; left: 8%; width: 78%; height: 2%; }
.tplmini.m-ats-compact .p3 { top: 37%; left: 8%; width: 82%; height: 2%; }
.tplmini.m-ats-compact .s2 { top: 45%; left: 8%; width: 26%; height: 3%; background: #6b7686; }
.tplmini.m-ats-compact .p4 { top: 51%; left: 8%; width: 84%; height: 2%; }
.tplmini.m-ats-compact .p5 { top: 55%; left: 8%; width: 70%; height: 2%; }
.tplmini.m-ats-compact .p6 { top: 63%; left: 8%; width: 80%; height: 2%; }
.tplmini.m-ats-compact .p7 { top: 67%; left: 8%; width: 64%; height: 2%; }
.tplmini.m-ats-compact .p8 { top: 75%; left: 8%; width: 76%; height: 2%; }

/* sidebar-pro mini */
.tplmini.m-sidebar-pro .side { top: 0; left: 0; width: 32%; height: 100%; border-radius: 0; background: var(--tpl-accent, #2563eb); }
.tplmini.m-sidebar-pro .ph { top: 6%; left: 7%; width: 18%; aspect-ratio: 1; height: auto; border-radius: 50%; background: rgba(255,255,255,.75); }
.tplmini.m-sidebar-pro .sl1 { top: 26%; left: 6%; width: 20%; height: 2.4%; background: rgba(255,255,255,.7); }
.tplmini.m-sidebar-pro .sl2 { top: 31%; left: 6%; width: 16%; height: 2%; background: rgba(255,255,255,.5); }
.tplmini.m-sidebar-pro .sl3 { top: 40%; left: 6%; width: 20%; height: 2%; background: rgba(255,255,255,.5); }
.tplmini.m-sidebar-pro .sl4 { top: 45%; left: 6%; width: 18%; height: 2%; background: rgba(255,255,255,.5); }
.tplmini.m-sidebar-pro .mt { top: 8%; left: 40%; width: 40%; height: 5%; background: #39424f; }
.tplmini.m-sidebar-pro .s1 { top: 20%; left: 40%; width: 24%; height: 3%; background: var(--tpl-accent, #2563eb); }
.tplmini.m-sidebar-pro .p1 { top: 27%; left: 40%; width: 52%; height: 2.2%; }
.tplmini.m-sidebar-pro .p2 { top: 32%; left: 40%; width: 46%; height: 2.2%; }
.tplmini.m-sidebar-pro .s2 { top: 42%; left: 40%; width: 28%; height: 3%; background: var(--tpl-accent, #2563eb); }
.tplmini.m-sidebar-pro .p3 { top: 49%; left: 40%; width: 52%; height: 2.2%; }
.tplmini.m-sidebar-pro .p4 { top: 54%; left: 40%; width: 40%; height: 2.2%; }
.tplmini.m-sidebar-pro .p5 { top: 63%; left: 40%; width: 50%; height: 2.2%; }

/* modern-accent mini */
.tplmini.m-modern-accent .banner { top: 0; left: 0; width: 100%; height: 22%; border-radius: 0; background: var(--tpl-accent, #2563eb); }
.tplmini.m-modern-accent .bl1 { top: 6%; left: 7%; width: 34%; height: 4.4%; background: rgba(255,255,255,.9); }
.tplmini.m-modern-accent .bl2 { top: 13%; left: 7%; width: 24%; height: 2.6%; background: rgba(255,255,255,.6); }
.tplmini.m-modern-accent .ph { top: 5%; right: 6%; left: auto; width: 13%; aspect-ratio: 1; height: auto; border-radius: 50%; background: rgba(255,255,255,.8); }
.tplmini.m-modern-accent .s1 { top: 29%; left: 7%; width: 22%; height: 3%; background: var(--tpl-accent, #2563eb); }
.tplmini.m-modern-accent .p1 { top: 36%; left: 7%; width: 50%; height: 2.2%; }
.tplmini.m-modern-accent .p2 { top: 41%; left: 7%; width: 44%; height: 2.2%; }
.tplmini.m-modern-accent .p3 { top: 50%; left: 7%; width: 52%; height: 2.2%; }
.tplmini.m-modern-accent .p4 { top: 55%; left: 7%; width: 38%; height: 2.2%; }
.tplmini.m-modern-accent .card { top: 29%; right: 6%; left: auto; width: 28%; height: 22%; border-radius: 6px; background: #eef1f7; border: 1px solid #dde3ee; }
.tplmini.m-modern-accent .card2 { top: 55%; right: 6%; left: auto; width: 28%; height: 16%; border-radius: 6px; background: #eef1f7; border: 1px solid #dde3ee; }

.cvw-option .tpl-name { font-weight: 800; margin-top: .4rem; }
.cvw-option .badge { align-self: flex-start; }

/* ---------- Ready screen ---------- */
.cv-ready { text-align: center; }
.cv-ready .cv-countdown {
  font-size: 1.6rem; font-weight: 800; letter-spacing: .04em;
  color: var(--primary); font-variant-numeric: tabular-nums;
}

/* ---------- Workspace resume cards ---------- */
.cv-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.cv-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .6rem;
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
}
.cv-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cv-card h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.cv-card .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .8rem; }
.cv-card .row-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }

.cv-trialbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .8rem 1.1rem; margin-bottom: 1.2rem; background: var(--surface);
}
.cv-trialbar .cv-countdown { font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- Editor layout ---------- */
.cv-editor-wrap { display: grid; grid-template-columns: minmax(380px, 46%) 1fr; gap: 1.1rem; align-items: start; }
.cv-form-pane { min-width: 0; }
.cv-preview-pane { position: sticky; top: 76px; min-width: 0; }
.cv-preview-pane iframe {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  background: #e8eaf0; height: min(78vh, 1000px);
}
.cv-preview-tools { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.cv-sample-badge {
  display: inline-flex; align-items: center;
  padding: .12rem .55rem; border-radius: 999px;
  background: color-mix(in srgb, #f59e0b 18%, var(--surface));
  color: #b45309; border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--border));
  font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}

.cv-editor-topbar {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.cv-editor-topbar .title-input {
  flex: 1; min-width: 180px; font-weight: 700; font-size: 1.05rem;
}
.cv-save-state { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.cv-save-state.ok { color: var(--ok, #059669); }
.cv-save-state.err { color: var(--danger, #dc2626); }

/* Editor tabs (content / design / preview-on-mobile) */
.cv-etabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.cv-etabs button {
  border: 0; background: none; cursor: pointer; font: inherit; font-weight: 700;
  color: var(--muted); padding: .55rem 1rem; margin-bottom: -2px;
  border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
}
.cv-etabs button:hover { color: var(--text); background: var(--surface-2); }
.cv-etabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.cv-etabs .only-mobile { display: none; }

/* Collapsible section blocks */
.cv-secblock {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); margin-bottom: .8rem; overflow: hidden;
}
.cv-secblock > .head {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .8rem 1rem; cursor: pointer; user-select: none;
  font-weight: 800; background: none; border: 0; color: var(--text); font-size: .95rem;
  text-align: start;
}
.cv-secblock > .head .chev { margin-inline-start: auto; transition: transform .15s; color: var(--muted); }
.cv-secblock.open > .head .chev { transform: rotate(180deg); }
.cv-secblock > .body { display: none; padding: 0 1rem 1rem; }
.cv-secblock.open > .body { display: block; }

/* Repeatable item rows */
.cv-rep { display: flex; flex-direction: column; gap: .7rem; }
.cv-rep-item {
  border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem;
  background: var(--surface-2, rgba(0,0,0,.02)); position: relative;
}
.cv-rep-item .rep-tools { display: flex; gap: .25rem; justify-content: flex-end; margin-bottom: .4rem; }
.cv-rep-item .rep-tools button {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  display: inline-grid; place-items: center; padding: 0;
}
.cv-rep-item .rep-tools button:hover { color: var(--text); border-color: var(--primary); }
.cv-rep-item .rep-tools button.danger:hover { color: var(--danger, #dc2626); border-color: var(--danger, #dc2626); }

.cv-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cv-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
@media (max-width: 560px) { .cv-grid2, .cv-grid3 { grid-template-columns: 1fr; } }

.cv-check { display: inline-flex; align-items: center; gap: .45rem; font-size: .88rem; color: var(--muted); cursor: pointer; }
.cv-check input { width: auto; }

/* Skills tag input */
.cv-tagbox {
  display: flex; flex-wrap: wrap; gap: .35rem; padding: .5rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.cv-tagbox .chip-tag {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; padding: .18rem .65rem; font-size: .85rem; font-weight: 700;
}
.cv-tagbox .chip-tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 1rem; line-height: 1; }
.cv-tagbox input { border: 0 !important; outline: none; flex: 1; min-width: 130px; background: transparent; color: var(--text); padding: .25rem; }

/* Photo control — square rounded */
.cv-photo-ctl { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.cv-photo-ctl .ph {
  width: 80px; height: 80px; border-radius: 16px; overflow: hidden;
  border: 2px dashed var(--border); display: grid; place-items: center; color: var(--muted);
  background: var(--surface-2, rgba(0,0,0,.03));
}
.cv-photo-ctl .ph img { width: 100%; height: 100%; object-fit: cover; }

/* Mode chooser (autofill vs manual) */
.cv-mode-gate { margin-bottom: 1rem; }
.cv-mode-title {
  margin: .2rem 0 1rem; font-size: 1.15rem; line-height: 1.45; font-weight: 800;
}
.cv-mode-opts { display: grid; gap: .85rem; }
@media (min-width: 900px) {
  .cv-mode-opts { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
}
.cv-import-file {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 3.1rem; padding: .85rem 1rem; border-radius: 12px;
  border: 1.5px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  cursor: pointer; text-align: center;
}
.cv-import-file strong { font-size: .92rem; font-weight: 700; color: var(--text); word-break: break-word; }
.cv-import-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.cv-mode-card {
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
}
.cv-mode-card.open { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.cv-mode-pick {
  display: flex; flex-direction: column; gap: .35rem; width: 100%; text-align: start;
  border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer;
  padding: 1.05rem 1.15rem;
}
.cv-mode-pick strong { font-size: 1.05rem; font-weight: 800; }
.cv-mode-pick span { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.cv-mode-panel { padding: 0 1.15rem 1.15rem; display: flex; flex-direction: column; gap: .7rem; }
.cv-mode-panel textarea { min-height: 160px; resize: vertical; }
.cv-mode-change { margin-bottom: .8rem; }

/* Crop modal */
.cv-crop-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 23, 42, .55);
  display: grid; place-items: center; padding: 1rem;
}
.cv-crop-modal[hidden] { display: none !important; }
.cv-crop-dialog {
  width: min(560px, 100%); background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 1.1rem 1.2rem 1.2rem;
}
.cv-crop-dialog h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.cv-crop-hint { margin: 0 0 .8rem; color: var(--muted); font-size: .88rem; }
.cv-crop-stage {
  position: relative; display: inline-block; max-width: 100%;
  background: #0f172a; border-radius: 12px; overflow: hidden; touch-action: none;
}
.cv-crop-stage canvas { display: block; max-width: 100%; vertical-align: top; }
.cv-crop-box {
  position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  border-radius: 12px; cursor: move; box-sizing: border-box;
}
.cv-crop-handle {
  position: absolute; inset-inline-end: -7px; bottom: -7px;
  width: 16px; height: 16px; border-radius: 4px;
  background: #fff; border: 2px solid var(--primary, #2563eb); cursor: nwse-resize;
}
.cv-crop-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1rem; flex-wrap: wrap; }

/* Auth bar + share */
.cv-authbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: .7rem .95rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  font-size: .9rem;
}
.cv-auth-chip { color: var(--muted); font-size: .85rem; margin-inline-end: .4rem; }
.cv-share-box {
  margin: 1.2rem auto 0; max-width: 460px; text-align: start;
  padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.cv-share-box label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: .45rem; }
.cv-share-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.cv-share-row input {
  flex: 1; min-width: 180px; font-family: ui-monospace, monospace; font-size: .85rem;
}

/* Template minis: square rounded photo */
.tplmini.m-sidebar-pro .ph,
.tplmini.m-modern-accent .ph { border-radius: 22% !important; }

/* ---------- Design tab controls ---------- */
.cv-tpl-picker { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.cv-tpl-picker .cvw-option label { padding: .7rem; }
.cv-tpl-picker .tpl-name { font-size: .85rem; margin-top: .3rem; }

.cv-swatches { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.cv-swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  outline: 1px solid var(--border); padding: 0;
}
.cv-swatch.is-light { outline-color: rgba(15, 23, 42, .35); }
.cv-swatch.active { border-color: var(--surface); outline: 3px solid var(--primary); }
.cv-swatch.is-light { box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .22); }

.cv-swatch-picker {
  width: 38px; height: 38px; border: none; padding: 0; background: transparent;
  cursor: pointer; border-radius: 50%;
}
.cv-swatch-picker::-webkit-color-swatch-wrapper { padding: 0; }
.cv-swatch-picker::-webkit-color-swatch { border: 2px solid var(--border); border-radius: 50%; }

.cv-fs-btns { display: flex; gap: .4rem; }
.cv-fs-btns button {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 10px; padding: .45rem .9rem; cursor: pointer; font: inherit; font-weight: 700;
}
.cv-fs-btns button.active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.cv-order-panel { margin-top: .35rem; }
.cv-order-hint {
  margin: .25rem 0 .7rem; font-size: .82rem; color: var(--muted); line-height: 1.45;
}
.cv-order-group { margin-bottom: .75rem; }
.cv-order-group-title {
  font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary); margin-bottom: .4rem;
}
.cv-order-list { display: flex; flex-direction: column; gap: .4rem; }
.cv-order-item {
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; background: var(--surface);
}
.cv-order-item .nm { font-weight: 700; font-size: .9rem; flex: 1; }
.cv-order-item.off { opacity: .72; }
.cv-order-item.off .nm { color: var(--muted); text-decoration: line-through; }
.cv-order-item input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
.cv-order-item button {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; display: inline-grid; place-items: center; padding: 0;
}
.cv-order-item button:disabled { opacity: .35; cursor: default; }

/* ---------- Toast ---------- */
.cv-toast {
  position: fixed; bottom: 1.4rem; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--surface); font-weight: 700; font-size: .9rem;
  padding: .6rem 1.3rem; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 200; box-shadow: var(--shadow-lg);
}
[dir="rtl"] .cv-toast { transform: translateX(50%) translateY(20px); }
.cv-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
[dir="rtl"] .cv-toast.show { transform: translateX(50%) translateY(0); }

/* ---------- Responsive: mobile = tabbed panes ---------- */
@media (max-width: 980px) {
  .cv-editor-wrap { grid-template-columns: 1fr; }
  .cv-preview-pane { position: static; display: none; }
  .cv-etabs .only-mobile { display: inline-block; }
  body.cv-show-preview .cv-preview-pane { display: block; }
  body.cv-show-preview .cv-form-pane { display: none; }
}
