/* =====================================================================
   Générateur de CV — Corentin Cuzeau
   Écran : atelier sombre (éditeur + aperçu A4). Impression : A4 propre.
   ===================================================================== */

:root {
  --bg:        #0f1320;   /* fond atelier */
  --panel:     #171c2c;   /* panneaux */
  --panel-2:   #1f2538;   /* champs */
  --border:    #2a3147;
  --text:      #e8ebf2;
  --muted:     #9aa3bd;
  --muted-2:   #6c7693;
  --primary:   #2468d6;
  --primary-2: #d69224;

  /* Couleur d'accent du CV (modifiable via la toolbar) */
  --accent:    #2468d6;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --head: "Poppins", var(--sans);

  --sheet-w: 210mm;
  --sheet-h: 297mm;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ----------------------------- Toolbar ------------------------------ */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem clamp(0.8rem, 3vw, 1.75rem);
  background: rgba(15, 19, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.toolbar a.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.toolbar a.back:hover { color: var(--text); }
.toolbar a.back::before { content: "\2190"; margin-right: 0.45em; }

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}

/* Segmented control (thèmes) */
.seg {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Swatches couleur */
.swatches { display: inline-flex; gap: 0.35rem; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--sw);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--sw); }

/* Toggle photo */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Boutons */
.btn-primary, .btn-ghost {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn-primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted-2); }

/* ----------------------------- Workspace ---------------------------- */
.workspace {
  min-height: calc(100vh - 60px);
}

/* ----------------------------- Aperçu -------------------------------- */
.preview-stage {
  padding: 1.75rem clamp(0.5rem, 2vw, 2rem) 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
}
.preview-hint {
  max-width: var(--sheet-w);
  margin: 1.25rem auto 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.preview-hint i { color: var(--accent); }
.hint-private { display: inline-block; margin-top: 0.4rem; color: var(--muted-2); }
.hint-private i { color: var(--accent); }

/* =====================================================================
   La feuille A4 (commune)
   ===================================================================== */
.cv-sheet {
  --ink:      #1f2430;
  --ink-soft: #525a6b;
  --line:     #e4e7ee;

  width: var(--sheet-w);
  min-height: var(--sheet-h);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
  overflow: hidden;
  font-size: 10.5pt;
  line-height: 1.5;
}

.cv-sheet h1, .cv-sheet h2, .cv-sheet h3 { margin: 0; font-family: var(--head); }

/* En-tête nom + titre */
.cv-name { font-size: 23pt; font-weight: 700; line-height: 1.1; letter-spacing: 0.01em; }
.cv-name .cv-ln { color: var(--accent); }
.cv-role { font-size: 11.5pt; font-weight: 500; color: var(--ink-soft); margin-top: 2px; }

/* Titre de section */
.cv-sec-title {
  font-size: 10.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}
.cv-sec-title::after {
  content: "";
  flex: 1;
  height: 2px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 1px;
}
.cv-sec { margin-bottom: 0.95rem; }
.cv-sec:last-child { margin-bottom: 0; }

/* Entrées expériences / formations */
.cv-entry { margin-bottom: 0.7rem; }
.cv-entry:last-child { margin-bottom: 0; }
.cv-entry-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.cv-entry-role { font-weight: 700; font-size: 10.8pt; }
.cv-entry-period {
  font-size: 8.6pt;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  padding: 1px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.cv-entry-org { font-size: 9.6pt; font-weight: 600; color: var(--ink-soft); margin-top: 1px; }
.cv-entry-desc { font-size: 9.5pt; color: #444b59; margin-top: 3px; }
.cv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cv-tag {
  font-size: 8pt;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, #fff);
  padding: 1px 7px;
  border-radius: 4px;
}

/* Listes (compétences, langues, intérêts) */
.cv-chiplist { display: flex; flex-wrap: wrap; gap: 5px; }
.cv-chip {
  font-size: 8.8pt;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  color: var(--accent);
}
.cv-skillgroup { margin-bottom: 0.5rem; }
.cv-skillgroup:last-child { margin-bottom: 0; }
.cv-skillgroup-label { font-size: 9pt; font-weight: 700; margin-bottom: 3px; }

.cv-lang { display: flex; justify-content: space-between; font-size: 9.4pt; margin-bottom: 3px; }
.cv-lang .lvl { color: var(--ink-soft); }

.cv-contact-line { display: flex; align-items: center; gap: 0.45rem; font-size: 9.2pt; margin-bottom: 4px; }
.cv-contact-line i { width: 14px; text-align: center; color: var(--accent); }
.cv-contact-line a { text-decoration: none; color: inherit; word-break: break-word; }

/* Lignes visibles uniquement au téléchargement (PDF), masquées à l'écran */
.cv-print-only { display: none !important; }

/* ---------------------- THÈME : Sidebar ----------------------------- */
.theme-sidebar { display: grid; grid-template-columns: 34% 66%; }
.theme-sidebar .cv-aside {
  background: var(--accent);
  color: #fff;
  padding: 18mm 7mm 12mm;
}
.theme-sidebar .cv-aside .cv-sec-title {
  color: #fff;
}
.theme-sidebar .cv-aside .cv-sec-title::after { background: rgba(255, 255, 255, 0.35); }
.theme-sidebar .cv-aside .cv-contact-line i { color: rgba(255, 255, 255, 0.85); }
.theme-sidebar .cv-aside .cv-chip {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.theme-sidebar .cv-aside .cv-lang .lvl { color: rgba(255, 255, 255, 0.8); }

.theme-sidebar .cv-photo {
  width: 42mm;
  height: 42mm;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 12px;
  border: 3px solid rgba(255, 255, 255, 0.5);
}
.theme-sidebar .cv-main { padding: 14mm 12mm 12mm; }
.theme-sidebar .cv-main .cv-header { margin-bottom: 0.9rem; }

/* ---------------------- THÈME : Classique --------------------------- */
.theme-classic { padding: 14mm 14mm 12mm; }
.theme-classic .cv-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 0.8rem;
  margin-bottom: 0.9rem;
  border-bottom: 2px solid var(--accent);
}
.theme-classic .cv-photo {
  width: 26mm;
  height: 26mm;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  flex: 0 0 auto;
}
.theme-classic .cv-header-text { flex: 1; }
.theme-classic .cv-contacts-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
}
.theme-classic .cv-contacts-inline .cv-contact-line { margin-bottom: 0; }
.theme-classic .cv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.4rem; }
/* Bas du CV classique : Compétences (2/3, groupes en 2×2) + Langues/Intérêts (1/3) sur une seule bande */
.theme-classic .cv-bottom { display: grid; grid-template-columns: 2fr 1fr; gap: 0 1.4rem; }
.theme-classic .cv-bottom-skills .cv-sec { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.2rem; row-gap: 0.1rem; }
.theme-classic .cv-bottom-skills .cv-sec-title { grid-column: 1 / -1; }
.theme-classic .cv-chip {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff);
}

