* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2d6cdf;
    --primary-dark: #1f4fa3;
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --text: #1f2433;
    --text-muted: #6a7180;
    --border: #e6e8ee;
    --danger: #d04848;
    --shadow: 0 4px 16px rgba(0,0,0,0.06);
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color .2s ease;
}
a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

h1, h2, h3 { line-height: 1.3; }

/* navbar */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}
.nav-brand:hover { text-decoration: none; color: var(--primary); }
.nav-links {
    list-style: none;
    display: flex;
    gap: 1.4rem;
}
.nav-links a {
    color: var(--text);
    font-weight: 500;
    font-size: .95rem;
    position: relative;
}
.nav-links a:hover {
    color: var(--primary);
    text-decoration: none;
}
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -6px;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease;
}
.nav-links a:hover::after { transform: scaleX(1); }
.nav-edit {
    background: var(--primary);
    color: #fff !important;
    padding: .35rem .9rem;
    border-radius: 6px;
}
.nav-edit:hover { background: var(--primary-dark); }
.nav-edit::after { display: none; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text);
}

/* switch de langue FR / EN */
.lang-switch {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .82rem;
    font-weight: 600;
}
.lang-switch a {
    color: var(--text-muted);
    padding: .15rem .35rem;
    border-radius: 5px;
}
.lang-switch a:hover { color: var(--primary); text-decoration: none; }
.lang-switch a.active {
    color: #fff;
    background: var(--primary);
}
.lang-switch a.active:hover { color: #fff; background: var(--primary-dark); }
.lang-switch a::after { display: none; }
.lang-sep { color: var(--border); }

/* layout */
.layout {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

.sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
}

.profile-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.8rem 1.4rem;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeUp .5s ease both;
}

.avatar {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 0 0 3px var(--primary);
    margin: 0 auto 1rem;
    display: block;
    transition: transform .3s ease;
}
.avatar:hover { transform: scale(1.04); }

.avatar-placeholder {
    background: var(--primary);
    color: white;
    font-size: 2.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-card h1 {
    font-size: 1.4rem;
    margin-bottom: .4rem;
}

.contact {
    list-style: none;
    margin: 1rem 0;
    text-align: left;
}
.contact li {
    padding: .4rem 0;
    color: var(--text-muted);
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.contact .ico {
    color: var(--primary);
    width: 18px;
    text-align: center;
}
.contact a { color: var(--text); }
.contact a:hover { color: var(--primary); }

/* cards */
.content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: fadeUp .5s ease both;
}
.card-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.card-header h2 {
    font-size: 1.2rem;
    color: var(--text);
}
.toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: transform .25s ease;
}
.collapsible:not(.open) .toggle { transform: rotate(180deg); }

.card-body {
    padding: 1.4rem;
    max-height: 5000px;
    transition: max-height .4s ease, padding .3s ease, opacity .3s ease;
    opacity: 1;
    overflow: hidden;
}
.collapsible:not(.open) .card-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* timeline */
.timeline {
    list-style: none;
    position: relative;
    padding-left: 1.5rem;
    border-left: 2px solid var(--border);
}
.timeline-item {
    position: relative;
    padding: 0 0 1.4rem .5rem;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -2.05rem;
    top: .35rem;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid var(--bg);
    transition: transform .25s ease;
}
.timeline-item:hover .timeline-dot { transform: scale(1.25); }

