:root {
    --app-primary: #2b4acb;
    --app-bg: #f4f6fb;
    --bs-primary: #2b4acb;
    --bs-primary-rgb: 43, 74, 203;
    --bs-link-color: #2b4acb;
    --bs-link-color-rgb: 43, 74, 203;
}

body {
    background: var(--app-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #223ba3;
    --bs-btn-hover-border-color: #223ba3;
    --bs-btn-active-bg: #1c3189;
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
}

.navbar-brand .logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: .5rem;
    background: #fff; color: var(--app-primary); font-weight: 800; margin-right: .5rem;
}

.card { border: 0; box-shadow: 0 1px 3px rgba(20, 30, 60, .08); border-radius: .75rem; }
.card-header { background: transparent; font-weight: 600; }

.stat-card .value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .label { color: var(--bs-secondary-color); font-size: .875rem; }

.hero {
    background: linear-gradient(135deg, #2b4acb 0%, #5b3fc4 100%);
    color: #fff; border-radius: 1rem;
}
.hero .lead { opacity: .9; }

.role-card { transition: transform .15s, box-shadow .15s; }
.role-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(20, 30, 60, .12); }
.role-card .icon { font-size: 2.5rem; }

.table > :not(caption) > * > * { vertical-align: middle; }
.table-hover tbody tr[data-href] { cursor: pointer; }

/* ---------- Constructeur de contrôle ---------- */
.builder-question {
    border-left: 4px solid var(--app-primary);
    transition: box-shadow .15s;
}
.builder-question.is-section { border-left-color: #f0ad4e; background: #fffaf2; }
.builder-question:focus-within { box-shadow: 0 0 0 .2rem rgba(43, 74, 203, .2); }
.builder-question .drag-handle { cursor: grab; color: #9aa3b5; font-size: 1.25rem; user-select: none; }
.builder-question.sortable-ghost { opacity: .4; }
.builder-question .q-number {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2rem; height: 2rem; border-radius: 50%;
    background: var(--app-primary); color: #fff; font-weight: 700; font-size: .875rem;
}
.builder-choice .form-check-input { width: 1.3em; height: 1.3em; cursor: pointer; }
.builder-choice .form-check-input:checked { background-color: #198754; border-color: #198754; }
.builder-toolbar { position: sticky; bottom: 0; z-index: 10; }
.builder-empty { border: 2px dashed #c9d0e0; border-radius: .75rem; }
.type-btn { min-width: 9rem; }

/* ---------- Passage d'un contrôle ---------- */
.exam-timer {
    position: sticky; top: 0; z-index: 1020;
}
.exam-timer .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; }
.exam-timer.warning { background: #fff3cd !important; }
.exam-timer.danger { background: #f8d7da !important; }
.question-card .q-label { white-space: pre-wrap; font-size: 1.05rem; }
.question-card .form-check { padding: .6rem .75rem .6rem 2.25rem; border: 1px solid #e3e7ef; border-radius: .5rem; margin-bottom: .5rem; background: #fff; }
.question-card .form-check:hover { background: #f5f7ff; }
.question-card .form-check-input:checked + .form-check-label { font-weight: 600; }
.answer-correct { background: #d1e7dd !important; border-color: #a3cfbb !important; }
.answer-wrong { background: #f8d7da !important; border-color: #f1aeb5 !important; }
.pre-wrap { white-space: pre-wrap; }

/* ---------- Impression des identifiants ---------- */
.credential-card { border: 1px dashed #999; border-radius: .5rem; padding: .75rem 1rem; break-inside: avoid; page-break-inside: avoid; }
.credential-card code { font-size: 1.1rem; color: #000; }
@media print {
    body { background: #fff; }
    .no-print, nav.navbar, footer, .alert { display: none !important; }
    .card { box-shadow: none; }
    main { padding: 0 !important; }
}

/* ---------- Histogrammes (administration) ---------- */
.bar-chart { position: relative; padding-left: 2rem; }
.bar-chart-grid { position: absolute; inset: 0 0 1.25rem 0; pointer-events: none; }
.bar-chart-grid span {
    position: absolute; left: 0; right: 0; transform: translateY(50%);
    font-size: .7rem; color: #6c757d; border-bottom: 1px solid #edf0f5; line-height: 1;
}
.bar-chart-plot { display: flex; align-items: stretch; gap: 2px; height: 9rem; margin-bottom: .25rem; }
.bar-col { flex: 1; display: flex; align-items: flex-end; position: relative; z-index: 1; outline: none; }
.bar-col:hover, .bar-col:focus-visible { background: rgba(43, 74, 203, .06); }
.bar-col .bar { width: 100%; min-height: 0; border-radius: 4px 4px 0 0; }
.bar-chart-x { display: flex; justify-content: space-between; }

/* ---------- Médias : bibliothèque, sélecteur, questions ---------- */
.media-preview { height: 10rem; background: #f8f9fb; border-bottom: 1px solid #edf0f5; border-radius: .75rem .75rem 0 0; overflow: hidden; }
.media-preview > a, .media-preview img, .media-preview svg { display: block; width: 100%; height: 100%; object-fit: contain; }
.media-dropzone { border: 2px dashed #c9d0e0; transition: background .15s, border-color .15s; }
.media-dropzone.is-dragover { background: #eef2ff; border-color: var(--app-primary); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.media-tile:hover { border-color: var(--app-primary) !important; }
.media-thumb { height: 6.5rem; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: .35rem; overflow: hidden; }
.media-thumb img, .media-thumb svg { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-thumb-sm { width: 4.5rem; height: 3rem; }
.question-image { max-width: 100%; max-height: 24rem; height: auto; border-radius: .5rem; border: 1px solid #e3e7ef; }
.question-figure { max-width: 40rem; border: 1px solid #e3e7ef; border-radius: .5rem; overflow: hidden; background: #fff; }
.question-figure svg { display: block; width: 100%; height: auto; }
.question-audio { max-width: 100%; width: 24rem; }

/* ---------- Éditeur de figures ---------- */
.figure-canvas { max-width: 60rem; outline: none; }
.figure-svg-edit { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; user-select: none; }
.figure-svg-edit .fig-point { cursor: pointer; }
.figure-svg-edit .fig-shape:hover line, .figure-svg-edit .fig-shape:hover circle, .figure-svg-edit .fig-shape:hover polygon { filter: drop-shadow(0 0 .05px #2b4acb); }
