/* ============================================================
   ZeTraining — Identité "école de code"
   Palette : indigo électrique / encre / lime
   Typo : Space Grotesk (titres) · Inter (texte) · JetBrains Mono (code)
   ============================================================ */
:root {
    --ink: #0E1016;
    --ink-2: #1A1D29;
    --primary: #5A4FF3;
    --primary-dark: #4338E0;
    --primary-soft: #EDEBFE;
    --lime: #C6F432;
    --bg: #F4F5FA;
    --surface: #FFFFFF;
    --text: #23252F;
    --muted: #7A7E8F;
    --line: #E6E8F0;
    --success: #17B26A;
    --success-soft: #E3F8EE;
    --warning: #F5A524;
    --warning-soft: #FEF4E2;
    --danger: #E5484D;
    /* Alias utilisés par le module communauté/social (menus, modales, pagination, badges).
       Sans ces alias, ces déclarations CSS restaient invalides (variable jamais définie),
       ce qui produisait des fonds/textes invisibles ou illisibles (ex: "Modifier" en texte
       sombre sur fond sombre par défaut du navigateur). */
    --card: var(--surface);
    --border: var(--line);
    --accent: var(--primary);
    --hover: var(--primary-soft);
    --radius: 14px;
    --shadow: 0 1px 3px rgba(14,16,22,.06), 0 8px 24px rgba(14,16,22,.05);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
.display { font-family: var(--font-display); letter-spacing: -.02em; }
.mono { font-family: var(--font-mono); }
h1.display { font-size: 1.9rem; font-weight: 700; }
h2 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============ Sidebar (app shell) ============ */
body.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; height: 100vh; position: sticky; top: 0; flex-shrink: 0;
    background: var(--ink); color: #fff;
    display: flex; flex-direction: column; padding: 22px 14px;
    overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; }
