/* FreeCV — app UI (everything except the resume itself) */

:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #dde1e7;
  --line-strong: #c5ccd6;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --focus: #2f6fdf;
  --danger: #b42318;
  --warn-bg: #fff6e0;
  --warn-line: #f0d48a;
  --radius: 8px;
  --topbar-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181e;
    --panel: #1c2129;
    --panel-2: #222832;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --line: #2e3540;
    --line-strong: #3d4552;
    --brand: #8fb3e8;
    --brand-ink: #0f1722;
    --focus: #7aa7ff;
    --danger: #ff7b72;
    --warn-bg: #2e2714;
    --warn-line: #5e4c1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.ic { width: 18px; height: 18px; flex: none; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.logo {
  width: 28px; height: 28px; border-radius: 7px; background: var(--brand); flex: none;
  background-image: linear-gradient(var(--brand-ink), var(--brand-ink)), linear-gradient(var(--brand-ink), var(--brand-ink)), linear-gradient(var(--brand-ink), var(--brand-ink));
  background-size: 14px 2.5px, 14px 2.5px, 9px 2.5px;
  background-position: 7px 8px, 7px 13px, 7px 18px;
  background-repeat: no-repeat;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-tag { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: 6px; }
.ctl-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

select {
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23778' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  appearance: none;
  cursor: pointer;
}

.swatches { display: flex; gap: 6px; align-items: center; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line-strong);
  padding: 0; cursor: pointer;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.swatch-custom {
  position: relative; overflow: hidden;
  background: conic-gradient(#e5484d, #f5a524, #46a758, #0090ff, #8e4ec6, #e5484d);
}
.swatch-custom input { position: absolute; inset: -8px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }

.actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { background: var(--panel-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-danger { color: var(--danger); }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  display: flex; flex-direction: column;
}
.menu-list button {
  text-align: left; padding: 8px 10px; border: 0; border-radius: 5px; background: none; cursor: pointer;
}
.menu-list button:hover { background: var(--panel-2); }

/* ---------- Banner ---------- */

.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
}
.banner[hidden] { display: none; }
.banner p { margin: 0; flex: 1 1 280px; }
.banner-actions { display: flex; gap: 6px; }

/* ---------- Layout ---------- */

.tabs { display: none; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
}

.editor {
  overflow-y: auto;
  padding: 16px;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}

.preview {
  overflow: auto;
  padding: 20px 24px 40px;
  min-width: 0;
}

.preview-meta {
  max-width: 820px; margin: 0 auto 10px;
  color: var(--muted); font-size: 12px;
  display: flex; justify-content: space-between; gap: 12px;
}

.sheet-frame { margin: 0 auto; position: relative; }

.sheet {
  --page-w: 210mm;
  --page-h: 297mm;
  --page-m: 15mm;
  position: relative;
  width: var(--page-w);
  min-height: var(--page-h);
  padding: var(--page-m);
  background: #fff;
  color: #111;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 30px rgba(0,0,0,.10);
  transform-origin: top left;
}
.sheet.paper-letter { --page-w: 8.5in; --page-h: 11in; }

.guides { position: absolute; inset: 0; pointer-events: none; }
.guide {
  position: absolute; left: 0; right: 0;
  border-top: 1px dashed #e0697a;
}
.guide span {
  position: absolute; right: 6px; top: 2px;
  font: 600 10px/1 var(--font); color: #d14d60; background: #fff; padding: 2px 4px;
}

@media (max-width: 899px) {
  .brand-tag { display: none; }
  .topbar { gap: 10px; padding: 8px 12px; }
  .controls { order: 3; width: 100%; gap: 12px; }
  .actions { margin-left: auto; }
  #btn-import, #btn-export { display: none; }

  .tabs {
    display: flex;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  .tabs button {
    flex: 1; padding: 10px; border: 0; background: none; cursor: pointer;
    font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent;
  }
  .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }

  .workspace { display: block; overflow: auto; }
  .workspace[data-view="edit"] .preview { display: none; }
  .workspace[data-view="preview"] .editor { display: none; }
  .editor { border-right: 0; padding: 12px; }
  .preview { padding: 12px; }
}

.menu-list .mobile-only { display: none; }
@media (max-width: 899px) {
  .menu-list .mobile-only { display: block; }
}

@media (max-width: 520px) {
  .btn-primary .ic { display: none; }
  .ctl-label { display: none; }
}

/* ---------- Editor ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.card.is-hidden { opacity: .6; }
.card.is-hidden .card-body { display: none; }

.card-head {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 4px;
}
.card-head .toggle {
  display: flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 6px; cursor: pointer; border-radius: 5px;
  color: var(--muted);
}
.card-head .toggle:hover { background: var(--panel-2); }
.card-head .toggle .ic { transition: transform .15s; }
.is-open > .card-head .toggle .ic,
.is-open > .entry-head .toggle .ic { transform: rotate(90deg); }

.sec-title {
  flex: 1; min-width: 0;
  font-weight: 650; font-size: 15px;
  border: 1px solid transparent; border-radius: 5px;
  padding: 5px 6px;
  background: transparent;
}
.sec-title:hover { border-color: var(--line); }
.sec-title:focus { border-color: var(--line-strong); background: var(--panel); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent); }
.sec-fixed-title { flex: 1; font-weight: 650; font-size: 15px; padding: 5px 6px; }

.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 5px; background: none; cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); }

.card-body { padding: 4px 14px 14px; display: none; }
.is-open > .card-body { display: block; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
}
.field textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
.hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

.links { display: flex; flex-direction: column; gap: 6px; }
.link-row { display: flex; gap: 4px; }
.link-row input { flex: 1; }

.entry {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-top: 10px;
  background: var(--panel);
}
.entry-head {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 4px 4px 2px;
}
.entry-head .toggle {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 6px; cursor: pointer; border-radius: 5px;
  text-align: left;
}
.entry-head .toggle:hover { background: var(--panel-2); }
.entry-head .toggle .ic { color: var(--muted); transition: transform .15s; }
.entry-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.entry-label.empty { color: var(--muted); font-weight: 400; font-style: italic; }
.entry-body { display: none; padding: 4px 12px 12px; }
.entry.is-open > .entry-body { display: block; }

.add-btn {
  margin-top: 10px; width: 100%;
  border-style: dashed; color: var(--muted);
}
.add-btn:hover { color: var(--text); }

.editor-foot {
  color: var(--muted); font-size: 12px; text-align: center;
  padding: 8px 8px 24px;
}
.editor-foot a { color: inherit; }

/* ---------- Toast & dialogs ---------- */

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px;
  background: #1c2430; color: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  z-index: 20;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.toast .btn-ghost { color: #9cc3ff; }
.toast .btn-ghost:hover { background: rgba(255,255,255,.1); }

.dialog {
  border: 0; border-radius: 12px;
  padding: 22px 24px 18px;
  width: min(460px, calc(100% - 32px));
  background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.dialog::backdrop { background: rgba(15, 20, 28, .45); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog p, .dialog li { line-height: 1.5; }
.dialog ol, .dialog ul { padding-left: 20px; }
.muted { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- Print: only the resume ---------- */

@media print {
  html, body { height: auto; background: #fff !important; display: block; }
  .topbar, .banner, .tabs, .editor, .preview-meta, .toast, .guides, dialog { display: none !important; }
  .workspace, .preview { display: block !important; overflow: visible !important; padding: 0 !important; margin: 0 !important; }
  .sheet-frame { width: auto !important; height: auto !important; margin: 0 !important; }
  .sheet {
    transform: none !important;
    width: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
}