.timeline-content h3 {
    font-size: 1.05rem;
    margin-bottom: .15rem;
}
.dates {
    display: inline-block;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
.timeline-content p {
    color: #444;
    font-size: .95rem;
}

/* skills */
.skills-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.skill {
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .7rem .9rem;
    transition: transform .2s ease, box-shadow .2s ease;
}
.skill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.skill-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .4rem;
}
.skill-name { font-weight: 600; }
.skill-level {
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #eef2fb;
    color: var(--primary-dark);
}
.skill-level.skill-expert     { background: #e7f7ed; color: #1f7a3b; }
.skill-level.skill-proficient { background: #eaf0fc; color: #1f4fa3; }
.skill-level.skill-beginner   { background: #fdf1e1; color: #a86a1f; }

.skill-bar {
    background: #eef0f4;
    border-radius: 6px;
    height: 6px;
    overflow: hidden;
}
.skill-bar-fill {
    background: var(--primary);
    height: 100%;
    border-radius: 6px;
    transition: width 1s ease;
}

.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
    padding: 1rem 0 2rem;
}
.footer-edit {
    margin-top: .35rem;
    font-size: .72rem;
}
.footer-edit a {
    color: var(--text-muted);
    text-decoration: none;
    opacity: .55;
    transition: opacity .2s ease, color .2s ease;
}
.footer-edit a:hover {
    opacity: 1;
    color: var(--primary);
    text-decoration: none;
}

.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* page edit */
.edit-page { background: var(--bg); }

.edit-wrapper {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.edit-wrapper > h1 {
    font-size: 1.7rem;
    margin-bottom: .5rem;
}

.flash {
    background: #e7f7ed;
    color: #1f7a3b;
    padding: .8rem 1rem;
    border-radius: 8px;
    border: 1px solid #c5e5d2;
    animation: fadeUp .3s ease both;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }

.form-grid label {
    display: flex;
    flex-direction: column;
    font-size: .9rem;
    color: var(--text-muted);
    gap: .35rem;
}
.form-grid label small {
    font-size: .8rem;
    color: #aaa;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    font-family: inherit;
    font-size: .95rem;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease;
    color: var(--text);
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45,108,223,.15);
}

textarea { resize: vertical; }

.form-actions {
    display: flex;
    gap: .6rem;
    justify-content: flex-end;
    margin-top: .3rem;
}

.btn {
    cursor: pointer;
    border: none;
    padding: .55rem 1.2rem;
    border-radius: 6px;
    font-size: .92rem;
    font-weight: 500;
    transition: all .2s ease;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #b03b3b; color: #fff; text-decoration: none; }

.btn-small { padding: .3rem .7rem; font-size: .85rem; }

.btn-edit {
    margin-top: .8rem;
    background: var(--primary);
    color: #fff;
    width: 100%;
}
.btn-edit:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.edit-row {
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.card-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.skills-edit-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: .5rem;
}
.skill-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto auto;
    gap: .5rem;
    align-items: center;
    padding: .5rem;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.skill-row input,
.skill-row select {
    padding: .4rem .55rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: .9rem;
    font-family: inherit;
}
.skill-row input:focus,
.skill-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(45,108,223,.15);
}

@media (max-width: 600px) {
    .skill-row { grid-template-columns: 1fr 1fr; }
}

/* profil : titre / accroche / resume */
.profile-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: .3rem;
}
.profile-tagline {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
.summary-card { animation: fadeUp .5s ease both; }
.summary-text {
    color: #444;
    font-size: .97rem;
    font-style: italic;
}

/* projets : lien externe */
.proj-link {
    font-size: .9rem;
    text-decoration: none;
}
.proj-link:hover { text-decoration: none; }

/* langues */
.lang-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .7rem;
}
.lang-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .9rem;
}
.lang-name { font-weight: 600; }
.lang-level {
    font-size: .8rem;
    color: var(--primary-dark);
    background: #eef2fb;
    padding: 2px 10px;
    border-radius: 10px;
}