.brand-mark {
    font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem;
    background: var(--lime); color: var(--ink);
    width: 34px; height: 34px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark.lg { width: 46px; height: 46px; font-size: 1.5rem; border-radius: 12px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.brand-cursor { color: var(--lime); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: #B9BDCE; text-decoration: none; font-weight: 500; font-size: .93rem;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--ink-2); color: #fff; }
.nav-admin { margin-top: 10px; border: 1px dashed rgba(198,244,50,.35); color: var(--lime); }
.nav-admin:hover { background: rgba(198,244,50,.08); color: var(--lime); }

.sidebar-footer { border-top: 1px solid var(--ink-2); padding-top: 14px; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; font-size: .95rem;
}
.avatar.sm { width: 30px; height: 30px; font-size: .85rem; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ffffff; }
.user-role { font-family: var(--font-mono); font-size: .7rem; color: var(--lime); }
.logout-link { color: #8A8FA3; display: inline-flex; padding: 6px; border-radius: 8px; }
.logout-link:hover { color: #fff; background: var(--ink-2); }
.logout-link svg { width: 18px; height: 18px; }

.main-content { flex: 1; padding: 34px 40px; max-width: 1150px; margin-left: auto; margin-right: auto; width: 100%; }

/* ============ En-tête de page ============ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 26px; }
.eyebrow { font-family: var(--font-mono); font-size: .78rem; color: var(--primary); font-weight: 700; margin-bottom: 4px; }

/* ============ Cartes & formulaires ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, textarea, select {
    width: 100%; padding: 10px 13px; margin-bottom: 12px;
    border: 1.5px solid var(--line); border-radius: 10px;
    font: inherit; background: #FBFBFE; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: #fff; }
input[type="file"] { padding: 8px; background: #fff; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: .9rem; color: var(--text); font-weight: 500; }
.form-grid { display: flex; flex-direction: column; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============ Boutons ============ */
.btn {
    border: none; border-radius: 10px; padding: 10px 18px;
    font: inherit; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost-danger { background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: #FDECEC; }
.btn-sm { padding: 6px 13px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; padding: 2px 0; }
.btn-link:hover { color: var(--primary); }
.btn-link.join { color: var(--primary); font-weight: 600; }

/* ============ Tables ============ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
th { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: none; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user small { color: var(--muted); }
.cell-course { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.mini-banner { width: 46px; height: 30px; object-fit: cover; border-radius: 6px; }

/* ============ Tags & tokens ============ */
.tag { font-family: var(--font-mono); padding: 4px 10px; border-radius: 8px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.tag-active { background: var(--success-soft); color: var(--success); }
.tag-pending { background: var(--warning-soft); color: var(--warning); }
.tag-free { background: var(--primary-soft); color: var(--primary); }
code { font-family: var(--font-mono); background: var(--ink); color: var(--lime); padding: 3px 9px; border-radius: 7px; font-size: .84rem; font-weight: 700; letter-spacing: .08em; }
.token-line { font-size: .84rem; color: var(--muted); margin-top: 8px; }
.mono-tag {
    font-family: var(--font-mono); font-size: .76rem; font-weight: 700;
    background: var(--ink); color: var(--lime); padding: 5px 11px; border-radius: 8px;
}

/* ============ Stats admin ============ */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--ink); color: #fff; border-radius: var(--radius); padding: 20px 22px;
    display: flex; flex-direction: column; gap: 2px;
}
.stat-card:first-child { background: var(--primary); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--lime); }
.stat-card:first-child .stat-value { color: #fff; }
.stat-label { font-size: .82rem; opacity: .75; }

/* ============ Auth (login / register) ============ */
body.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.guest-content { width: 100%; }
.auth-wrap { display: flex; justify-content: center; padding: 30px 16px; }
.auth-panel {
    display: grid; grid-template-columns: 1.1fr 1fr; max-width: 920px; width: 100%;
    background: var(--surface); border-radius: 22px; overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.auth-hero {
    background: linear-gradient(150deg, var(--ink) 0%, #191C2E 55%, #23274a 100%);
    color: #fff; padding: 46px 42px; display: flex; flex-direction: column; gap: 18px;
}
.auth-hero h1 { font-size: 2.3rem; line-height: 1.12; font-weight: 700; }
.auth-hero em { font-style: normal; color: var(--lime); }
.hero-sub { color: #A9AEC2; font-size: .95rem; max-width: 320px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.hero-tags .mono-tag { background: rgba(255,255,255,.07); color: #C9CDDf; border: 1px solid rgba(255,255,255,.1); }
.auth-card { padding: 46px 40px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-switch { margin-top: 18px; font-size: .9rem; color: var(--muted); }
.alert-error { background: #FDECEC; color: var(--danger); padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .88rem; }

/* ============ Catalogue formations ============ */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.course-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
    transition: transform .18s, box-shadow .18s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(14,16,22,.1); }
.course-banner {
    height: 140px; background: linear-gradient(135deg, var(--primary) 0%, #7C6FF7 60%, #9D8FFF 100%);
    background-size: cover; background-position: center; position: relative;
    display: flex; align-items: center; justify-content: center;
}
.banner-placeholder { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: rgba(255,255,255,.85); }
.price-chip {
    position: absolute; top: 12px; right: 12px;
    font-family: var(--font-mono); font-size: .74rem; font-weight: 700;
    background: var(--ink); color: var(--lime); padding: 5px 11px; border-radius: 8px;
}
.course-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.course-body h3 { font-family: var(--font-display); font-size: 1.08rem; margin-bottom: 6px; }
.course-desc { color: var(--muted); font-size: .9rem; flex: 1; margin-bottom: 14px; }
.course-footer { display: flex; justify-content: flex-start; }

/* ============ Communauté ============ */
.community-layout { display: grid; grid-template-columns: 1fr 290px; gap: 22px; align-items: start; }
.community-side { position: sticky; top: 30px; }

.composer { padding: 0; overflow: hidden; }
.editor-toolbar { display: flex; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFAFE; }
.editor-toolbar button {
    border: none; background: none; cursor: pointer;
    width: 34px; height: 32px; border-radius: 8px; font-size: .95rem; color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; transition: .12s;
}
.editor-toolbar button:hover { background: var(--primary-soft); color: var(--primary); }
.editor-toolbar button.active { background: var(--primary); color: #fff; }
.toolbar-sep { width: 1px; background: var(--line); margin: 4px 8px; }
.editor { min-height: 90px; padding: 16px 18px; outline: none; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.editor h3 { font-family: var(--font-display); margin: 8px 0 4px; }
.editor blockquote, .post-content blockquote { border-left: 3px solid var(--primary); padding: 4px 14px; color: var(--muted); margin: 8px 0; }
.editor pre, .post-content pre { font-family: var(--font-mono); font-size: .85rem; background: var(--ink); color: #D6E4C8; padding: 12px 16px; border-radius: 10px; margin: 8px 0; overflow-x: auto; white-space: pre-wrap; }
.editor ul, .editor ol, .post-content ul, .post-content ol { padding-left: 22px; margin: 6px 0; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }

.post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px; box-shadow: var(--shadow); animation: fadeIn .3s ease; }
.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-author { font-weight: 700; }
.post-date { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); margin-left: auto; }
.post-group { font-family: var(--font-mono); font-size: .72rem; color: var(--primary); font-weight: 700; }
.post-content { word-wrap: break-word; }
.post-content h3 { font-family: var(--font-display); margin: 6px 0; }
.post-content-truncated {
    max-height: 210px; overflow: hidden; position: relative;
}
.post-content-truncated::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 70px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), var(--surface));
    pointer-events: none;
}
.post-read-more {
    display: inline-block; margin: 6px 0 0; padding: 0; background: none; border: none;
    font-size: .85rem; font-weight: 700; color: var(--primary); cursor: pointer;
}
.post-read-more:hover { text-decoration: underline; }
.post-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.comments { margin-top: 12px; background: #FAFAFE; border-radius: 10px; padding: 12px 14px; }
.comment { font-size: .9rem; padding: 6px 0; border-bottom: 1px solid var(--line); }
.comment:last-of-type { border-bottom: none; }
.comment b { color: var(--primary); }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { margin: 0; }

/* Groupes */
.group-item { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.group-item:last-child { border-bottom: none; }
.group-name { background: none; border: none; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; padding: 0; text-align: left; }
.group-name:hover { color: var(--primary); }
.group-item.member .group-name { color: var(--primary); }
.group-item.active-group { background: var(--primary-soft); border-radius: 10px; padding: 10px; }
.group-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.group-meta .mono { font-size: .72rem; color: var(--muted); }

/* ============ États vides ============ */
.empty, .empty-state { text-align: center; color: var(--muted); padding: 34px 20px; }
.empty-state { background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty-sm { color: var(--muted); font-size: .85rem; padding: 8px 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ Responsive ============ */
@media (max-width: 900px) {
    body.app { flex-direction: column; }

    /* Sur mobile, la navigation devient une barre fixe EN HAUT de l'écran
       (demandé : plus lisible et plus standard qu'une barre en bas). */
    .sidebar {
        width: 100%; min-height: auto; height: 60px;
        position: fixed; top: 0; bottom: auto; left: 0; right: 0; z-index: 1000;
        flex-direction: row; align-items: stretch; padding: 0 6px;
        box-shadow: 0 2px 16px rgba(0,0,0,.18);
        padding-top: env(safe-area-inset-top, 0);
    }
    .sidebar-brand { display: none; }
    .sidebar-nav { flex-direction: row; flex: 1; gap: 0; justify-content: space-around; }
    .sidebar-item {
        flex-direction: column; justify-content: center; gap: 2px;
        flex: 1; padding: 6px 2px; margin-bottom: 0; border-radius: 10px;
        font-size: .66rem; text-align: center; white-space: nowrap;
    }
    .sidebar-item svg { width: 20px; height: 20px; }
    .sidebar-item.active { background: transparent; color: var(--primary); }
    .sidebar-item.active svg { color: var(--primary); }
    .sidebar-item.active::before { display: none; }
    .sidebar-footer {
        border: none; padding: 0 4px; margin: 0; flex-shrink: 0;
        align-items: center; justify-content: center; gap: 4px;
    }
    /* Profil accessible sur mobile : on garde l'avatar (on masque juste le texte) */
    .user-chip { display: flex; flex: 0 0 auto; }
    .user-chip .user-meta { display: none; }
    .user-chip .avatar { width: 30px; height: 30px; font-size: .8rem; border: 2px solid transparent; }
    .user-chip.active .avatar { border-color: var(--primary); }
    .logout-link { padding: 8px; }

    /* Le contenu passe sous la barre fixe du haut : on ajoute de l'air en haut */
    .main-content { padding: calc(76px + env(safe-area-inset-top, 0)) 16px 28px; }

    .auth-panel { grid-template-columns: 1fr; }
    .auth-hero { padding: 32px 28px; }
    .community-layout { grid-template-columns: 1fr; }
    .community-side { position: static; }
    .stats-row { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    /* Messagerie mobile : WhatsApp-style, géré en JS via classes */
    .chat-container { grid-template-columns: 1fr; height: auto; max-height: none; }
}

/* ============ Filtres catalogue ============ */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.filter-tab {
    border: 1.5px solid var(--line); background: var(--surface); color: var(--muted);
    font: inherit; font-weight: 600; font-size: .88rem;
    padding: 8px 16px; border-radius: 999px; cursor: pointer; transition: .15s;
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--ink); border-color: var(--ink); color: var(--lime); }
.lessons-count { font-size: .74rem; color: var(--muted); margin-bottom: 6px; }

/* ============ Page formation (player + playlist) ============ */
.progress-bar-wrap { margin-bottom: 20px; }
.progress-info { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 6px; }
.progress-info .mono { color: var(--primary); font-weight: 700; }
.progress-track { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #8B7FFF); border-radius: 999px; transition: width .4s ease; }

.player-layout { display: grid; grid-template-columns: 1fr 330px; gap: 22px; align-items: start; }
.video-frame {
    aspect-ratio: 16 / 9; background: var(--ink); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); margin-bottom: 18px;
    display: flex; align-items: center; justify-content: center;
}
.video-frame iframe, .video-frame video { width: 100%; height: 100%; border: none; display: block; }
.lesson-info h2 { margin-bottom: 6px; }
.lesson-info .btn { margin-top: 14px; }
#complete-btn.is-done { background: var(--line); color: var(--muted); }

.playlist { position: sticky; top: 30px; padding: 18px; max-height: calc(100vh - 60px); overflow-y: auto; }
.playlist-items { display: flex; flex-direction: column; gap: 4px; }
.playlist-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    border: none; background: none; font: inherit; text-align: left;
    padding: 11px 12px; border-radius: 10px; cursor: pointer; transition: .13s;
}
.playlist-item:hover { background: var(--primary-soft); }
.playlist-item.playing { background: var(--ink); color: #fff; }
.playlist-item.playing .playlist-num { color: var(--lime); }
.playlist-num { font-size: .78rem; font-weight: 700; color: var(--muted); }
.playlist-title { flex: 1; font-size: .9rem; font-weight: 500; }
.playlist-check { opacity: 0; color: var(--success); font-weight: 700; }
.playlist-item.done .playlist-check { opacity: 1; }
.playlist-item.done .playlist-title { color: var(--muted); }
.playlist-item.playing.done .playlist-title { color: #B9BDCE; }

@media (max-width: 900px) {
    .player-layout { grid-template-columns: 1fr; }
    .playlist { position: static; max-height: none; }
}

/* ============ Enlever underlines des liens et boutons ============ */
a { text-decoration: none; }
.btn { text-decoration: none; }
button { text-decoration: none; }

/* ============ Menu actif (sidebar items) ============ */
.sidebar-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px;
    border-radius: 8px; cursor: pointer; transition: .15s;
    color: #A0A7B8; text-decoration: none;
}
.sidebar-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-item.active { background: var(--primary); color: #fff; }
.sidebar-item.active::before { content: ''; display: inline-block; width: 4px; height: 4px; 
    background: var(--lime); border-radius: 50%; margin-right: 8px; }

/* ============ Système de rating/étoiles pour vidéos ============ */
.rating-container { display: flex; align-items: center; gap: 16px; margin: 16px 0; }
.stars { display: flex; gap: 6px; }
.star { 
    font-size: 1.25rem; cursor: pointer; transition: .15s;
    color: var(--line);
}
.star.filled { color: #FFD700; }
.star:hover { transform: scale(1.1); }
.rating-text { font-size: .88rem; color: var(--muted); }

/* ============ Système de likes et vue ============ */
.video-stats { 
    display: flex; gap: 8px; margin: 14px 0; font-size: .82rem;
    color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px;
    flex-wrap: wrap;
}
.stat { 
    display: flex; align-items: center; gap: 5px; cursor: pointer; transition: .15s;
    padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--surface);
}
.stat:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.stat-count { font-weight: 600; color: var(--text); }

/* ============ Commentaires vidéos (imbriqués) ============ */
.comments-section { margin-top: 24px; }
.comment-form { margin-bottom: 20px; }
.comment-form textarea { 
    width: 100%; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; font-size: .9rem; resize: vertical; min-height: 64px;
    background: var(--bg); transition: border-color .15s;
}
.comment-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.comment-form .btn { font-size: .82rem; padding: 6px 14px; }
.comments-list { display: flex; flex-direction: column; gap: 16px; }
.comment { padding: 12px; background: var(--surface); border-radius: 8px; }
.comment-header { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 8px; }
.comment-author { font-weight: 600; }
.comment-time { color: var(--muted); }
.comment-content { font-size: .95rem; margin-bottom: 8px; }
.comment-actions { display: flex; gap: 16px; font-size: .8rem; }
.comment-reply-btn { cursor: pointer; color: var(--primary); transition: .15s; }
.comment-reply-btn:hover { color: var(--primary-dark); }
.comment-replies { margin-left: 24px; margin-top: 12px; padding-left: 12px; border-left: 2px solid var(--line); }

/* ============ Attachements vidéos ============ */
.attachments-section { margin-top: 20px; }
.attachments-list { 
    display: flex; flex-wrap: wrap; gap: 12px;
}
.attachment-item { 
    display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: var(--primary-soft); border-radius: 8px; cursor: pointer;
    transition: .15s; text-decoration: none; color: var(--primary);
}
.attachment-item:hover { background: var(--primary); color: #fff; }
.attachment-icon { font-size: 1.1rem; }
.attachment-name { font-size: .9rem; font-weight: 500; }

/* ============ Publications avec images ============ */
.post-image { 
    width: 100%; max-height: 75vh; object-fit: contain; background: var(--bg);
    border-radius: 8px; margin: 12px 0;
}
.post-actions { 
    display: flex; gap: 24px; padding-top: 12px; border-top: 1px solid var(--line);
    font-size: .9rem; color: var(--muted);
}
.post-action-btn { 
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: .15s; background: none; border: none; font: inherit;
    color: var(--muted);
}
.post-action-btn:hover { color: var(--primary); }
.post-action-btn.active { color: var(--primary); }

/* ══════════ Chat privé — layout WhatsApp ══════════ */

/* Desktop : 2 colonnes fixes */
.chat-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 100px);
    max-height: 820px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg);
}

/* ── Colonne gauche : liste ── */
.chat-list {
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow: hidden;
}
.chat-panel-title {
    font-size: .95rem; font-weight: 700; padding: 16px 16px 10px;
    border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.chat-search-wrap {
    padding: 10px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.chat-search-wrap input { margin: 0; font-size: .85rem; }
.chat-unread-badge {
    margin: 8px 14px 0; padding: 6px 10px; border-radius: 6px;
    background: var(--danger); color: #fff; font-size: .8rem; text-align: center;
    flex-shrink: 0;
}
.chat-conv-list { flex: 1; overflow-y: auto; padding: 10px 10px; }
.chat-empty { color: var(--muted); font-size: .88rem; text-align: center; padding: 24px 8px; }

.chat-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px; border-radius: 8px; cursor: pointer;
    transition: background .12s; margin-bottom: 2px;
}
.chat-item:hover { background: var(--primary-soft); }
.chat-item.active { background: var(--primary); color: #fff; }
.chat-item.active .chat-item-preview { color: rgba(255,255,255,.7); }
.chat-item-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.chat-item.active .chat-item-avatar { background: rgba(255,255,255,.2); color: #fff; }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* Demandes d'amitié dans la sidebar */
.chat-friend-requests {
    padding: 12px 14px; border-top: 1px solid var(--line); flex-shrink: 0;
}
.chat-friend-requests h3 { font-size: .82rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.friend-req-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; background: var(--primary-soft); border-radius: 6px;
    margin-bottom: 6px; font-size: .88rem; font-weight: 500;
}

/* ── Colonne droite : conversation ── */
.chat-zone {
    display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden;
}

/* En-tête de conversation */
.chat-conv-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--line);
    background: var(--surface); flex-shrink: 0;
}
.chat-back-btn {
    background: none; border: none; cursor: pointer; font: inherit;
    color: var(--primary); font-size: .88rem; font-weight: 600;
    padding: 4px 8px; border-radius: 6px; transition: .12s;
    display: none; /* masqué sur desktop */
}
.chat-back-btn:hover { background: var(--primary-soft); }
.chat-conv-name { font-weight: 700; font-size: .95rem; }
.chat-conv-status { font-size: .78rem; color: var(--success); }

/* Zone de messages */
.chat-messages {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 16px 20px; display: flex; flex-direction: column; gap: 8px;
}
.chat-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; color: var(--muted); gap: 10px; font-size: .9rem;
}
.chat-loading { text-align: center; color: var(--muted); padding: 32px; font-size: .9rem; }
.message { display: flex; }
.message.mine { justify-content: flex-end; }
.message-bubble {
    max-width: 65%; padding: 10px 14px; border-radius: 14px; word-break: break-word;
    font-size: .9rem; line-height: 1.45;
}
.message:not(.mine) .message-bubble {
    background: var(--surface); color: var(--text); border-bottom-left-radius: 4px;
}
.message.mine .message-bubble {
    background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.message-time { font-size: .7rem; margin-top: 4px; opacity: .65; }

/* Barre de saisie */
.chat-input {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 12px 16px; border-top: 1px solid var(--line);
    background: var(--surface); flex-shrink: 0;
}
.chat-input textarea {
    flex: 1; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: 20px; font: inherit; font-size: .9rem;
    resize: none; min-height: 42px; max-height: 120px;
    background: var(--bg); transition: border-color .15s; line-height: 1.4;
}
.chat-input textarea:focus { outline: none; border-color: var(--primary); }
.chat-input .btn { flex-shrink: 0; border-radius: 50%; width: 42px; height: 42px; padding: 0; font-size: 1rem; }

/* Résultats de recherche */
.search-result-item {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 6px; background: var(--bg); margin-bottom: 5px;
}
.search-result-name { font-size: .85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-err, .search-empty { font-size: .82rem; color: var(--muted); padding: 6px 0; }
.search-err { color: var(--danger); }

/* ══ Mobile : navigation WhatsApp ══ */
@media (max-width: 767px) {
    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100dvh - 80px);
        max-height: none;
        border-radius: 0;
        border-left: none; border-right: none;
    }
    .chat-list { border-right: none; }
    .chat-back-btn { display: inline-flex !important; }

    /* Par défaut sur mobile : liste visible, chat caché */
    .chat-zone { display: none; }

    /* Quand on entre dans une conversation */
    .chat-zone.active-mobile {
        display: flex;
        position: fixed; inset: 0; z-index: 200;
        background: var(--bg);
    }

    /* Masquer la liste quand le chat est ouvert */
    .chat-list.hidden-mobile { display: none; }

    /* Cacher le header page quand le chat est ouvert */
    .message-bubble { max-width: 80%; }
}

/* ============ Gestion des amis ============ */
.friends-section { padding: 20px; }
.friend-list { display: flex; flex-direction: column; gap: 12px; }
.friend-item { 
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; background: var(--surface); border-radius: 8px; border: 1px solid var(--line);
}
.friend-info { display: flex; flex-direction: column; }
.friend-name { font-weight: 600; }
.friend-status { font-size: .8rem; color: var(--muted); }
.friend-actions { display: flex; gap: 8px; }
.friend-actions .btn { padding: 6px 12px; font-size: .85rem; }

/* ============================================================
   PROFIL UTILISATEUR
   ============================================================ */

.profile-page {
    max-width: 860px;
    margin: 0 auto;
}

.profile-cover {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-size: cover;
    background-position: center;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 2px dashed rgba(255,255,255,.15);
}
.profile-cover.no-cover::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: block;
}
.profile-cover.no-cover .cover-placeholder-text {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; color: rgba(255,255,255,.3); font-size: .82rem; pointer-events: none;
}
.profile-cover.no-cover .cover-placeholder-text svg { opacity: .4; }

.cover-upload-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(4px);
}
.cover-upload-btn:hover { background: rgba(0,0,0,0.85); }

.profile-info-bar {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 0 8px;
    margin-top: -40px;
    position: relative;
    z-index: 2;
}

.profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid var(--bg);
    object-fit: cover;
    display: block;
    background: var(--card);
}

.profile-avatar-initials {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid var(--bg);
    background: linear-gradient(135deg, var(--primary) 0%, #7C6FF7 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
    box-shadow: 0 0 0 2px rgba(255,255,255,.12);
    outline: 2px dashed rgba(255,255,255,.25);
    outline-offset: 4px;
}

.avatar-upload-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid var(--bg);
}
.avatar-upload-btn:hover { opacity: 0.85; }

.profile-meta {
    flex: 1;
    padding-top: 44px;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.profile-email {
    font-size: 0.82rem;
    opacity: 0.6;
    margin: 2px 0 8px;
}

.profile-bio {
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 12px;
    max-width: 500px;
}

.profile-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.82rem;
    opacity: 0.8;
    margin-bottom: 12px;
}

.profile-detail a {
    color: var(--accent);
    text-decoration: none;
}

.profile-actions-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.profile-section {
    margin-top: 32px;
}

.profile-section-title {
    font-size: 0.85rem;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    margin-bottom: 12px;
}

.profile-courses {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-course-chip {
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--card);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
}

.profile-course-chip.active { border-color: var(--accent); }
.profile-course-chip.pending { opacity: 0.6; }

.chip-status {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-admin {
    background: linear-gradient(135deg, #6c63ff, #3d5af1);
    color: #fff;
    box-shadow: 0 0 8px rgba(108,99,255,0.4);
}

.badge-certified {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
}

.badge-gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 0 8px rgba(245,158,11,0.4);
}

/* Petits badges inline dans la sidebar */
.badge-admin-sm, .badge-icon {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    vertical-align: middle;
}

.badge-admin-sm { color: #6c63ff; }
.badge-gold-sm  { color: #f59e0b; }
.badge-cert-sm  { color: #0ea5e9; }

/* ============================================================
   MODAL GÉNÉRIQUE
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex !important; }

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { opacity: 1; }

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

/* ============================================================
   MODAL WHATSAPP
   ============================================================ */

.modal-whatsapp {
    max-width: 420px;
}

.whatsapp-icon {
    font-size: 3rem;
    margin-bottom: 4px;
}

.btn-whatsapp {
    background: #25D366;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-whatsapp:hover { background: #1da851; }

.whatsapp-number {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: 0.05em;
}

.small { font-size: 0.8rem; }
.muted { opacity: 0.6; }

/* ============================================================
   EDIT PROFILE FORM
   ============================================================ */

.edit-profile-form .form-group {
    margin-bottom: 14px;
}

.edit-profile-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.edit-profile-form label {
    display: block;
    font-size: 0.78rem;
    opacity: 0.7;
    margin-bottom: 4px;
    font-family: var(--mono);
}

.edit-profile-form .form-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.edit-profile-form .form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.edit-profile-form textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ============================================================
   ADMIN USERS TABLE
   ============================================================ */

.admin-users-table {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-family: var(--mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.row-blocked { opacity: 0.5; }
.row-blocked td { text-decoration: line-through; }
.row-blocked td:last-child { text-decoration: none; }

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.user-link:hover { color: var(--accent); }

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-xs {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
}

.btn-warning {
    background: #f59e0b;
    color: #000;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.btn-warning:hover { background: #d97706; }

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }

.badge-select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* user-chip as link */
a.user-chip {
    text-decoration: none;
    color: var(--text);
    transition: opacity 0.15s;
}
a.user-chip:hover { opacity: 0.8; }

/* ============================================================
   OVERRIDE MODAL — fond solide, pas transparent
   ============================================================ */

.modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.80) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    z-index: 9999 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
}

.modal-overlay.open,
.modal-overlay[style*="flex"] {
    display: flex !important;
}

.modal {
    background: #1a1a1a !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 20px !important;
    padding: 32px !important;
    max-width: 580px !important;
    width: 100% !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    box-shadow: 0 32px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.05) !important;
    position: relative !important;
    z-index: 10000 !important;
}

/* Scrollbar discrète dans le modal */
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.modal-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 24px !important;
    padding-bottom: 16px !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
}

.modal-header h3 {
    margin: 0 !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #fff !important;
}

.modal-close {
    background: rgba(255,255,255,0.08) !important;
    border: none !important;
    color: #fff !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
    flex-shrink: 0 !important;
}
.modal-close:hover { background: rgba(255,255,255,0.18) !important; }

/* ============================================================
   PAGE TRANSITIONS — loader stylé
   ============================================================ */

/* Barre de progression en haut */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #a855f7, #06b6d4);
    z-index: 99999;
    transition: width 0.3s ease, opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(108,99,255,0.6);
}

/* Overlay de transition de page */
#page-transition {
    position: fixed;
    inset: 0;
    background: rgba(10,10,14,0.0);
    z-index: 99998;
    pointer-events: none;
    transition: background 0.25s ease;
}

#page-transition.leaving {
    background: rgba(10,10,14,0.4);
    pointer-events: all;
}

/* Fade-in du contenu au chargement */
@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.main-content {
    /* NB: ne pas remettre de "transform" ici : un transform sur un
       ancêtre de .post-detail-overlay (position:fixed) crée un
       containing block et transforme le "fixed" en "absolute" relatif
       à .main-content. C'est ce qui causait le mauvais positionnement
       de la modale de publication (besoin de scroller pour la voir). */
    animation: pageFadeIn 0.35s ease both;
}

/* Skeleton loader pour les cartes */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 8px;
}

/* Post-author link sans soulignement */
.post-author-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}
.post-author-link:hover .post-author {
    color: var(--accent);
    text-decoration: underline;
}

/* ============ Corrections v5.1 ============ */

/* Badge globe (utilisateurs non certifiés) */
.badge-globe { font-size: .8rem; opacity: .65; }

/* Info auteur dans le post (nom + badge sur même ligne) */
.post-author-info { display: flex; flex-direction: column; }
.post-author { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: .9rem; }

/* Commentaires : auteur cliquable avec avatar */
.comment { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment:last-of-type { border-bottom: none; }
.comment-author-link {
    display: inline-flex; align-items: center; gap: 7px;
    text-decoration: none; color: inherit;
}
.comment-author-link:hover .comment-author-name b { text-decoration: underline; color: var(--primary); }
.comment-author-name { display: flex; align-items: center; gap: 4px; font-size: .88rem; }
.comment-text { font-size: .9rem; padding-left: 37px; color: var(--text); }

/* Nom utilisateur sidebar : toujours blanc */
.sidebar .user-name { color: #ffffff !important; }

/* user-chip actif (profil sélectionné) */
.user-chip.active { background: rgba(255,255,255,.1); border-radius: 10px; }

/* Statut dans le profil */
.profile-status-label { margin: 4px 0 8px; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-family: var(--font-mono); padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.status-admin   { background: rgba(255,100,100,.15); color: #ff6464; border: 1px solid rgba(255,100,100,.3); }
.status-certified { background: rgba(99,220,150,.12); color: #63dc96; border: 1px solid rgba(99,220,150,.3); }
.status-gold    { background: rgba(255,210,80,.12); color: #ffd250; border: 1px solid rgba(255,210,80,.3); }
.status-member  { background: rgba(255,255,255,.07); color: var(--muted); border: 1px solid var(--line); }

/* ============ Badges de navigation (messages non lus, demandes d'amitié) ============ */
.nav-badge {
    position: absolute;
    top: 6px; right: 6px;
    background: #ff4d4d;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    font-family: var(--font-mono);
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    border: 2px solid var(--ink);
    pointer-events: none;
}
.nav-badge-friend {
    background: var(--lime);
    color: var(--ink);
    top: 6px;
    right: 26px;
}
@media (max-width: 900px) {
    .nav-badge { top: 4px; right: 4px; }
    .nav-badge-friend { top: 4px; right: 22px; }
}

/* ============ Communauté — responsive amélioré ============ */
.community-layout {
    display: grid;
    grid-template-columns: 1fr 290px;
    gap: 22px;
    align-items: start;
}
@media (max-width: 1100px) {
    .community-layout { grid-template-columns: 1fr 240px; }
}
@media (max-width: 800px) {
    .community-layout { grid-template-columns: 1fr; }
    .community-side { position: static; }
    .community-side .card { margin-bottom: 0; }
    /* Sur mobile, les groupes sont affichés en scroll horizontal */
    #groups-list {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }
    .group-item {
        flex-shrink: 0;
        min-width: 140px;
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 10px 12px;
        background: var(--surface);
    }
}

/* ============ Profil — section posts ============ */
.profile-posts-list { display: flex; flex-direction: column; gap: 14px; }
.profile-posts-list .post { margin-bottom: 0; }
.post-group-label { font-family: var(--font-mono); font-size: .75rem; color: var(--primary); font-weight: 700; }
.profile-section { margin-top: 28px; }
.profile-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; color: var(--text); border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* ============ Messagerie — pièces jointes + refresh ============ */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-attach-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.chat-attach-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 5px 10px;
    font-size: .8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: .15s;
}
.chat-attach-btn:hover { border-color: var(--primary); color: var(--primary); }
.chat-refresh-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    width: 34px; height: 34px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
    flex-shrink: 0;
}
.chat-refresh-btn:hover { color: var(--primary); border-color: var(--primary); }
.chat-refresh-btn.spinning { animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Message image */
.message-img { max-width: 220px; border-radius: 10px; display: block; margin-top: 6px; cursor: pointer; }

/* Message vocal */
.message-audio { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.message-audio audio { height: 32px; max-width: 200px; }

/* Preview pièce jointe */
#attach-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.attach-chip {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: 20px; padding: 4px 10px; font-size: .78rem;
}
.attach-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .75rem; }

/* Alerte profil */
.alert { padding: 10px 14px; border-radius: 8px; font-size: .88rem; }
.alert-danger { background: rgba(255,77,77,.12); color: #ff6b6b; border: 1px solid rgba(255,77,77,.3); }
.alert-success { background: rgba(99,220,150,.12); color: #63dc96; border: 1px solid rgba(99,220,150,.3); }

/* ── Badge non lu par conversation ── */
.chat-item { position: relative; }
.conv-unread-badge {
    position: absolute;
    top: 50%; right: 12px;
    transform: translateY(-50%);
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}

/* ── Pagination ── */
.pagination { display:flex; align-items:center; justify-content:center; gap:.5rem; margin:2rem 0; flex-wrap:wrap; }
.page-btn { padding:.45rem .9rem; border:1px solid var(--border); border-radius:8px; color:var(--text); text-decoration:none; font-size:.9rem; transition:all .2s; background:transparent; }
.page-btn:hover { border-color:var(--primary); color:var(--primary); }
.page-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }

/* ── Formateur sur carte formation ── */
.course-trainer { font-size:.8rem; color:var(--primary); margin:.2rem 0 .4rem; }

/* ── Filtres groupes ── */
.group-filter-tabs .btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.group-item.member { border-left:3px solid var(--primary); }

/* ── Centrage grand écran (fix sidebar) ── */
.app-layout, body.app > .layout-wrap { display:flex; }

/* ── Images multiples sur publication ── */
.post-images { display:flex; flex-wrap:wrap; gap:.5rem; margin:.75rem 0; }
.post-img-thumb { width:120px; height:90px; object-fit:cover; border-radius:8px; cursor:zoom-in; border:1px solid var(--border); }
@media(max-width:640px) { .post-img-thumb { width:80px; height:65px; } }

/* ── Bouton supprimer publication ── */
.post-delete-btn { margin-left:auto; opacity:.5; font-size:.85rem; transition:opacity .2s; }
.post-delete-btn:hover { opacity:1; }

/* ── Menu contextuel conversation ── */
.ctx-item { display:block; width:100%; padding:.55rem 1rem; text-align:left; background:none; border:none; color:var(--text); cursor:pointer; font-size:.88rem; transition:background .15s; }
.ctx-item:hover { background:var(--hover); }

/* ── Modal WhatsApp souscription (une seule couche) ── */
.wa-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.wa-modal-backdrop.open { display: flex; }
.wa-modal-backdrop .modal { background: #1a1d27; border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 2rem; max-width: 420px; width: 100%; }
.wa-modal-backdrop .modal-header h3 { color: #fff; }
.wa-modal-backdrop .modal-body p { color: #fff; }
.wa-modal-backdrop .modal-close { color: #fff; }
.wa-phone-box {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
    border-radius: 12px; padding: .85rem 1rem; margin: .9rem 0;
}
.wa-phone-number { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.wa-copy-btn {
    flex-shrink: 0; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
    color: #fff; border-radius: 8px; padding: .4rem .7rem; font-size: .8rem; cursor: pointer; transition: .15s;
}
.wa-copy-btn:hover { background: rgba(255,255,255,.22); }

/* ── Menu 3 points sur post ── */
.post-menu-wrap { position:relative; margin-left:auto; }
.post-menu-btn  { background:none; border:none; color:var(--muted); font-size:1.2rem; cursor:pointer; padding:2px 8px; border-radius:8px; line-height:1; transition:.15s; }
.post-menu-btn:hover { background:var(--primary-soft); color:var(--primary); }
.post-menu-dropdown {
    display: none;
    position: absolute; right:0; top:calc(100% + 4px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 200;
    min-width: 160px;
    padding: .4rem;
    box-shadow: 0 12px 28px rgba(14,16,22,.14);
}
.post-menu-dropdown.open { display: block; animation: fadeIn .15s ease; }
.post-menu-item { display:block; width:100%; padding:.55rem .75rem; background:none; border:none; border-radius:8px; text-align:left; color:var(--text); cursor:pointer; font-size:.88rem; transition:.12s; }
.post-menu-item:hover { background:var(--hover); }
.post-menu-item.danger { color:var(--danger); }
.post-menu-item.danger:hover { background:#FDECEC; }

/* ── Modal post détail ── */
.post-detail-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(14,16,22,.6); backdrop-filter: blur(2px); z-index: 500;
    align-items: center; justify-content: center; padding: 1rem;
}
.post-detail-overlay.open { display: flex; animation: fadeIn .18s ease; }
.post-detail-modal {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; width: 100%; max-width: 680px;
    max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(14,16,22,.25);
}
.post-detail-header { display:flex; align-items:center; padding:1.1rem 1.35rem; border-bottom:1px solid var(--border); gap:.75rem; }
.post-detail-header strong { font-family: var(--font-display); font-size: .98rem; }
.post-detail-body   { padding:1.35rem; flex:1; line-height:1.65; }
.post-detail-images { display:flex; flex-wrap:wrap; gap:.5rem; margin:1rem 0; }
.post-detail-img    { width:100%; max-height:420px; object-fit:contain; border-radius:12px; cursor:zoom-in; background:var(--bg); }
.post-detail-images .post-detail-img:not(:first-child) { width:calc(50% - .25rem); max-height:200px; object-fit:cover; }
.post-detail-comments { padding:1.1rem 1.35rem 1.35rem; border-top:1px solid var(--border); background: #FAFAFE; border-radius: 0 0 18px 18px; }

/* ── Bouton supprimer message ── */
.msg-delete-btn { background:none; border:none; color:rgba(255,255,255,.3); font-size:.75rem; cursor:pointer; margin-left:.4rem; vertical-align:middle; }
.msg-delete-btn:hover { color:#ef4444; }
.message.mine .message-bubble:hover .msg-delete-btn { opacity:1; }

/* ============================================================
   REDESIGN — Publication & commentaires (style type Facebook)
   Ce bloc est placé en fin de fichier : il PRIME sur les anciennes
   règles (.composer, .post, .comment...) grâce à l'ordre du CSS.
   ============================================================ */

/* ---------- Composer (zone de publication) ---------- */
.composer { padding: 0; overflow: hidden; border-radius: 16px; }
.composer-top { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 4px; }
.composer-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 1rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.composer .editor {
    flex: 1; min-height: 46px; padding: 11px 16px; margin: 0;
    background: var(--bg); border-radius: 22px; line-height: 1.5;
    max-height: 260px; overflow-y: auto; transition: background .15s, box-shadow .15s;
}
.composer .editor:focus { background: #fff; box-shadow: 0 0 0 2px var(--primary-soft) inset; }
.composer .editor:empty::before { content: attr(data-placeholder); color: var(--muted); }

.composer .editor-toolbar {
    display: flex; gap: 2px; padding: 6px 16px; background: transparent; border: none;
}
.composer .editor-toolbar button {
    width: 32px; height: 30px; border-radius: 8px; border: none; background: none;
    cursor: pointer; color: var(--muted); font-size: .9rem;
    display: inline-flex; align-items: center; justify-content: center; transition: .12s;
}
.composer .editor-toolbar button:hover { background: var(--primary-soft); color: var(--primary); }
.composer .toolbar-sep { width: 1px; background: var(--line); margin: 4px 6px; }

.composer-previews { display: flex; gap: .5rem; flex-wrap: wrap; padding: 0 16px; }
.composer-previews:not(:empty) { padding-top: 8px; padding-bottom: 4px; }
.composer-previews img, .composer-previews video {
    border-radius: 10px; border: 1px solid var(--line);
}

.composer-actions {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; margin-top: 6px; border-top: 1px solid var(--line);
}
.composer-action {
    display: inline-flex; align-items: center; gap: 7px; margin: 0; cursor: pointer;
    padding: 8px 12px; border-radius: 10px; font-size: .9rem; font-weight: 600;
    color: var(--muted); transition: background .12s;
}
.composer-action:hover { background: var(--bg); }
.composer-action-ico { font-size: 1.05rem; }
.composer-context { flex: 1; font-family: var(--font-mono); font-size: .74rem; color: var(--muted); text-align: right; }
.composer-publish { border-radius: 10px; padding: 9px 22px; }

/* ---------- Carte publication ---------- */
.post {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
    padding: 16px 20px 6px; margin-bottom: 16px; box-shadow: var(--shadow);
    animation: fadeIn .3s ease;
}
.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-content { word-wrap: break-word; line-height: 1.6; }

/* Barre d'actions J'aime / Commenter — boutons pleine largeur type Facebook */
.post-actions {
    display: flex; gap: 4px; margin-top: 12px; padding: 4px 0 0;
    border-top: 1px solid var(--line);
}
.post-action-btn {
    flex: 1; justify-content: center; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    padding: 9px 6px; border-radius: 10px; font: inherit; font-size: .9rem; font-weight: 600;
    background: none; border: none; color: var(--muted); transition: background .12s, color .12s;
}
.post-action-btn:hover { background: var(--bg); color: var(--text); }
.post-action-btn.active { color: var(--primary); }

/* ---------- Commentaires (bulles type Facebook) ---------- */
.comment {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 0; border: none; background: none;
}
.comment:last-of-type { border: none; }
.comment-avatar-link { flex-shrink: 0; text-decoration: none; }
.comment-bubble {
    background: var(--bg); border-radius: 16px; padding: 8px 14px;
    max-width: 100%; display: inline-block;
}
.comment-author-name {
    display: block; font-size: .86rem; text-decoration: none; color: var(--text);
    margin-bottom: 1px;
}
.comment-author-name b { color: var(--text); }
.comment-author-name:hover b { text-decoration: underline; color: var(--primary); }
.comment-text { display: block; font-size: .92rem; color: var(--text); padding: 0; }
.comment-empty { font-size: .88rem; color: var(--muted); padding: 6px 2px 12px; }

/* Champ de saisie d'un commentaire (pilule + bouton envoyer) */
.comment-form { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.comment-form input {
    flex: 1; margin: 0; padding: 10px 16px; border-radius: 22px;
    border: 1px solid var(--line); background: var(--bg); font-size: .92rem;
}
.comment-form input:focus { background: #fff; }
.comment-send-btn {
    width: 40px; height: 40px; flex-shrink: 0; border: none; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 1rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: background .12s;
}
.comment-send-btn:hover { background: var(--primary-dark); }

/* Zone commentaires de la fenêtre détail */
.post-detail-comments { background: var(--surface); }
.post-detail-comments #post-detail-comments-list { display: block; }

/* ============================================================
   Retours visuels : bouton en chargement + progression d'upload
   ============================================================ */
.btn.is-loading { opacity: .85; cursor: progress; }
.btn-spinner {
    display: inline-block; width: 14px; height: 14px; margin-right: 8px;
    border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
    border-radius: 50%; vertical-align: -2px; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.upload-progress { margin: 4px 16px 14px; }
.upload-progress-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px;
}
.upload-progress-pct { font-family: var(--font-mono); color: var(--primary); }
.upload-progress-track {
    height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden;
}
.upload-progress-fill {
    height: 100%; width: 0%; border-radius: 6px;
    background: linear-gradient(90deg, var(--primary), var(--lime, var(--primary)));
    transition: width .2s ease;
}

/* Champ mot de passe avec bouton afficher/masquer (login + register) */
.password-field { position: relative; margin-bottom: 12px; }
.password-field input { margin-bottom: 0; padding-right: 46px; }
.password-toggle {
    position: absolute; right: 4px; top: 0; height: 100%;
    display: flex; align-items: center; padding: 0 10px;
    background: none; border: none; cursor: pointer; font-size: 1.05rem; line-height: 1;
    opacity: .75;
}
.password-toggle:hover { opacity: 1; }

/* ===== Page Notifications ===== */
.notif-page { padding: 6px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-soft, rgba(0,120,255,.06)); }
.notif-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); border-radius: 10px; }
.notif-link:hover { background: var(--bg); }
.notif-body { display: flex; flex-direction: column; gap: 2px; }
.notif-text { font-size: .93rem; }
.notif-time { font-size: .78rem; color: var(--muted); }
.notif-empty { color: var(--muted); padding: 20px; text-align: center; }

/* Hashtags dans les publications */
.hashtag { color: var(--primary); font-weight: 600; cursor: default; }

/* ===== Réactions (👍 ❤️ 😂 😮 😢) ===== */
.reaction-summary { display: flex; align-items: center; gap: 6px; padding: 8px 2px 2px; font-size: .85rem; color: var(--muted); }
.reaction-summary[hidden] { display: none; }
.reaction-emojis { font-size: 1rem; letter-spacing: -2px; }
.reaction-count { font-weight: 600; }

.reaction-wrap { position: relative; flex: 1; }
.reaction-main { width: 100%; }
.reaction-main.active { color: var(--primary); }
.reaction-picker {
    position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
    display: none; gap: 4px; padding: 6px 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 30px;
    box-shadow: 0 8px 24px rgba(0,0,0,.16); z-index: 20;
}
.reaction-wrap:hover .reaction-picker,
.reaction-wrap.open .reaction-picker { display: flex; }
.reaction-opt {
    border: none; background: none; cursor: pointer; font-size: 1.5rem; line-height: 1;
    padding: 2px; border-radius: 50%; transition: transform .12s;
}
.reaction-opt:hover { transform: scale(1.35) translateY(-3px); }
