/* ===========================================================
   Police "Codec Pro" : police commerciale (Pangram Pangram).
   Les fichiers ne sont pas inclus ici pour des raisons de licence.
   Déposez vos fichiers .woff2 dans /assets/fonts/ pour l'activer ;
   en leur absence, la pile de secours (Segoe UI, etc.) est utilisée.
   =========================================================== */
@font-face {
    font-family: 'Codec Pro';
    src: url('/assets/fonts/CodecPro-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Codec Pro';
    src: url('/assets/fonts/CodecPro-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #880D1E;
    --primary-dark: #6b0a17;
    --secondary: #DD2D4A;
    --dark: #0A0A0A;
    --light: #CBEEF3;
    --bg: #f7f5f6;
    --surface: #ffffff;
    --text: var(--dark);
    --text-muted: #6b6870;
    --border: #ece7e8;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 8px rgba(10, 10, 10, 0.06), 0 1px 3px rgba(10, 10, 10, 0.08);
    --shadow-lg: 0 16px 40px rgba(10, 10, 10, 0.16);
    --success: #1f9d55;
    --warning: #c9820f;
    --danger: var(--secondary);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Codec Pro', 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Pages d'authentification ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

    .auth-logo h1 {
        font-size: 22px;
        margin: 10px 0 4px;
        color: var(--primary);
    }

    .auth-logo p {
        color: var(--text-muted);
        font-size: 14px;
        margin: 0;
    }

.auth-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 18px;
}

    .form-group label {
        display: block;
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 6px;
        color: var(--text);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 11px 14px;
        border-radius: var(--radius-sm);
        border: 1px solid var(--border);
        font-size: 14px;
        background: #fff;
        font-family: inherit;
        color: var(--text);
        transition: border-color .15s, box-shadow .15s;
    }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(136, 13, 30, 0.12);
        }

.form-row {
    display: flex;
    gap: 14px;
}

    .form-row .form-group {
        flex: 1;
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .05s, box-shadow .15s;
    font-family: inherit;
}

    .btn:active {
        transform: scale(0.98);
    }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--primary-dark);
        box-shadow: 0 6px 16px rgba(136,13,30,0.28);
    }

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: #f1eef0;
    color: var(--text);
}

    .btn-secondary:hover {
        background: #e6e1e3;
    }

.btn-danger {
    background: var(--secondary);
    color: #fff;
}

    .btn-danger:hover {
        filter: brightness(0.92);
    }

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

    .btn-outline:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 7px;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.alert-error {
    background: #fdeeef;
    color: var(--secondary);
    border: 1px solid #f6c9d1;
}

.alert-success {
    background: #eafaf0;
    color: var(--success);
    border: 1px solid #bfe9cf;
}

.link-muted {
    color: var(--text-muted);
    font-size: 13px;
}

    .link-muted a {
        color: var(--primary);
        font-weight: 600;
    }

.auth-footer {
    text-align: center;
    margin-top: 18px;
}

/* ---------- Structure de l'application ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 256px;
    background: var(--dark);
    color: #c9c6ce;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

    .sidebar-brand .badge-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: var(--primary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        color: #fff;
    }

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
}

    .sidebar-nav a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 14px;
        border-radius: var(--radius-sm);
        font-size: 14px;
        color: #b3aeb8;
        margin-bottom: 4px;
        font-weight: 500;
        transition: background .15s, color .15s;
    }

        .sidebar-nav a i {
            width: 18px;
            text-align: center;
            font-size: 15px;
        }

        .sidebar-nav a:hover {
            background: rgba(255,255,255,0.06);
            color: #fff;
        }

        .sidebar-nav a.active {
            background: var(--primary);
            color: #fff;
        }

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

    .sidebar-user .avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--secondary);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 14px;
    }

    .sidebar-user .info {
        overflow: hidden;
    }

    .sidebar-user .name {
        font-size: 13px;
        color: #fff;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-user .role {
        font-size: 11px;
        color: #928d99;
    }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

    .topbar h2 {
        margin: 0;
        font-size: 19px;
    }

    .topbar .sub {
        color: var(--text-muted);
        font-size: 13px;
        margin-top: 2px;
    }

.content {
    padding: 28px;
    flex: 1;
}

/* ---------- Cartes / statistiques ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .15s, box-shadow .15s;
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
    flex-shrink: 0;
}

.stat-value {
    font-size: 23px;
    font-weight: 700;
}

.stat-label {
    font-size: 12.5px;
    color: var(--text-muted);
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

    .card-header h3 {
        margin: 0;
        font-size: 16px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.chart-wrap {
    position: relative;
    height: 260px;
}

.dashboard-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.search-box {
    position: relative;
    max-width: 280px;
    flex: 1;
}

    .search-box input {
        padding-left: 36px;
    }

    .search-box i {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 13px;
        color: var(--text-muted);
    }

/* ---------- Tableaux ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    text-align: left;
    padding: 11px 14px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid #f4f1f2;
    vertical-align: middle;
}

tbody tr:hover {
    background: #fdf8f9;
}

.table-wrap {
    overflow-x: auto;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-primary {
    background: var(--light);
    color: var(--primary);
}

.badge-green {
    background: #e7f8ee;
    color: var(--success);
}

.badge-gray {
    background: #f1eef0;
    color: var(--text-muted);
}

.badge-amber {
    background: #fdf3e2;
    color: var(--warning);
}

.badge-red {
    background: #fdeeef;
    color: var(--secondary);
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text);
    transition: background .15s, border-color .15s;
}

    .icon-btn:hover {
        background: var(--light);
        border-color: var(--light);
        color: var(--primary);
    }

    .icon-btn.danger:hover {
        background: #fdeeef;
        border-color: #f6c9d1;
        color: var(--secondary);
    }

/* ---------- Étoiles (niveau de formation) ---------- */
.star-rating {
    display: inline-flex;
    gap: 2px;
    color: var(--warning);
}

    .star-rating i.bi-star-fill {
        color: var(--warning);
    }

    .star-rating i.bi-star {
        color: var(--border);
    }

