﻿/* =========================================================
   ÉDITEUR DE CV — DESIGN MODERNE
   ========================================================= */

/* --- Barre de sections horizontale --- */
.editor-sections-bar {
    max-width: var(--container);
    margin: 0 auto 1rem;
    width: min(100% - 2rem, var(--container));
    overflow-x: auto;
}

.section-list-horizontal {
    display: flex;
    gap: 0.4rem;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    min-width: fit-content;
}

.section-list-horizontal button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--muted);
    transition: all 200ms ease;
    white-space: nowrap;
    position: relative;
}

.section-list-horizontal button .section-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.5;
}

.section-list-horizontal button .section-check {
    opacity: 0;
    width: 14px;
    height: 14px;
    color: #22c55e;
    flex-shrink: 0;
    transition: opacity 200ms ease;
}

.section-list-horizontal button.filled .section-check { opacity: 1; }

.section-list-horizontal button .section-badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 700;
}

.section-list-horizontal button:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 127, 0, 0.1);
}

.section-list-horizontal button.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 127, 0, 0.25);
    box-shadow: 0 4px 12px rgba(255, 127, 0, 0.1);
}

.section-list-horizontal button.active .section-icon { opacity: 1; }

/* --- Layout principal (2 colonnes égales) --- */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    min-height: 75vh;
    padding-bottom: 2rem;
}

/* --- Barre d'outils supérieure --- */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    max-width: var(--container);
    margin: 0 auto 1rem;
    width: min(100% - 2rem, var(--container));
    position: relative;
    overflow: hidden;
}

.editor-toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0.6;
}

.editor-toolbar-left { display: flex; align-items: center; gap: 0.75rem; }
.editor-toolbar-left .brand { font-size: 1.05rem; }
.editor-toolbar-left .brand img { height: 28px; }
.editor-toolbar-left .brand span { font-size: 1rem; }

.editor-toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 200ms ease;
    white-space: nowrap;
}

.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.toolbar-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 127, 0, 0.15);
    transform: translateY(-1px);
}

.toolbar-btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(255, 127, 0, 0.25);
    padding: 0.5rem 1.1rem;
}

.toolbar-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(255, 127, 0, 0.35);
    color: #fff;
    background: var(--primary-gradient);
}

.toolbar-divider { width: 1px; height: 28px; background: var(--line); flex-shrink: 0; }

/* --- Sidebar formulaire --- */
.editor-sidebar {
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0.85rem;
    position: sticky;
    top: 5.5rem;
    align-self: start;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
}

.editor-sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.3rem 0.85rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.75rem;
}

.editor-sidebar-header svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }
.editor-sidebar-header h3 { margin: 0; font-size: 0.92rem; font-weight: 700; }

.section-list { display: grid; gap: 0.35rem; }

.section-list button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.75rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.84rem;
    color: var(--muted);
    transition: all 220ms ease;
}

.section-list button .section-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.section-list button .section-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 700;
}

.section-list button .section-check {
    opacity: 0;
    width: 16px;
    height: 16px;
    color: #22c55e;
    flex-shrink: 0;
    transition: opacity 220ms ease;
}

.section-list button.filled .section-check { opacity: 1; }

.section-list button:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 127, 0, 0.1);
    transform: translateX(3px);
}

.section-list button.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(255, 127, 0, 0.25);
    box-shadow: 0 4px 12px rgba(255, 127, 0, 0.1);
    transform: translateX(3px);
}

.section-list button.active .section-icon { opacity: 1; }

/* --- Formulaire --- */
.editor-form {
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.editor-form section { display: none; }
.editor-form section.active-section { display: block; animation: fadeInSection 300ms ease both; }

@keyframes fadeInSection {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--line);
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.section-header-left svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }
.section-header-left h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.section-header .section-count {
    font-size: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}

.form-grid { display: grid; gap: 0.85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.field { display: grid; gap: 0.3rem; }
.field.full-width { grid-column: 1 / -1; }

.field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.field label .required { color: #ef4444; font-size: 0.75rem; }
.field label .label-hint { font-weight: 400; font-size: 0.72rem; opacity: 0.6; }

.editor-field, .editor-textarea, .editor-select {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    outline: none;
    transition: all 220ms ease;
    font-family: inherit;
}

.editor-field:hover, .editor-textarea:hover, .editor-select:hover { border-color: rgba(255, 127, 0, 0.25); }

.editor-field:focus, .editor-textarea:focus, .editor-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 127, 0, 0.1);
}

