/* CV ATS Builder - kukuh.id/cv-ats */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 0.625rem;

  --background: #fafafa;
  --surface: #ffffff;
  --foreground: #0a0a0a;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --link: #1c64c4;
  --accent: #1c64c4;
  --accent-soft: #eaf1fb;
  --good: #1a7f37;
  --warn: #b45309;
  --bad: #cf222e;
  --sheet-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0a0a0a;
    --surface: #171717;
    --foreground: #fafafa;
    --muted: #262626;
    --muted-foreground: #a1a1a1;
    --border: rgba(255,255,255,.12);
    --link: #76affa;
    --accent: #76affa;
    --accent-soft: rgba(118,175,250,.12);
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #ff6568;
    --sheet-shadow: 0 1px 3px rgba(0,0,0,.5), 0 8px 32px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  font-size: 14px;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
.mono { font-family: var(--font-mono); font-size: .85em; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--background) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 2px; color: var(--foreground); font-weight: 700; font-size: 15px; white-space: nowrap; flex: none; }
.brand:hover { text-decoration: none; }
.brand-sep { color: var(--muted-foreground); font-weight: 400; margin: 0 1px; }
.brand-tool { color: var(--accent); font-family: var(--font-mono); font-weight: 500; font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.divider { width: 1px; height: 20px; background: var(--border); }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--foreground);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.btn.primary:hover { opacity: .88; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--bad); }
.linklike { background: none; border: none; color: var(--link); font-size: 12.5px; cursor: pointer; padding: 0; font-weight: 500; }
.linklike:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.workspace {
  max-width: 1440px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(400px, 560px) 1fr;
  gap: 0; align-items: start;
}
.editor { padding: 20px; min-width: 0; }
.preview {
  position: sticky; top: 53px;
  height: calc(100vh - 53px);
  overflow: auto;
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 4%, transparent), transparent 60%),
    var(--muted);
  border-left: 1px solid var(--border);
}
.preview-inner { padding: 28px 28px 60px; display: flex; flex-direction: column; align-items: center; }
.page-note { margin-top: 12px; font-size: 12px; color: var(--muted-foreground); text-align: center; }

/* ---------- score card ---------- */
.score-card {
  display: flex; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.score-ring-wrap { position: relative; width: 72px; height: 72px; flex: none; }
.score-ring { width: 72px; height: 72px; transform: rotate(-90deg); }
.ring-bg, .ring-val { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--muted); }
.ring-val { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 213.6; stroke-dashoffset: 213.6; transition: stroke-dashoffset .5s ease, stroke .3s ease; }
.score-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; }
.score-title { font-weight: 700; font-size: 14px; }
.score-sub { font-size: 12.5px; color: var(--muted-foreground); margin: 2px 0 4px; }
.score-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-top: 8px; padding: 12px 16px; font-size: 13px;
}
.score-detail .chk { display: flex; gap: 8px; padding: 4px 0; align-items: baseline; }
.score-detail .chk .mark { flex: none; font-weight: 700; }
.chk.ok .mark { color: var(--good); }
.chk.no .mark { color: var(--bad); }
.chk.warn .mark { color: var(--warn); }
.chk .pts { margin-left: auto; color: var(--muted-foreground); font-family: var(--font-mono); font-size: 11px; }

/* ---------- lang toggle ---------- */
.lang-row { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; }
.lang-label { font-size: 13px; font-weight: 600; }
.seg { display: inline-flex; background: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn {
  border: none; background: transparent; color: var(--muted-foreground);
  padding: 5px 14px; font-size: 12.5px; font-weight: 600; border-radius: 6px; cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- editor sections ---------- */
.sec {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden;
}
.sec-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 16px; background: none; border: none; cursor: pointer; text-align: left;
  color: var(--foreground);
}
.sec-head:hover { background: var(--muted); }
.sec-title { font-weight: 700; font-size: 13.5px; flex: 1; }
.sec-count { font-size: 11px; color: var(--muted-foreground); font-family: var(--font-mono); }
.sec-chev { transition: transform .2s ease; color: var(--muted-foreground); font-size: 11px; }
.sec.open .sec-chev { transform: rotate(90deg); }
.sec-body { display: none; padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.sec.open .sec-body { display: block; }

.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.frow.one { grid-template-columns: 1fr; }
.frow.three { grid-template-columns: 1fr 1fr 1fr; }
.fld label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted-foreground); margin-bottom: 4px; letter-spacing: .01em; }
.fld :where(input, textarea, select) {
  width: 100%; border: 1px solid var(--border); background: var(--background); color: var(--foreground);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fld :where(input, textarea, select):focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fld textarea { resize: vertical; min-height: 60px; line-height: 1.45; }
.fld .hint { font-size: 11px; color: var(--muted-foreground); margin-top: 4px; }

.item {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 12px;
  background: var(--background);
}
.item-head { display: flex; align-items: center; gap: 6px; }
.item-title { font-size: 12.5px; font-weight: 700; flex: 1; color: var(--muted-foreground); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted-foreground);
  width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--foreground); background: var(--muted); }
