@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Lora:ital,wght@0,400;1,600&family=Merriweather:ital,wght@0,400;1,700&family=Playfair+Display:ital,wght@1,600&display=swap');

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
}

/* ---------- CV (public + preview) ---------- */

.cv {
    display: flex;
    width: 100%;
    max-width: 850px;
    min-height: 1000px;
    background: #fff;
    box-shadow: 0 4px 28px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
    font-family: var(--font-corps, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: calc(1rem * var(--taille-texte-ratio, 1));
}

.cv-sidebar {
    width: var(--sidebar-width, 34%);
    background: var(--accent, #1f3550);
    color: #fff;
    padding: 2.25rem 1.5rem;
    flex-shrink: 0;
}

.cv-photo {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.cv-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-photo-placeholder { font-size: calc(2.2rem * var(--taille-texte-ratio, 1)); font-weight: 600; letter-spacing: 1px; }

.cv-section { margin-top: 1.75rem; }
.cv-section:first-of-type { margin-top: 0; }

/* Titre de section unifié : chaque section peut atterrir dans la colonne claire ou
   sombre selon le réglage "colonne" — le style s'adapte à l'ancêtre réel, pas au
   type de section. */
.cv-section-heading {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.75rem;
    padding-bottom: 0.4rem;
}
.cv-sidebar .cv-section-heading {
    font-size: calc(0.75rem * var(--taille-texte-ratio, 1));
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    opacity: 0.9;
}
.cv-main .cv-section-heading {
    font-size: calc(0.95rem * var(--taille-texte-ratio, 1));
    color: var(--accent, #1f3550);
    border-bottom: 2px solid var(--accent, #1f3550);
    margin-bottom: 1.1rem;
}

.cv-contact p { font-size: calc(0.85rem * var(--taille-texte-ratio, 1)); margin: 0 0 0.4rem; opacity: 0.92; word-break: break-word; }

.cv-skill-group h4 {
    font-size: calc(0.78rem * var(--taille-texte-ratio, 1));
    text-transform: uppercase;
    opacity: 0.7;
    margin: 0.85rem 0 0.4rem;
    letter-spacing: 0.4px;
}
.cv-skill-group:first-child h4 { margin-top: 0; }

.cv-skill { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: calc(0.85rem * var(--taille-texte-ratio, 1)); margin-bottom: 0.5rem; }
.cv-skill.cv-skill-full { display: block; }
.cv-skill.cv-skill-full > span { display: block; width: 100%; line-height: 1.4; }
.cv-skill-icon { margin-right: 0.4rem; }
.cv-skill-icon-img { width: 1em; height: 1em; object-fit: contain; vertical-align: -0.15em; display: inline-block; }
.cv-bar { flex-shrink: 0; width: 60px; height: 5px; border-radius: 3px; overflow: hidden; }
.cv-bar-fill { height: 100%; border-radius: 3px; }
.cv-sidebar .cv-bar { background: rgba(255, 255, 255, 0.25); }
.cv-sidebar .cv-bar-fill { background: #fff; }
.cv-main .cv-bar { background: rgba(0, 0, 0, 0.12); }
.cv-main .cv-bar-fill { background: var(--accent, #1f3550); }

.cv-links { list-style: none; margin: 0; padding: 0; }
.cv-links li { margin-bottom: 0.5rem; font-size: calc(0.8rem * var(--taille-texte-ratio, 1)); }
.cv-link-label { display: block; font-weight: 600; margin-bottom: 0.1rem; }
.cv-links a { text-decoration: underline dotted; word-break: break-all; opacity: 0.9; }
.cv-sidebar .cv-links a { color: #fff; }
.cv-main .cv-links a { color: var(--accent, #1f3550); }

.cv-bloc-titre {
    font-family: var(--font-titres, 'Playfair Display', Georgia, serif);
    font-style: italic;
    font-weight: 600;
    font-size: calc(1.2rem * var(--taille-texte-ratio, 1));
    line-height: 1.3;
    margin: 0 0 1rem;
}
.cv-sidebar .cv-bloc-titre { color: #fff; }
.cv-bloc-sousgroupe { margin-bottom: 1.1rem; }
.cv-bloc-sousgroupe-titre {
    font-size: calc(0.72rem * var(--taille-texte-ratio, 1));
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 0.4rem;
    margin: 0 0 0.6rem;
}
.cv-sidebar .cv-bloc-sousgroupe-titre { color: rgba(255, 255, 255, 0.75); border-bottom: 1px solid rgba(255, 255, 255, 0.25); }
.cv-main .cv-bloc-sousgroupe-titre { color: rgba(0, 0, 0, 0.6); border-bottom: 1px solid rgba(0, 0, 0, 0.15); }
.cv-bloc-items { list-style: none; margin: 0; padding: 0; }
.cv-bloc-items li {
    font-size: calc(0.85rem * var(--taille-texte-ratio, 1));
    line-height: 1.45;
    padding-left: 1rem;
    position: relative;
    margin-bottom: 0.5rem;
}
.cv-sidebar .cv-bloc-items li { opacity: 0.95; }
.cv-bloc-items li::before { content: '—'; position: absolute; left: 0; opacity: 0.6; }

.cv-main { flex: 1; padding: 2.5rem 2.75rem; min-width: 0; color: #1c1917; }

.cv-header h1 { font-size: calc(2rem * var(--taille-texte-ratio, 1)); margin: 0 0 0.15rem; color: var(--accent, #1f3550); letter-spacing: -0.5px; }
.cv-titre { font-size: calc(1.05rem * var(--taille-texte-ratio, 1)); color: #57534e; margin: 0 0 1.5rem; }

.cv-bio p { color: #333; line-height: 1.65; margin: 0 0 1.75rem; white-space: pre-line; }

.cv-timeline { display: flex; flex-direction: column; gap: 1.15rem; }
.cv-item { position: relative; padding-left: 1rem; border-left: 2px solid #eee; }
.cv-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent, #1f3550);
}
.cv-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.cv-item-head strong { font-size: calc(1rem * var(--taille-texte-ratio, 1)); }
.cv-period { font-size: calc(0.8rem * var(--taille-texte-ratio, 1)); white-space: nowrap; }
.cv-item-sub { font-size: calc(0.9rem * var(--taille-texte-ratio, 1)); margin: 0.2rem 0 0.4rem; }
.cv-item-desc { font-size: calc(0.88rem * var(--taille-texte-ratio, 1)); line-height: 1.55; margin: 0; white-space: pre-line; }
.cv-main .cv-item { border-left-color: #eee; }
.cv-main .cv-item-head strong { color: #1c1917; }
.cv-main .cv-period { color: #a8a29e; }
.cv-main .cv-item-sub { color: #57534e; }
.cv-main .cv-item-desc { color: #44403c; }
.cv-sidebar .cv-item { border-left-color: rgba(255, 255, 255, 0.3); }
.cv-sidebar .cv-item-head strong { color: #fff; }
.cv-sidebar .cv-period { color: rgba(255, 255, 255, 0.65); }
.cv-sidebar .cv-item-sub { color: rgba(255, 255, 255, 0.85); }
.cv-sidebar .cv-item-desc { color: rgba(255, 255, 255, 0.8); }

.cv-aparte {
    background: #f3f2ef;
    border-left: 3px solid var(--accent, #1f3550);
    border-radius: 0 8px 8px 0;
    padding: 1.15rem 1.4rem;
    margin-top: 1.75rem;
}
.cv-aparte-header { display: flex; align-items: baseline; gap: 0.65rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.cv-aparte-titre {
    font-family: var(--font-titres, 'Playfair Display', Georgia, serif);
    font-style: italic;
    font-weight: 600;
    font-size: calc(1.1rem * var(--taille-texte-ratio, 1));
    margin: 0;
    color: #1c1917;
}
.cv-aparte-tag {
    font-size: calc(0.68rem * var(--taille-texte-ratio, 1));
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    color: var(--accent, #1f3550);
    opacity: 0.85;
}
.cv-aparte-grid { display: flex; flex-wrap: wrap; gap: 0.9rem 1.5rem; }
.cv-aparte-item { width: 100%; }
.cv-main .cv-aparte-item { width: calc(50% - 0.75rem); }
.cv-aparte-item h4 { font-size: calc(0.86rem * var(--taille-texte-ratio, 1)); margin: 0 0 0.3rem; color: #1c1917; font-weight: 600; }
.cv-aparte-item p { font-size: calc(0.82rem * var(--taille-texte-ratio, 1)); color: #57534e; line-height: 1.5; margin: 0; white-space: pre-line; }

/* ---------- Login / landing ---------- */

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f5f5f4; }
.login-card { background: #fff; padding: 2.5rem; border-radius: 14px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07); width: 340px; max-width: 90vw; }
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; color: #1f3550; }
.login-sub { color: #78716c; font-size: 0.9rem; margin: 0 0 1.5rem; }
.login-card label { display: block; font-size: 0.8rem; color: #57534e; margin: 0.9rem 0 0.3rem; }
.login-card input { width: 100%; padding: 0.6rem 0.7rem; border: 1px solid #d6d3d1; border-radius: 8px; font-size: 0.9rem; }
.login-card button { width: 100%; margin-top: 1.25rem; padding: 0.65rem; border: none; border-radius: 8px; background: #1f3550; color: #fff; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.login-card button:hover { opacity: 0.92; }
.login-error { color: #991b1b; background: #fee2e2; padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.85rem; margin: 0 0 0.5rem; }
.login-back { display: block; text-align: center; margin-top: 1.25rem; font-size: 0.8rem; color: #78716c; text-decoration: none; }

/* ---------- Public CV page ---------- */

.public-body { background: #e7e5e0; min-height: 100vh; }
.public-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid #e5e5e0;
}
.public-wrap { display: flex; justify-content: center; padding: 2.5rem 1.5rem; }
.badge-private { font-size: 0.78rem; padding: 0.25rem 0.65rem; border-radius: 999px; background: #fef3c7; color: #92400e; margin-right: auto; }

/* ---------- Buttons ---------- */

.btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem; border-radius: 8px; border: none; font-size: 0.85rem; cursor: pointer; text-decoration: none; font-weight: 500; }
.btn-primary { background: #1f3550; color: #fff; }
.btn-danger { background: #b91c1c; }
.btn-ghost { background: transparent; color: #44403c; border: 1px solid #d6d3d1; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.btn:hover { opacity: 0.9; }

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

.editor-body { background: #f5f5f4; }
.editor-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e5e5e0;
    gap: 1rem;
    flex-wrap: wrap;
}
.editor-topbar-left, .editor-topbar-right { display: flex; align-items: center; gap: 0.65rem; }
.topbar-logo { font-weight: 700; color: #1c1917; text-decoration: none; }
.topbar-logo:hover { color: #1f3550; }

.save-status { font-size: 0.78rem; padding: 0.22rem 0.65rem; border-radius: 999px; background: #eee; color: #666; }
.save-status[data-state="saving"] { background: #fef3c7; color: #92400e; }
.save-status[data-state="saved"] { background: #dcfce7; color: #166534; }
.save-status[data-state="error"] { background: #fee2e2; color: #991b1b; }

.badge-admin { font-size: 0.75rem; padding: 0.22rem 0.65rem; border-radius: 999px; background: #ede9fe; color: #5b21b6; }

.editor-layout { display: flex; height: calc(100vh - 57px); }
.editor-form { width: 420px; min-width: 340px; overflow-y: auto; padding: 1.25rem; background: #fafaf9; border-right: 1px solid #e5e5e0; }
.editor-preview { flex: 1; overflow-y: auto; background: #e7e5e0; padding: 2.5rem 1.5rem; }
.editor-preview-inner { display: flex; justify-content: center; }

/* Repère de fin de page A4 (297mm ≈ 1123px à 96dpi) : largeur alignée sur la largeur
   réelle d'impression (A4, marges nulles) pour que le repère tombe au bon endroit. */
.editor-preview .cv {
    max-width: 794px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 1120px,
        rgba(217, 119, 6, 0.85) 1120px,
        rgba(217, 119, 6, 0.85) 1123px,
        transparent 1123px,
        transparent 1123px
    );
}

.form-card { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.form-card h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px; color: #78716c; margin: 0 0 0.9rem; }
.colonne-select { display: block; margin: -0.5rem 0 0.9rem; font-size: 0.78rem; padding: 0.3rem 0.5rem; border: 1px solid #d6d3d1; border-radius: 6px; color: #57534e; background: #fff; }

.field { display: block; font-size: 0.8rem; color: #57534e; margin-bottom: 0.75rem; font-weight: 500; }
.field input, .field textarea, .field select {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #d6d3d1;
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
    color: #1c1917;
}
.field input[type="color"] { padding: 0.2rem; height: 2.4rem; cursor: pointer; }
.field textarea { resize: vertical; }
.field-pair { display: flex; gap: 0.75rem; }
.field-pair .field { flex: 1; }

.photo-crop { margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid #e5e5e0; }
.photo-crop-preview {
    margin: 0 auto 0.6rem;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    border: 2px solid #d6d3d1;
    background: #f0efec;
}
.photo-crop-preview:active { cursor: grabbing; }
.photo-crop-preview img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.shape-buttons { display: flex; gap: 0.4rem; margin-top: 0.3rem; }
.shape-btn {
    flex: 1;
    padding: 0.4rem;
    border: 1px solid #d6d3d1;
    border-radius: 6px;
    background: #fff;
    font-size: 0.78rem;
    cursor: pointer;
    color: #57534e;
}
.shape-btn.active { background: #1f3550; color: #fff; border-color: #1f3550; }

.repeat-item { border: 1px solid #e5e5e0; border-radius: 8px; padding: 0.85rem; margin-bottom: 0.85rem; background: #fcfcfb; }
.repeat-item-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.repeat-item-title { font-size: 0.8rem; font-weight: 600; color: #57534e; }
.repeat-item-actions button {
    border: none; background: #f0efec; width: 26px; height: 26px; border-radius: 6px;
    cursor: pointer; margin-left: 0.3rem; font-size: 0.85rem; color: #44403c;
}
.repeat-item-actions button.danger { background: #fee2e2; color: #b91c1c; }
.repeat-item-actions button:disabled { opacity: 0.3; cursor: default; }

.sub-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0; }
.sub-item { display: flex; gap: 0.4rem; align-items: center; }
.sub-item input { flex: 1; padding: 0.45rem 0.55rem; border: 1px solid #d6d3d1; border-radius: 6px; font-size: 0.85rem; min-width: 0; }
.sub-item select { padding: 0.45rem; border: 1px solid #d6d3d1; border-radius: 6px; font-size: 0.85rem; }
.sub-item select.icon-select { flex: 0 0 68px; max-width: 68px; }
.sub-item button.danger { border: none; background: #fee2e2; color: #b91c1c; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; flex-shrink: 0; }
.sub-item-link input:first-child { flex: 0 0 34%; }

.icon-pick-btn {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid #d6d3d1;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}
.icon-pick-btn img { width: 100%; height: 100%; object-fit: contain; }

.icon-picker { padding: 1.5rem; max-height: 80vh; overflow-y: auto; }
.icon-upload-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.icon-upload-label { cursor: pointer; }
.icon-grid-category { margin-bottom: 1rem; }
.icon-grid-category h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: #78716c; margin: 0 0 0.5rem; }
.icon-grid-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.icon-grid-btn {
    width: 38px;
    height: 38px;
    border: 1px solid #d6d3d1;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-grid-btn:hover { background: #f0efec; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: #292524; margin-bottom: 0.5rem; }
.hint { font-size: 0.78rem; color: #a8a29e; }
.public-link { font-size: 0.8rem; color: #166534; word-break: break-all; }

/* ---------- Dialogs ---------- */

dialog { border: none; border-radius: 12px; padding: 0; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); max-width: 420px; width: 90%; }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog form, .versions-panel { padding: 1.5rem; }
dialog h2, .versions-panel h2 { margin: 0 0 1rem; font-size: 1.1rem; color: #1c1917; }
dialog label { display: block; font-size: 0.85rem; margin-bottom: 0.9rem; color: #44403c; }
dialog input { width: 100%; margin-top: 0.3rem; padding: 0.5rem 0.6rem; border: 1px solid #d6d3d1; border-radius: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

.versions-list { list-style: none; padding: 0; margin: 1rem 0; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.version-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; border: 1px solid #e5e5e0; border-radius: 8px; font-size: 0.85rem; }

/* ---------- Admin ---------- */

.admin-body { background: #f5f5f4; }
.admin-main { max-width: 900px; margin: 2rem auto; padding: 0 1.25rem 3rem; display: flex; flex-direction: column; gap: 1.5rem; }
.admin-card { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 1.5rem; }
.admin-card h2 { margin-top: 0; font-size: 1rem; color: #1c1917; }
.admin-form { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.admin-form label { display: flex; flex-direction: column; font-size: 0.8rem; color: #57534e; gap: 0.3rem; }
.admin-form input, .admin-form select { padding: 0.5rem 0.6rem; border: 1px solid #d6d3d1; border-radius: 6px; font-size: 0.88rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid #efeeea; }
.admin-table-actions { display: flex; gap: 0.4rem; }
.admin-callout { background: #dcfce7; color: #166534; padding: 0.85rem 1rem; border-radius: 8px; font-size: 0.9rem; }
.admin-callout code { background: rgba(0, 0, 0, 0.06); padding: 0.15rem 0.4rem; border-radius: 4px; font-weight: 600; }
.admin-callout-error { background: #fee2e2; color: #991b1b; }

/* ---------- Print ---------- */

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    .no-print { display: none !important; }
    body { background: #fff !important; }
    .public-wrap, .editor-preview, .editor-preview-inner { padding: 0 !important; margin: 0 !important; background: #fff !important; }
    .editor-layout { display: block !important; height: auto !important; }
    .editor-form { display: none !important; }
    .cv { box-shadow: none !important; border-radius: 0 !important; max-width: 100% !important; overflow: visible !important; min-height: 0 !important; }
    .cv-item, .cv-skill-group, .cv-bloc, .cv-bloc-sousgroupe, .cv-aparte, .cv-aparte-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    @page { size: A4; margin: 0; }
}