/* ----------------------- Responsive atelier ------------------------- */
@media (max-width: 480px) {
  .toolbar-controls { gap: 0.6rem; }
  .control-label { display: none; }
}

/* =====================================================================
   IMPRESSION — seule la feuille A4 est imprimée
   ===================================================================== */
@media print {
  @page { size: A4; margin: 0; }

  html, body { background: #fff !important; }
  .toolbar, .preview-hint { display: none !important; }

  .workspace { display: block; }
  .preview-stage { padding: 0; overflow: visible; }

  .cv-sheet {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none !important;
    border-radius: 0;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .theme-sidebar { grid-template-columns: 34% 66%; }

  /* Téléphone + localisation : révélés uniquement à l'impression */
  .cv-print-only { display: flex !important; }

  /* Resserrage léger pour garantir une seule page A4 */
  .cv-sheet { font-size: 10pt; }
  .theme-sidebar .cv-aside { padding: 12mm 6mm 8mm; }
  .theme-sidebar .cv-main { padding: 10mm 10mm 8mm; }
  .theme-classic { padding: 10mm 12mm 9mm; }
  .cv-sec { margin-bottom: 0.6rem; }
  .cv-entry { margin-bottom: 0.5rem; }
  .cv-entry-desc { margin-top: 2px; }
  .cv-tags { margin-top: 3px; }

  /* Le thème classique (1 colonne) est plus haut : resserrage modéré */
  .cv-sheet.theme-classic { font-size: 9.2pt; }
  .theme-classic { padding: 9mm 12mm 8mm; }
  .theme-classic .cv-name { font-size: 18.5pt; }
  .theme-classic .cv-photo { width: 22mm; height: 22mm; }
  .theme-classic .cv-header { padding-bottom: 0.4rem; margin-bottom: 0.45rem; }
  .theme-classic .cv-entry { margin-bottom: 0.2rem; }
  .theme-classic .cv-entry-desc { font-size: 8.9pt; line-height: 1.3; }
  .theme-classic .cv-sec { margin-bottom: 0.32rem; }
  .theme-classic .cv-skillgroup { margin-bottom: 0.18rem; }
  .theme-classic .cv-skillgroup-label { font-size: 8.2pt; margin-bottom: 1px; }
  .theme-classic .cv-chip { font-size: 8pt; padding: 1px 6px; }
  .theme-classic .cv-chiplist { gap: 3px; }
  .theme-classic .cv-bottom-skills .cv-sec { row-gap: 0.05rem; }
}