.editor-field::placeholder, .editor-textarea::placeholder { color: var(--muted); opacity: 0.5; }
.editor-textarea { min-height: 80px; resize: vertical; line-height: 1.5; }

.field-hint { font-size: 0.7rem; color: var(--muted); opacity: 0.6; margin-top: 0.1rem; }

/* --- Entrées dynamiques --- */
.dynamic-entry {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    margin-bottom: 0.75rem;
    padding: 0.85rem 0.85rem 0.75rem;
    transition: all 220ms ease;
    position: relative;
    overflow: hidden;
}

.dynamic-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 220ms ease;
}

.dynamic-entry:hover { border-color: rgba(255, 127, 0, 0.2); }
.dynamic-entry:hover::before { opacity: 0.6; }

.dynamic-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.dynamic-entry-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dynamic-entry-title .entry-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
}

.dynamic-entry .entry-actions { display: flex; gap: 0.3rem; }

.dynamic-entry .entry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 180ms ease;
}

.dynamic-entry .entry-btn:hover { background: rgba(239,68,68,0.1); color: #ef4444; }
.dynamic-entry .entry-btn.move-up:hover, .dynamic-entry .entry-btn.move-down:hover { background: var(--surface-2); color: var(--text); }
.dynamic-entry .entry-btn svg { width: 15px; height: 15px; }
.dynamic-entry .form-row { margin-bottom: 0.4rem; }

.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem;
    border-radius: 12px;
    border: 2px dashed var(--line);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 220ms ease;
    margin-top: 0.35rem;
}

.add-btn svg { width: 18px; height: 18px; transition: transform 220ms ease; }

.add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.add-btn:hover svg { transform: rotate(90deg); }

/* =============================================================
   PRÉVISUALISATION — TEMPLATE EXACT
   ============================================================= */
.editor-preview {
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    position: sticky;
    top: 5.5rem;
    align-self: start;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--line);
}

.preview-header-left { display: flex; align-items: center; gap: 0.5rem; }
.preview-header-left svg { width: 18px; height: 18px; color: var(--primary); }
.preview-header-left h3 { margin: 0; font-size: 0.85rem; font-weight: 700; }
.preview-header .preview-actions { display: flex; gap: 0.3rem; }

.preview-header .preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 180ms ease;
}

.preview-header .preview-btn:hover { background: var(--surface-2); color: var(--primary); }
.preview-header .preview-btn svg { width: 16px; height: 16px; }

/* --- Canvas A4-like --- */
.preview-canvas {
    min-height: 700px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    overflow: hidden;
    position: relative;
}

/* --- Layout 2 colonnes du CV --- */
.cv-template {
    display: table;
    width: 100%;
    min-height: 700px;
    font-family: 'Poppins', sans-serif;
    color: #222;
    line-height: 1.5;
    table-layout: fixed;
}

/* --- COLONNE GAUCHE (#F5F5F5) --- */
.cv-left {
    background: #f5f5f5;
    padding: 1.5rem 0.85rem;
    display: table-cell;
    vertical-align: top;
    width: 30%;
    box-sizing: border-box;
}

/* Photo */
.cv-photo-wrapper {
    text-align: center;
    margin-bottom: 0.5rem;
}

.cv-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto;
    display: block;
    border: 3px solid #1F5D78;
}

.cv-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #dde;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #1F5D78;
    color: #1F5D78;
    font-size: 2.5rem;
    font-weight: 700;
}

/* Titres colonne gauche */
.cv-left-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1F5D78;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0.3rem 0 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid #1F5D78;
}

/* Compétences & Langues avec barre */
.cv-skill-item, .cv-language-item {
    margin-bottom: 0.4rem;
}

.cv-skill-name, .cv-language-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.15rem;
}

.cv-skill-bar, .cv-language-bar {
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
}

.cv-skill-fill, .cv-language-fill {
    height: 100%;
    background: #1F5D78;
    border-radius: 3px;
    transition: width 300ms ease;
}

/* Centres d'intérêt */
.cv-interest-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    color: #444;
    margin-bottom: 0.25rem;
}

.cv-interest-item::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #1F5D78;
    flex-shrink: 0;
    border-radius: 1px;
}

