:root {
  /* Image de marque officielle "Formation à Distance — Bénin & Québec" :
     bleu Québec en couleur principale, vert Bénin réservé au succès,
     or Bénin en accent, rouge Bénin pour les erreurs. */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1f2320;
  --muted: #6b6f6c;
  --border: #e1e0dc;
  --primary: #02498a;
  --primary-dark: #01345f;
  --primary-light: #e3ecf5;
  --success: #008533;
  --success-light: #e3f3e8;
  --accent: #f5a300;
  --accent-light: #fdf1d9;
  --danger: #d81e2c;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(31,35,32,0.06);
  --shadow-md: 0 4px 16px rgba(31,35,32,0.08);
  font-size: 17px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

a { color: var(--primary-dark); }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

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

header.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}

nav.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

nav.tabs a,
.tabs-logout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  padding: 9px 4px 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 2px solid transparent;
}

.tabs-logout {
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  font: inherit;
  cursor: pointer;
}

nav.tabs a.active {
  color: var(--primary-dark);
  font-weight: 600;
  border-top: 2px solid var(--primary);
}

/* Écran d'accueil admin : logo compact en en-tête, puis une grille de
   pictogrammes énormes colorés en alternance selon la palette officielle. */
.home-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.home-logo {
  display: block;
  width: 150px;
  height: auto;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 8px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 34px 16px;
  background: var(--surface);
  border: none;
  border-radius: 22px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
  transition: transform 0.2s cubic-bezier(.22,.9,.32,1.5), box-shadow 0.2s;
}

.home-tile-icon {
  display: flex;
  color: inherit;
}

.home-tile-icon svg {
  display: block;
  transition: transform 0.3s cubic-bezier(.22,.9,.32,1.5);
}

.home-tile-label {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* Palette officielle en alternance sur les tuiles. */
.home-tile.color-blue  { background: var(--primary); color: #fff; }
.home-tile.color-green { background: var(--success); color: #fff; }
.home-tile.color-gold  { background: var(--accent); color: #2b1c00; }

.home-tile:hover,
.home-tile:focus-visible {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(20,20,18,0.22);
}

.home-tile:hover .home-tile-icon svg,
.home-tile:focus-visible .home-tile-icon svg {
  transform: rotate(-6deg) scale(1.08);
}

.home-tile:active { transform: translateY(-2px) scale(0.99); }

@media (max-width: 640px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }
}

h1 { font-size: 1.35rem; margin: 0 0 12px; }
h1.page-title { display: flex; align-items: center; gap: 9px; }
h1.page-title svg { color: var(--primary); flex-shrink: 0; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--primary-dark);
}
.section-title svg { flex-shrink: 0; }

.list-item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
}

.list-item .title { font-weight: 600; }
.list-item .meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1ee;
  color: var(--muted);
  margin-right: 6px;
}