.icon-btn.del:hover { color: var(--bad); border-color: var(--bad); }
.add-btn {
  margin-top: 12px; width: 100%; border: 1px dashed var(--border); background: none; color: var(--muted-foreground);
  border-radius: 8px; padding: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.add-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.switch-row .sw-label { font-size: 12.5px; font-weight: 600; flex: 1; }
.switch-row .sw-sub { font-size: 11px; color: var(--muted-foreground); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--muted); border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; transition: background .15s ease;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  background: var(--surface); border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

.photo-row { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.photo-thumb {
  width: 56px; height: 72px; border-radius: 6px; border: 1px solid var(--border);
  object-fit: cover; background: var(--muted); display: none;
}
.photo-thumb.show { display: block; }

/* ---------- JD matcher ---------- */
.jd-card, .tips-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-top: 16px;
}
.jd-title, .tips-title { font-weight: 700; font-size: 13.5px; }
.jd-sub { font-size: 12px; color: var(--muted-foreground); margin: 2px 0 10px; }
.jd-card textarea {
  width: 100%; border: 1px solid var(--border); background: var(--background); color: var(--foreground);
  border-radius: 8px; padding: 10px; font-size: 13px; font-family: inherit; resize: vertical; margin-bottom: 10px;
}
.jd-card textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.jd-result { margin-top: 12px; font-size: 13px; }
.kw { display: inline-block; margin: 3px 4px 0 0; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.kw.hit { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.kw.miss { background: color-mix(in srgb, var(--bad) 8%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.jd-meter { height: 6px; border-radius: 6px; background: var(--muted); overflow: hidden; margin: 8px 0 12px; }
.jd-meter > div { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s ease; }

.tips-card ul { padding-left: 18px; }
.tips-card li { font-size: 12.5px; color: var(--muted-foreground); margin-top: 6px; }

.editor-foot { margin: 24px 4px 40px; font-size: 12px; color: var(--muted-foreground); line-height: 1.7; }

/* ---------- A4 sheet preview ---------- */
.sheet-wrap { width: 100%; display: flex; justify-content: center; overflow: hidden; }
.sheet {
  width: 210mm; min-height: 297mm; flex: none;
  background: #ffffff; color: #111111;
  box-shadow: var(--sheet-shadow);
  padding: 14mm 16mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10.5pt; line-height: 1.42;
  transform-origin: top center;
}
/* CV content styles (ATS-safe look) */
.cv-name { font-size: 20pt; font-weight: bold; letter-spacing: .02em; }
.cv-headline { font-size: 11.5pt; margin-top: 2pt; color: #333; }
.cv-contact { font-size: 9.5pt; margin-top: 5pt; color: #222; }
.cv-contact span + span::before { content: "  |  "; color: #999; }
.cv-head-flex { display: flex; justify-content: space-between; gap: 16pt; align-items: flex-start; }
.cv-photo { width: 78pt; height: 100pt; object-fit: cover; flex: none; }
.cv-sec { margin-top: 12pt; }
.cv-sec-title {
  font-size: 11pt; font-weight: bold; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1.2pt solid #111; padding-bottom: 2pt; margin-bottom: 6pt;
}
.cv-entry { margin-bottom: 8pt; }
.cv-entry-top { display: flex; justify-content: space-between; gap: 12pt; }
.cv-role { font-weight: bold; font-size: 10.5pt; }
.cv-org { font-size: 10.5pt; color: #222; }
.cv-dates { font-size: 9.5pt; color: #333; white-space: nowrap; }
.cv-bullets { margin: 3pt 0 0 14pt; padding: 0; }
.cv-bullets li { margin-top: 1.5pt; }
.cv-summary { text-align: justify; }
.cv-skill-line { margin-top: 2pt; }
.cv-skill-line b { font-weight: bold; }
.cv-empty {
  color: #888; text-align: center; padding: 60pt 20pt 0; font-family: var(--font-sans);
}
.cv-empty .big { font-size: 15pt; font-weight: 700; color: #555; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 560px; padding: 20px;
}
.modal-title { font-weight: 700; font-size: 15px; }
.modal-sub { font-size: 12.5px; color: var(--muted-foreground); margin: 4px 0 12px; }
.modal textarea {
  width: 100%; border: 1px solid var(--border); background: var(--background); color: var(--foreground);
  border-radius: 8px; padding: 10px; font-size: 12px; font-family: var(--font-mono); resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--foreground); color: var(--background); font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; z-index: 200; opacity: 0;
  transition: transform .25s ease, opacity .25s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- mobile ---------- */
.mobile-tabs { display: none; }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview { display: none; position: static; height: auto; border-left: none; }
  body[data-tab="preview"] .preview { display: block; }
  body[data-tab="preview"] .editor { display: none; }
  .mobile-tabs {
    display: flex; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    z-index: 90; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 4px; gap: 4px; box-shadow: 0 4px 24px rgba(0,0,0,.18);
  }
  .mtab { border: none; background: none; color: var(--muted-foreground); font-weight: 700; font-size: 13px; padding: 8px 22px; border-radius: 9px; cursor: pointer; }
  .mtab.active { background: var(--foreground); color: var(--background); }
  .topbar-actions .btn:not(.primary):not(#btnDocx) { display: none; }
  .preview-inner { padding: 16px 10px 120px; }
}

/* ---------- print: only the sheet ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  .topbar, .editor, .mobile-tabs, .page-note, .modal-backdrop, .toast { display: none !important; }
  .workspace { display: block !important; max-width: none !important; }
  .preview { display: block !important; position: static !important; height: auto !important; overflow: visible !important; border: none !important; background: #fff !important; }
  .preview-inner { display: block !important; padding: 0 !important; }
  .sheet-wrap { display: block !important; height: auto !important; overflow: visible !important; }
  .sheet {
    width: auto; min-height: 0;
    box-shadow: none !important; transform: none !important;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
}