/* --- COLONNE DROITE --- */
.cv-right {
    background: #fff;
    padding: 1.5rem 2rem 1.5rem 1.5rem;
    display: table-cell;
    vertical-align: top;
    width: auto;
    box-sizing: border-box;
}

/* En-tête */
.cv-header-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.1rem;
    line-height: 1.1;
}

.cv-header-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1F5D78;
    margin: 0 0 0.5rem;
}

/* Infos personnelles (icônes) */
.cv-contact-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.8rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.cv-contact-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #555;
}

.cv-contact-item svg {
    width: 14px;
    height: 14px;
    color: #1F5D78;
    flex-shrink: 0;
}

/* Sections colonne droite */
.cv-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1F5D78;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0.5rem 0 0.3rem;
    padding-bottom: 0.15rem;
    border-bottom: 2px solid #1F5D78;
}

.cv-profile-text {
    font-size: 0.75rem;
    color: #444;
    line-height: 1.6;
    margin: 0 0 0.25rem;
    text-align: justify;
}

/* Items (expérience, formation) */
.cv-item {
    margin-bottom: 0.5rem;
}

.cv-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.cv-item-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #222;
}

.cv-item-date {
    font-size: 0.68rem;
    color: #888;
    font-weight: 500;
    white-space: nowrap;
}

.cv-item-sub {
    font-size: 0.72rem;
    color: #555;
    font-weight: 500;
}

.cv-item-desc {
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.1rem;
    line-height: 1.4;
}

/* --- Actions en bas --- */
.editor-actions-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: var(--container);
    margin: 1rem auto 0;
    width: min(100% - 2rem, var(--container));
}

.editor-actions-bottom .action-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: grid;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: auto;
    animation: toastIn 300ms ease both;
    max-width: 360px;
}

.toast.success { border-color: rgba(34,197,94,0.3); background: linear-gradient(135deg, #f0fdf4, #fafbfe); }
.toast.error { border-color: rgba(239,68,68,0.3); background: linear-gradient(135deg, #fef2f2, #fafbfe); }
.toast.info { border-color: rgba(59,130,246,0.3); background: linear-gradient(135deg, #eff6ff, #fafbfe); }

html[data-theme="dark"] .toast.success { background: linear-gradient(135deg, #052e16, #131b24); }
html[data-theme="dark"] .toast.error { background: linear-gradient(135deg, #450a0a, #131b24); }
html[data-theme="dark"] .toast.info { background: linear-gradient(135deg, #172554, #131b24); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: #22c55e; }
.toast.error svg { color: #ef4444; }
.toast.info svg { color: #3b82f6; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(100%) scale(0.9); }
}

/* --- Dark mode preview --- */
html[data-theme="dark"] .preview-canvas { border-color: var(--line); }
html[data-theme="dark"] .cv-left { background: #1a2330; }
html[data-theme="dark"] .cv-right { background: #131b24; }
html[data-theme="dark"] .cv-template { color: #eef4fb; }
html[data-theme="dark"] .cv-header-name { color: #eef4fb; }
html[data-theme="dark"] .cv-contact-line { border-bottom-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .cv-skill-name, html[data-theme="dark"] .cv-language-name { color: #ccc; }
html[data-theme="dark"] .cv-interest-item { color: #aaa; }
html[data-theme="dark"] .cv-profile-text { color: #aaa; }
html[data-theme="dark"] .cv-item-title { color: #eef4fb; }
html[data-theme="dark"] .cv-item-sub { color: #aaa; }
html[data-theme="dark"] .cv-item-desc { color: #999; }
html[data-theme="dark"] .cv-section-title { border-bottom-color: rgba(31,93,120,0.5); }
/* --- Responsive --- */
@media (max-width: 1200px) {
    .editor-layout { grid-template-columns: minmax(0,1fr) 360px; }
}

@media (max-width: 1024px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-preview { position: static; }
    .form-row { grid-template-columns: 1fr; }
    .section-list-horizontal { flex-wrap: wrap; }
}

@media (max-width: 640px) {
    .cv-left, .cv-right { display: block; width: 100%; }
    .cv-template { display: block; }
    .editor-toolbar { flex-wrap: wrap; }
    .editor-form { padding: 0.85rem; }
    .editor-actions-bottom { flex-direction: column; align-items: stretch; }
    .editor-actions-bottom .action-group { flex-direction: column; }
    .section-list-horizontal button { font-size: 0.7rem; padding: 0.4rem 0.5rem; }
}