*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

:root {
  --bg:      #f6f4f0;
  --surface: #ffffff;
  --ink:     #18181b;
  --ink2:    #3f3f46;
  --muted:   #a1a1aa;
  --line:    #e4e4e7;
  --line2:   #f1f0ed;
  --accent:  #18181b;
  --panel:   360px;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ─────────────────────────────── */
.topbar {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 200;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  font-family: 'Lora', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand-badge {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--surface);
  background: #16a34a;
  padding: 2px 6px;
  border-radius: 3px;
}

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

.btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 16px;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #27272a; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.18); }

.ats-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: #16a34a;
  font-weight: 500;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 4px 10px;
  border-radius: 20px;
}
.ats-dot { width: 6px; height: 6px; background: #16a34a; border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── WORKSPACE ──────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: var(--panel) 1fr;
  flex: 1;
  height: calc(100vh - 54px);
  overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.tabs {
  display: flex;
  position: sticky; top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.tab {
  flex: 1;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  padding: 13px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab:hover:not(.active) { color: var(--ink2); }

.tab-panel { display: none; padding: 20px 18px 40px; }
.tab-panel.active { display: block; }

.sec-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  margin-top: 20px;
}
.sec-label:first-child { margin-top: 0; }

.fg { display: grid; gap: 9px; }
.fg2 { grid-template-columns: 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 0.65rem; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  outline: none;
  border-radius: 6px;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}
.field input:focus, .field textarea:focus { border-color: var(--ink); background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #d4d4d8; }
.field textarea { resize: vertical; min-height: 68px; }

.sep { height: 1px; background: var(--line2); margin: 16px 0; }

/* Blocks */
.block-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.block-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.block-item:hover { border-color: #d4d4d8; }
.block-hd {
  display: flex; align-items: center;
  padding: 9px 11px; cursor: pointer; user-select: none; gap: 7px;
}
.block-grip { color: #d4d4d8; font-size: 0.6rem; }
.block-title { font-size: 0.78rem; font-weight: 600; color: var(--ink2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-del { background: none; border: none; color: #d4d4d8; cursor: pointer; font-size: 0.75rem; padding: 1px 4px; transition: color 0.15s; }
.block-del:hover { color: #ef4444; }
.block-chev { color: #d4d4d8; font-size: 0.55rem; transition: transform 0.2s; flex-shrink: 0; }
.block-item.open .block-chev { transform: rotate(90deg); }
.block-bd { display: none; padding: 11px; border-top: 1px solid var(--line2); background: var(--bg); }
.block-item.open .block-bd { display: block; }

.add-btn {
  width: 100%; padding: 8px;
  background: transparent; border: 1.5px dashed var(--line);
  color: var(--muted); font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.73rem; font-weight: 600;
  cursor: pointer; border-radius: 8px;
  transition: all 0.15s; margin-top: 4px;
}
.add-btn:hover { border-color: var(--muted); color: var(--ink); background: var(--bg); }

/* Skills chips */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.68rem; font-weight: 500;
  padding: 3px 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 20px; color: var(--ink2);
  animation: pop 0.12s ease;
}
@keyframes pop { from{transform:scale(0.8);opacity:0} to{transform:scale(1);opacity:1} }
.chip-x { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.65rem; line-height: 1; }
.chip-x:hover { color: #ef4444; }

.skill-row { display: flex; gap: 6px; }
.skill-row input { flex: 1; }
.skill-add-btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.75rem; font-weight: 600;
  padding: 7px 12px; background: var(--ink); color: #fff;
  border: none; cursor: pointer; border-radius: 6px; transition: background 0.15s;
}
.skill-add-btn:hover { background: #27272a; }

/* Accent dots */
.dot-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.dot {
  width: 20px; height: 20px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: all 0.15s; flex-shrink: 0;
}
.dot:hover { transform: scale(1.12); }
.dot.on { outline-color: var(--ink); }
input[type=color].dot { padding: 0; background: none; border: 1.5px dashed var(--line); overflow: hidden; cursor: pointer; }

/* ── PREVIEW AREA ───────────────────────── */
.preview-area {
  background: #e8e6e1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.preview-bar {
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-lbl {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b0ada6;
}

.ats-checklist { display: flex; gap: 10px; align-items: center; }
.ats-check {
  font-size: 0.65rem;
  color: #16a34a;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLET
   ══════════════════════════════════════════ */

/* ── Mobile preview toggle button ── */
.mobile-preview-btn {
  display: none;
}
@media (max-width: 700px) {
  .mobile-preview-btn {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

/* ── Tablet (≤ 1000px) ── */
@media (max-width: 1000px) {
  :root { --panel: 300px; }
  .preview-area { padding: 20px 14px; }
  .ats-checklist { display: none; }

  #cv-paper {
    transform-origin: top center;
    transform: scale(0.72);
    margin-bottom: -200px;
  }
}

/* ── Mobile (≤ 700px) ── */
@media (max-width: 700px) {
  body { overflow-x: hidden; }

  .topbar {
    padding: 0 12px;
    height: 48px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .brand-logo { font-size: 1rem; }
  .brand-badge { display: none; }
  .topbar-actions { gap: 5px; }
  .btn { font-size: 0.68rem; padding: 6px 10px; }
  .ats-status { display: none; }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    min-height: calc(100dvh - 48px);
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    height: auto;
  }
  .sidebar.hidden { display: none; }

  .tabs { gap: 0; }
  .tab { font-size: 0.68rem; padding: 12px 6px; }

  .tab-panel { padding: 16px 14px 28px; }

  .fg2 { grid-template-columns: 1fr; }

  .field input,
  .field textarea,
  .field select {
    font-size: 1rem;
    padding: 9px 11px;
  }
  .field textarea { min-height: 60px; }

  .block-title { font-size: 0.73rem; }
  .block-bd { padding: 10px; }

  .chips { gap: 5px; }
  .chip { font-size: 0.7rem; padding: 4px 9px; }

  .dot { width: 24px; height: 24px; }
  .dot-row { gap: 9px; }

  /* Preview area: pas de padding horizontal, overflow caché */
  .preview-area {
    padding: 14px 0 30px;
    background: #e8e6e1;
    align-items: center;
    overflow-x: hidden;
  }
  .preview-area.hidden { display: none; }

  .preview-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 0 14px;
    width: 100%;
  }
  .ats-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .ats-check { font-size: 0.58rem; }

  /*
   * CV paper : centrage mathématique après scale
   * transform-origin: top left + translateX calcule exactement
   * l'espace restant de chaque côté : (100vw - 794 * scale) / 2
   */
  #cv-paper {
    width: 794px;
    transform-origin: top left;
    transform:
      translateX(calc((100vw - 794px * var(--cv-mobile-scale, 0.44)) / 2))
      scale(var(--cv-mobile-scale, 0.44));
    /* Compense l'espace fantôme : hauteur_visuelle - hauteur_réelle
       ≈ (1123 * 0.44) - 1123 = -629px */
    margin-bottom: -550px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.18);
  }

  .sep { margin: 12px 0; }
  .sec-label { margin-top: 14px; }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
  .topbar { padding: 0 8px; }
  .btn { font-size: 0.62rem; padding: 5px 8px; }
  .brand-logo { font-size: 0.9rem; }
  #cv-paper {
    transform-origin: top left;
    transform:
      translateX(calc((100vw - 794px * 0.37) / 2))
      scale(0.37);
    margin-bottom: -600px;
  }
}

/* ── Landscape mobile ── */
@media (max-width: 750px) and (orientation: landscape) {
  .workspace {
    grid-template-columns: 280px 1fr;
    height: calc(100dvh - 48px);
    overflow: hidden;
  }
  .sidebar {
    border-right: 1px solid var(--line);
    border-bottom: none;
    overflow-y: auto;
    height: 100%;
  }
  .sidebar.hidden { display: block; }
  .preview-area.hidden { display: flex; }
  #cv-paper {
    transform-origin: top left;
    /* Soustrait la largeur du sidebar (280px) pour centrer dans le panneau droit */
    transform:
      translateX(calc((100vw - 280px - 794px * 0.55) / 2))
      scale(0.55);
    margin-bottom: -450px;
  }
  .mobile-preview-btn { display: none; }
}

/* ── CV PAPER (base) ────────────────────── */
#cv-paper {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  box-shadow: 0 2px 40px rgba(0,0,0,0.1);
  flex-shrink: 0;
  padding: 56px 64px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10pt;
  color: #1a1a1a;
  line-height: 1.5;
}

.cv-header {
  text-align: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--cv-accent, #18181b);
}

.cv-name {
  font-family: Georgia, serif;
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1a1a1a;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.cv-jobtitle {
  font-family: Georgia, serif;
  font-size: 11pt;
  font-style: italic;
  color: var(--cv-accent, #18181b);
  margin-bottom: 10px;
}

.cv-contact-line {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
  color: #555;
  line-height: 1.8;
}
.cv-contact-sep { margin: 0 6px; color: #bbb; }

.cv-section { margin-bottom: 20px; }

.cv-section-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cv-accent, #18181b);
  padding-bottom: 5px;
  border-bottom: 1.5px solid var(--cv-accent, #18181b);
  margin-bottom: 12px;
}

.cv-summary-text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9.5pt;
  color: #333;
  line-height: 1.7;
}

.cv-entry {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0f0f0;
}
.cv-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.cv-entry-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 1px;
}

.cv-entry-title {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10pt;
  font-weight: 700;
  color: #1a1a1a;
}

.cv-entry-date {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
  color: #777;
  white-space: nowrap;
  flex-shrink: 0;
}

.cv-entry-org {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  font-style: italic;
  color: #555;
  margin-bottom: 5px;
}

.cv-entry-desc {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  color: #444;
  line-height: 1.65;
}

.cv-skills-grid { display: flex; flex-wrap: wrap; gap: 4px 0; }
.cv-skill-kw {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  color: #333;
}
.cv-skill-kw::after { content: ' · '; color: #bbb; }
.cv-skill-kw:last-child::after { content: ''; }

.cv-lang-item {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  color: #333;
  display: inline;
}
.cv-lang-item::after { content: ' · '; color: #bbb; }
.cv-lang-item:last-child::after { content: ''; }

.cv-interests-text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  color: #555;
}

.cv-ph {
  font-family: Arial, sans-serif;
  font-size: 9pt;
  color: #ccc;
  font-style: italic;
}

.cv-footer {
  margin-top: 32px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-family: Arial, sans-serif;
  font-size: 7.5pt;
  color: #aaa;
  text-align: center;
}