/* certifications (pilules) */
.pill-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.pill-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .6rem .9rem;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.pill-name { font-weight: 600; }
.pill-meta {
    font-size: .82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* publications */
.pub-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.pub-item h3 { font-size: 1.02rem; margin-bottom: .15rem; }
.pub-item p { color: #444; font-size: .93rem; }

/* login */
.login-wrapper {
    max-width: 440px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}
.login-card { animation: fadeUp .5s ease both; }
.login-intro {
    color: var(--text-muted);
    font-size: .92rem;
    margin-bottom: 1rem;
}
.flash-error {
    background: #fdecec;
    color: #a33;
    border-color: #f3c9c9;
}
.logout-form { margin: 0; display: inline; }
.logout-form button {
    cursor: pointer;
    border: none;
    font: inherit;
}

/* bouton export PDF (navbar) */
.nav-pdf {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: .85rem;
    color: #fff;
    background: var(--primary);
    border: none;
    padding: .35rem .8rem;
    border-radius: 6px;
    transition: background .2s ease, transform .15s ease;
}
.nav-pdf:hover { background: var(--primary-dark); transform: translateY(-1px); }

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

/* ============================================================
   Export PDF : tout le contenu est verse dans #pdf-flow (construit
   par main.js) et coule dans 2 colonnes EQUILIBREES en hauteur.
   Les grosses listes (Experience, Projets) se repartissent donc
   sur les 2 colonnes au lieu de s'empiler -> hauteur ~divisee par 2.
   Police racine + espacements reduits pour densifier, puis un zoom
   final garantit la page unique.
   Regles dupliquees en .printing (mesure) et @media print (rendu).
   ============================================================ */

/* ---- reglages communs de compaction (partages ecran-mesure + impression) ---- */
.printing .navbar,
.printing .nav-toggle,
.printing .toggle,
.printing .footer-edit,
.printing .footer,
.printing .nav-pdf-li,
.printing .layout > .sidebar,
.printing .layout > .content,
.printing #pdf-flow .toggle { display: none !important; }

.printing { background: #fff; font-size: 11px; } /* pose sur <html> -> reduit les rem */
.printing .layout {
    display: block !important;
    width: 715px !important;      /* zone imprimable A4 (194mm) */
    max-width: 715px !important;
    margin: 0 auto;
    padding: 0;
}
#pdf-flow {
    column-count: 2;
    column-gap: 12px;
    column-fill: balance;
}
#pdf-flow > * { margin: 0 0 .6rem !important; }
/* les gros blocs peuvent se couper entre colonnes... (overflow visible sinon
   la carte devient monolithique et refuse de se couper) */
#pdf-flow .card { break-inside: auto; overflow: visible !important; box-shadow: none; border: 1px solid var(--border); }
/* ...mais pas un element individuel */
#pdf-flow .profile-card,
#pdf-flow .summary-card,
#pdf-flow .timeline-item,
#pdf-flow .skill,
#pdf-flow .lang-item,
#pdf-flow .pill-item,
#pdf-flow .pub-item { break-inside: avoid; }
#pdf-flow .profile-card { padding: 1rem .9rem; box-shadow: none; border: 1px solid var(--border); text-align: center; }
#pdf-flow .avatar { width: 84px; height: 84px; margin-bottom: .5rem; }
#pdf-flow .profile-card h1 { font-size: 1.25rem; }
#pdf-flow .contact { margin: .5rem 0; }
#pdf-flow .contact li { padding: .18rem 0; }
#pdf-flow .card-header { padding: .5rem .9rem; }
#pdf-flow .card-header h2 { font-size: 1.05rem; }
#pdf-flow .card-body { padding: .7rem .9rem !important; }
#pdf-flow .timeline-item { padding-bottom: .6rem; }
#pdf-flow .timeline-content p,
#pdf-flow .summary-text,
#pdf-flow .pub-item p { font-size: .9rem; line-height: 1.3; }
/* grilles en 1 colonne (chaque colonne ne fait que ~345px) */
#pdf-flow .skills-list,
#pdf-flow .lang-list { grid-template-columns: 1fr !important; gap: .4rem; }
/* forcer toutes les sections ouvertes, meme repliees */
#pdf-flow .collapsible .card-body,
#pdf-flow .collapsible:not(.open) .card-body {
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
}
.printing * { animation: none !important; }

@media print {
    @page { size: A4 portrait; margin: 8mm; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; animation: none !important; }
    html { scroll-behavior: auto; font-size: 11px; }
    body { background: #fff; }
    .navbar, .nav-toggle, .toggle, .footer-edit, .footer, .nav-pdf-li,
    .layout > .sidebar, .layout > .content { display: none !important; }
    .layout {
        display: block !important;
        width: 715px !important;
        max-width: 715px !important;
        margin: 0 auto;
        padding: 0;
    }
    #pdf-flow { column-count: 2; column-gap: 12px; column-fill: balance; }
    #pdf-flow > * { margin: 0 0 .6rem !important; }
    #pdf-flow .card { break-inside: auto; overflow: visible !important; box-shadow: none; border: 1px solid var(--border); }
    #pdf-flow .profile-card,
    #pdf-flow .summary-card,
    #pdf-flow .timeline-item,
    #pdf-flow .skill,
    #pdf-flow .lang-item,
    #pdf-flow .pill-item,
    #pdf-flow .pub-item { break-inside: avoid; }
    #pdf-flow .profile-card { padding: 1rem .9rem; box-shadow: none; border: 1px solid var(--border); text-align: center; }
    #pdf-flow .avatar { width: 84px; height: 84px; margin-bottom: .5rem; }
    #pdf-flow .profile-card h1 { font-size: 1.25rem; }
    #pdf-flow .contact { margin: .5rem 0; }
    #pdf-flow .contact li { padding: .18rem 0; }
    #pdf-flow .card-header { padding: .5rem .9rem; }
    #pdf-flow .card-header h2 { font-size: 1.05rem; }
    #pdf-flow .card-body { padding: .7rem .9rem !important; }
    #pdf-flow .timeline-item { padding-bottom: .6rem; }
    #pdf-flow .timeline-content p, #pdf-flow .summary-text, #pdf-flow .pub-item p { font-size: .9rem; line-height: 1.3; }
    #pdf-flow .skills-list, #pdf-flow .lang-list { grid-template-columns: 1fr !important; gap: .4rem; }
    #pdf-flow .collapsible .card-body,
    #pdf-flow .collapsible:not(.open) .card-body {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
}

/* responsive */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
}

@media (max-width: 700px) {
    .nav-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: #fff;
        flex-direction: column;
        padding: 1rem 1.5rem;
        gap: .8rem;
        border-bottom: 1px solid var(--border);
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease, padding .3s ease;
    }
    .nav-links.open {
        max-height: 400px;
        padding: 1rem 1.5rem;
    }
    .form-grid { grid-template-columns: 1fr; }
}
