/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #2563eb;
    --primary-h:  #1d4ed8;
    --success:    #16a34a;
    --danger:     #dc2626;
    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --muted:      #64748b;
    --radius:     10px;
    --shadow:     0 2px 12px rgba(0,0,0,.08);
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Steps ──────────────────────────────────────────────────── */
.step { display: none; }
.step.active { display: block; }

/* ── Card (identification) ──────────────────────────────────── */
.card {
    max-width: 420px;
    margin: 80px auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.card h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: .25rem; }
.card .subtitle { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
    display: inline-block;
    padding: .6rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ── Container ──────────────────────────────────────────────── */
.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ── Exercice header ────────────────────────────────────────── */
.exercice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.exercice-header h2 { font-size: 1.3rem; }
#etudiant-label { color: var(--muted); font-size: .875rem; }

/* ── Commentaire card ───────────────────────────────────────── */
.commentaire-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.commentaire-meta {
    display: flex;
    gap: .5rem;
    margin-bottom: .75rem;
}

.badge {
    font-size: .75rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-plateforme { background: #dbeafe; color: #1d4ed8; }
.badge-agressif   { background: #fee2e2; color: #b91c1c; }
.badge-decu       { background: #fef3c7; color: #b45309; }
.badge-positif    { background: #dcfce7; color: #15803d; }
.badge-neutre     { background: #f1f5f9; color: #475569; }
.badge-sarcastique   { background: #ede9fe; color: #6d28d9; }
.badge-site_internet { background: #e0f2fe; color: #0369a1; }

.commentaire-texte {
    font-size: .95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    padding: .75rem;
    background: var(--bg);
    border-radius: 6px;
    border-left: 3px solid var(--border);
}

.commentaire-card label { font-size: .875rem; font-weight: 500; margin-bottom: .35rem; display: block; }
.commentaire-card textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: .95rem;
    resize: vertical;
    min-height: 90px;
    outline: none;
    transition: border-color .15s;
}
.commentaire-card textarea:focus { border-color: var(--primary); }

.submit-zone { text-align: center; padding: 1rem 0; }

/* ── Templates plateforme ───────────────────────────────────── */
.tpl {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: .9rem;
    font-size: .92rem;
}
.tpl-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .6rem;
}
.tpl-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .8rem;
    flex-shrink: 0;
}
.tpl-name   { font-weight: 600; font-size: .9rem; }
.tpl-handle { font-size: .78rem; color: var(--muted); }
.tpl-date   { font-size: .75rem; color: var(--muted); }
.tpl-logo   { width: 20px; height: 20px; margin-left: auto; flex-shrink: 0; }
.tpl-texte  { line-height: 1.55; margin-bottom: .5rem; }
.tpl-footer { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); margin-top: .5rem; }
.tpl-stars  { color: #f59e0b; font-size: .85rem; }

/* Twitter */
.tpl-twitter { background: #000; color: #e7e9ea; border: 1px solid #2f3336; }
.tpl-twitter .tpl-handle { color: #71767b; }
.tpl-twitter .tpl-footer { color: #71767b; }

/* Facebook */
.tpl-facebook { background: #fff; border: 1px solid #dddfe2; }
.tpl-facebook .tpl-footer { color: #1877f2; font-weight: 600; }

/* Google Review */
.tpl-google { background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* Instagram */
.tpl-instagram { background: #fff; border: 1px solid #dbdbdb; }
.tpl-avatar-ig {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--c, #ccc);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .8rem;
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #e1306c;
    flex-shrink: 0;
}
.tpl-instagram .tpl-texte { font-size: .88rem; }

/* LinkedIn */
.tpl-linkedin { background: #fff; border: 1px solid #e0e0e0; }
.tpl-linkedin .tpl-handle { font-size: .75rem; color: var(--muted); }
.tpl-linkedin .tpl-footer { color: #0a66c2; font-weight: 600; }

/* Site internet */
.tpl-site { background: #f9fafb; border: 1px solid var(--border); border-left: 3px solid #94a3b8; }
.tpl-site-header { display: flex; align-items: center; gap: .65rem; margin-bottom: .6rem; }

/* ── Résultats ──────────────────────────────────────────────── */
.score-global {
    text-align: center;
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin: 1rem 0 2rem;
}
.score-global span { font-size: 1.2rem; color: var(--muted); font-weight: 400; }

.resultat-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.reponse-etudiant {
    background: #f8faff;
    border-left: 3px solid var(--primary);
    border-radius: 0 6px 6px 0;
    padding: .65rem .9rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.reponse-etudiant .reponse-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .25rem;
}
.reponse-etudiant p { color: var(--text); line-height: 1.5; }

.resultat-footer {
    border-top: 1px solid var(--border);
    padding-top: .9rem;
    margin-top: .25rem;
}

.resultat-card .score-badge {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: .75rem;
}

.resultat-card .feedback { color: var(--text); font-size: .88rem; }

/* ── Critères barres ────────────────────────────────────────── */
.critere-row { margin-bottom: .9rem; }
.critere-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .3rem;
}
.critere-icon  { font-size: 1rem; }
.critere-nom   { flex: 1; font-size: .85rem; font-weight: 600; }
.critere-score { font-size: .82rem; font-weight: 700; color: var(--primary); }
.critere-bar-bg {
    height: 7px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: .3rem;
}
.critere-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .4s ease;
}
.critere-commentaire { font-size: .82rem; color: var(--muted); line-height: 1.45; margin: 0; }
.suggestion-box {
    margin-top: .75rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: .65rem .85rem;
    font-size: .85rem;
    line-height: 1.5;
    color: #92400e;
}

/* ── Admin nav ──────────────────────────────────────────────── */
body.admin { background: var(--bg); }

.admin-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
}
.nav-title { font-weight: 700; margin-right: auto; }
.nav-btn {
    padding: .4rem .9rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: .9rem;
    color: var(--muted);
    transition: background .15s;
}
.nav-btn:hover, .nav-btn.active { background: var(--bg); color: var(--text); }
.nav-btn.logout { color: var(--danger); }

/* ── Admin sections ─────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

.admin-section { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.section-header h2 { font-size: 1.2rem; }

/* Scenario list item */
.scenario-item {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.scenario-item .sc-title { flex: 1; font-weight: 500; }
.scenario-item .sc-mode  { color: var(--muted); font-size: .85rem; }
.actif-toggle {
    padding: .3rem .8rem;
    border-radius: 99px;
    border: none;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}
.actif-toggle.actif { background: #dcfce7; color: #15803d; }
.actif-toggle.inactif { background: var(--border); color: var(--muted); }

/* Results table */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; }

/* Filters */
.filters { display: flex; gap: .75rem; align-items: center; }
.filters select { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; }

/* Table actions */
.table-actions { margin-bottom: .75rem; }
.btn-danger {
    padding: .5rem 1rem;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.btn-danger:hover    { background: #b91c1c; }
.btn-danger:disabled { opacity: .4; cursor: not-allowed; }

/* Results expand */
.result-row:hover td { background: #f8faff; }
.expand-toggle { color: var(--muted); font-size: .75rem; width: 24px; }
.detail-row.hidden { display: none; }
.detail-row td { padding: 0 !important; border-bottom: 2px solid var(--primary) !important; }
.detail-panel { padding: 1rem 1.25rem; background: #f8faff; display: flex; flex-direction: column; gap: .75rem; }
.detail-item { background: var(--surface); border-radius: 6px; padding: .9rem 1rem; border: 1px solid var(--border); }
.detail-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.detail-score { margin-left: auto; font-weight: 700; color: var(--primary); }
.detail-commentaire { font-size: .88rem; color: var(--muted); background: var(--bg); padding: .5rem .75rem; border-radius: 5px; margin-bottom: .5rem; }
.detail-reponse { font-size: .88rem; background: #f0f7ff; border-left: 3px solid var(--primary); padding: .5rem .75rem; border-radius: 0 5px 5px 0; margin-bottom: .5rem; }
.detail-reponse-label { display: block; font-size: .72rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.detail-feedback { font-size: .85rem; color: var(--text); line-height: 1.55; white-space: pre-wrap; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.75rem;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-content h3 { margin-bottom: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

/* Comment builder row */
.comment-row {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .75rem;
    margin-bottom: .5rem;
}
.comment-row .row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.comment-row button.remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: .85rem; }

/* Loading */
.loading { text-align: center; padding: 3rem; color: var(--muted); }