.star-picker {
    display: inline-flex;
    gap: 6px;
    font-size: 22px;
    cursor: pointer;
}

    .star-picker i {
        color: var(--border);
        transition: color .1s;
    }

        .star-picker i.active {
            color: var(--warning);
        }

/* ---------- Modales ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,10,10,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

    .modal.modal-lg {
        max-width: 720px;
    }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

    .modal-header h3 {
        margin: 0;
        font-size: 16px;
    }

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- Divers ---------- */
.checkbox-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 7px;
}

    .checkbox-item:hover {
        background: #faf7f8;
    }

    .checkbox-item input {
        width: auto;
    }

.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.session-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform .15s, box-shadow .15s;
}

    .session-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

    .session-card .title {
        font-weight: 700;
        font-size: 15px;
    }

    .session-card .meta {
        font-size: 13px;
        color: var(--text-muted);
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

        .session-card .meta i {
            width: 16px;
            text-align: center;
            margin-right: 4px;
            color: var(--primary);
        }

.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.question-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

    .question-row input {
        flex: 1;
    }

/* ---------- Page de direct (avatar) ---------- */
.live-page {
    min-height: 100vh;
    background: var(--dark);
    color: #fff;
    display: flex;
    flex-direction: column;
}

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

    .live-topbar .info h2 {
        margin: 0;
        font-size: 17px;
    }

    .live-topbar .info p {
        margin: 2px 0 0;
        font-size: 13px;
        color: #9a94a1;
    }

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12.5px;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
}

    .status-dot.connected {
        background: var(--success);
    }

    .status-dot.error {
        background: var(--secondary);
    }

.live-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#avatar-container {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16/9;
    background: #17141a;
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

    #avatar-container video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.avatar-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #9a94a1;
}

.live-controls {
    padding: 20px;
    display: flex;
    justify-content: center;
    gap: 14px;
}

.questions-panel {
    max-width: 900px;
    width: 100%;
    margin: 0 auto 16px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 13px;
    color: #cfc9d3;
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 40;
        transition: left .2s;
    }

        .sidebar.open {
            left: 0;
        }

    .content {
        padding: 18px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ---------- QCM (examens) ---------- */
.qcm-question {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 16px;
}

    .qcm-question .qcm-numero {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--light);
        color: var(--primary);
        font-weight: 700;
        font-size: 12.5px;
        margin-right: 8px;
        flex-shrink: 0;
    }

    .qcm-question .qcm-texte {
        font-weight: 600;
        font-size: 14.5px;
        display: flex;
        align-items: flex-start;
        gap: 4px;
        margin-bottom: 14px;
    }

.qcm-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

    .qcm-option:hover {
        border-color: var(--primary);
        background: #fdf8f9;
    }

    .qcm-option input {
        width: auto;
        margin: 0;
    }

    .qcm-option.selected {
        border-color: var(--primary);
        background: var(--light);
    }

.qcm-submit-bar {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* ---------- Panneau de chat (session en direct) ---------- */
#avatar-stage {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chat-panel {
    background: #111015;
    border: 1px solid #262230;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    height: 420px;
    overflow: hidden;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #221f28;
    font-size: 12.5px;
    font-weight: 600;
    color: #cfc9d6;
    background: #17141c;
    flex-shrink: 0;
}

    .chat-panel-header i {
        color: var(--secondary);
    }

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0d0c10;
}

.chat-empty {
    color: #6f6a78;
    font-size: 13px;
    margin: auto;
    text-align: center;
}

.chat-message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

    .chat-message .chat-role {
        font-size: 10.5px;
        opacity: 0.6;
        margin-bottom: 3px;
        text-transform: uppercase;
        letter-spacing: .04em;
    }

    .chat-message .chat-bubble {
        padding: 9px 13px;
        border-radius: 14px;
        font-size: 13.5px;
        line-height: 1.45;
        word-wrap: break-word;
    }

    .chat-message.assistant {
        align-self: flex-start;
        align-items: flex-start;
    }

        .chat-message.assistant .chat-bubble {
            background: #232029;
            color: #f1eef2;
            border-bottom-left-radius: 4px;
        }

    .chat-message.user {
        align-self: flex-end;
        align-items: flex-end;
    }

        .chat-message.user .chat-bubble {
            background: var(--primary);
            color: #fff;
            border-bottom-right-radius: 4px;
        }

.chat-input-row {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #221f28;
    background: #14121a;
}

    .chat-input-row input {
        flex: 1;
        padding: 10px 14px;
        border-radius: 100px;
        border: 1px solid #322d38;
        background: #201c25;
        color: #fff;
        font-size: 13.5px;
    }

        .chat-input-row input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .chat-input-row input::placeholder {
            color: #6f6a78;
        }

    .chat-input-row button {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        padding: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .chat-input-row button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