.badge.open { background: var(--success-light); color: var(--success); }
.badge.closed { background: #f1e4e4; color: var(--danger); }
.badge.done { background: var(--success-light); color: var(--success); }
.badge.new { background: var(--accent-light); color: #8a5a00; font-weight: 700; }
.badge svg { vertical-align: -1px; margin-right: 2px; }

/* Écran d'accueil participant : tout ce qui demande une action (message,
   document, sondage) remonte dans une seule file "À faire" triée par
   priorité ; le reste (déjà consulté) devient une référence calme en
   dessous, une section par module. */
.greet { font-size: 1.15rem; font-weight: 700; margin: 0 0 14px; }

.progress-card {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.progress-card.done { background: var(--success); }
.progress-ring { flex-shrink: 0; }
.progress-text { flex: 1; min-width: 0; }
.progress-text .label { font-size: 0.78rem; opacity: 0.85; margin: 0 0 2px; }
.progress-text .count { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; }

.eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.queue { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
}
.queue-item.chat { border-left-color: var(--primary); }

/* Invitation à une session de clavardage en cours : un admin attend une
   réponse en direct, contrairement au reste de la file (à consulter
   quand on a le temps) — traitement plein bleu pour que ça se démarque
   au premier coup d'oeil, pas juste une bordure de couleur différente. */
.queue-item.room-invite {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.queue-item.room-invite .meta { color: rgba(255,255,255,.85); }

.chip {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-light);
  color: #8a5a00;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip.chat { background: var(--primary-light); color: var(--primary-dark); }
.chip.room-invite { background: rgba(255,255,255,.22); color: #fff; }

.queue-item .body { flex: 1; min-width: 0; }
.queue-item .title { font-size: 0.88rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .meta { font-size: 0.74rem; color: var(--muted); margin: 1px 0 0; }

.all-caught-up {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--success-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 20px;
  color: #0a5c24;
}
.all-caught-up svg { flex-shrink: 0; }
.all-caught-up p { margin: 0; font-size: 0.84rem; font-weight: 600; }

.ref-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 6px;
  margin-bottom: 14px;
}
.ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.ref-head h2 {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ref-head .ic {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Une couleur par section de référence (jamais d'éléments "en attente"
   ici — l'or/le vert ne risquent donc pas d'être lus comme un état,
   contrairement à la file À faire qui reste uniformément or. */
.ref-head .ic.gold { background: var(--accent-light); color: #8a5a00; }
.ref-head .ic.green { background: var(--success-light); color: var(--success); }
.ref-count { font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ref-list { display: flex; flex-direction: column; }
.ref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.ref-row:last-child { border-bottom: none; }
.ref-row.done { color: var(--muted); }
.ref-row .row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

/* Messages : titre cliquable qui déplie le corps en place (aucune
   navigation, un seul appel réseau léger pour marquer comme lu). */
.message-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 0;
  margin-bottom: 8px;
  overflow: hidden;
}

.message-title-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  text-align: left;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
}

.message-title-btn svg { color: var(--primary); flex-shrink: 0; }
.message-title-text { flex: 1; }
.message-badge { flex-shrink: 0; }

.message-body { padding: 0 14px 14px; }
.message-body p { margin: 0 0 12px; white-space: pre-line; }

/* Conversation individuelle participant <-> administrateurs : bulles de
   clavardage, l'participant toujours à droite (en couleur) pour rester
   cohérent que ce soit l'participant ou un admin qui consulte le fil. */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-line;
}

.chat-bubble .chat-meta {
  display: block;
  font-size: 0.72rem;
  margin-top: 4px;
  opacity: 0.75;
}

.chat-bubble.from-admin {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble.from-participant {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.chat-bubble.from-participant .chat-attachment { background: rgba(255,255,255,0.22); color: #fff; }

.chat-empty {
  color: var(--muted);
  text-align: center;
  padding: 16px 10px;
  font-size: 0.9rem;
}

.chat-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-top: 4px;
}

.chat-compose textarea {
  flex: 1;
  min-height: 44px;
  margin: 0;
  resize: none;
}

.chat-compose select { flex-basis: 100%; margin: 0; }

.chat-compose .btn { margin: 0; white-space: nowrap; }

form { margin: 0; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 12px 0 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; min-height: 70px; }

.password-field { position: relative; }
.password-field input[type="password"],
.password-field input[type="text"] { padding-right: 42px; }
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible { color: var(--primary-dark); }

.field-help { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.field-help svg { vertical-align: -2px; margin-left: 1px; }
label svg { vertical-align: -3px; margin-right: 1px; }
.field-error { color: var(--danger); font-size: 0.85rem; margin-top: 4px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: normal; }
.checkbox-row input { width: auto; }

/* Choix binaires importants (type de document, visibilité) présentés
   comme des cartes cliquables plutôt que des boutons radio nus — plus
   rapide à repérer d'un coup d'œil pour un admin non-technique. */
.choice-cards {
  display: flex;
  gap: 10px;
  margin: 8px 0 4px;
}

.choice-card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  transition: border-color 0.15s, background-color 0.15s;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card svg { color: var(--muted); transition: color 0.15s; }

.choice-card small { display: block; font-weight: 400; color: var(--muted); margin-top: 1px; }

.choice-card:has(input:checked),
.choice-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.choice-card:has(input:checked) svg,
.choice-card.is-selected svg { color: var(--primary); }

.btn {
  display: inline-block;
  padding: 11px 18px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s, transform 0.1s;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { background: var(--primary-dark); transform: scale(0.98); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.block { display: block; width: 100%; margin-top: 16px; }

/* Branded auth card — used by the admin and participant login/set-password screens. */
.auth-card {
  max-width: 380px;
  margin: 40px auto 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  text-align: center;
}

.auth-card h1 { margin: 16px 0 2px; }
.auth-subtitle { color: var(--muted); margin: 0 0 22px; font-size: 0.9rem; }
.auth-card form { text-align: left; }
.auth-card label { display: flex; align-items: center; gap: 6px; }
.auth-card .field-help { text-align: center; margin-top: 18px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.alert.status { background: var(--success-light); color: var(--success); }
.alert.error { background: #f6e6e6; color: var(--danger); }

.temp-code {
  font-size: 1.6rem;
  letter-spacing: 3px;
  font-weight: 700;
  text-align: center;
  padding: 14px;
  background: #eef1ee;
  border-radius: var(--radius);
  margin: 10px 0;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
tbody tr[onclick]:hover { background: var(--bg); }

.empty-state { color: var(--muted); text-align: center; padding: 24px 10px; }
.empty-state svg { display: block; margin: 0 auto 8px; opacity: 0.6; }

.icon-doc, .icon-video { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-right: 4px; }

.embed-placeholder {
  background: #111;
  border-radius: var(--radius);
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.embed-placeholder img { width: 100%; height: 100%; object-fit: cover; opacity: 0.6; }

.embed-placeholder button {
  position: absolute;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 0.95rem;
}

.office-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.office-placeholder button {
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Admin duplex layout: functions on the left, live participant-view preview on the right. */
.admin-shell {
  display: flex;
  align-items: flex-start;
}

.admin-main {
  flex: 2 1 0;
  min-width: 0;
}

.phone-preview-panel {
  flex: 1 1 0;
  min-width: 280px;
  position: sticky;
  top: 53px;
  align-self: flex-start;
  height: calc(100vh - 53px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.preview-controls select {
  flex: 1;
  max-width: 220px;
}

#preview-shuffle {
  padding: 6px 12px;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.preview-specific-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.preview-specific-toggle input { width: auto; }

.preview-search-wrap { width: 100%; }

.preview-search-wrap input[type="search"] { margin-bottom: 4px; }

.preview-search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 110px;
  overflow-y: auto;
}

.preview-search-results button {
  text-align: left;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.preview-search-results button:hover { background: var(--border); }

.preview-participant-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.phone-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: auto;
  max-width: 100%;
  aspect-ratio: 9 / 19.5;
  background: #3a3a3c;
  border-radius: 26px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.phone-screen {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
}

.phone-screen iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 960px) {
  .admin-shell { flex-direction: column; }
  .phone-preview-panel {
    position: static;
    height: auto;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

.embed-placeholder iframe { width: 100%; height: 100%; border: 0; }
