/* Polices auto-hébergées (cohérent avec panel-affichage et la contrainte "système
   fermé" du projet : pas de dépendance réseau au runtime). */
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/bebas-neue-v16-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/open-sans-v44-latin.woff2') format('woff2');
}

*, *::before, *::after { box-sizing: border-box; }

/* DA Herde Holding (or / noir sur fond clair), teintes prises sur le logo. Le texte
   sur fond or est noir (le blanc y serait illisible) ; le texte or sur fond blanc
   utilise la teinte foncée, seule assez contrastée. Le rouge reste réservé aux
   alertes et aux erreurs. */
:root {
  --herde-gold: #d4a82a;
  --herde-gold-hover: #b8901c;
  --herde-gold-dark: #8a6a00;
  --herde-gold-pale: #faf3dc;
  --herde-black: #141414;
  --alert-red: #c62828;
  --success-green: #2e7d32;
  --text-muted: #666;
  --border: #ddd;
}

html {
  /* Évite le flash noir entre deux pages (fond navigateur / View Transition). */
  background: #fff;
}
/* Session déjà connue (cache nav) : afficher tout de suite le formulaire, pas l'écran login. */
html.auth-likely #login-screen { display: none !important; }
html.auth-likely #mission-screen { display: block !important; }

/* Page (ex. Réglages) : rien de visible tant que les données ne sont pas prêtes. */
html.page-pending body {
  opacity: 0;
  pointer-events: none;
}
html.page-ready body {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.18s ease;
}
@media (prefers-reduced-motion: reduce) {
  html.page-ready body { transition: none; }
}
body {
  font-family: 'Open Sans', sans-serif;
  max-width: 420px;
  margin: 40px auto;
  padding: 0 16px;
  color: #222;
  background: #fff;
  /* Aide le morph View Transition quand Récap passe à 960px sur PC. */
  transition: max-width 0.28s ease;
}

/* Transitions entre pages admin (MPA Chromium / Safari récents).
   La nav garde le même nom → elle reste visuelle pendant le fondu du contenu. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: ease;
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  body { transition: none; }
}
#brand-logo { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto 24px; }
h1 {
  font-family: 'Bebas Neue', 'Open Sans', sans-serif; font-weight: 400; letter-spacing: 0.03em;
  color: var(--herde-black); font-size: 34px; margin: 0 0 20px; text-align: center;
}
/* Titre de section secondaire (ex. demandes invités sur "Mes missions") : même famille
   que h1, plus petit et aligné à gauche pour ne pas rivaliser avec le titre de page. */
.logo-hint { font-size: 14px; color: var(--text-muted); margin: 0 0 16px; }

/* Réglages : sections repliables (Comptes / Logo / Types) pour le téléphone. */
.settings-panel {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.settings-panel > summary {
  list-style: none;
  cursor: pointer;
  font-family: 'Bebas Neue', 'Open Sans', sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
  font-size: 22px;
  color: var(--herde-black);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}
.settings-panel > summary::-webkit-details-marker { display: none; }
.settings-panel > summary::after {
  content: '';
  width: 0.55em;
  height: 0.55em;
  border-right: 2px solid var(--herde-gold-dark);
  border-bottom: 2px solid var(--herde-gold-dark);
  transform: rotate(45deg);
  transition: transform 150ms ease;
  flex-shrink: 0;
}
.settings-panel[open] > summary::after { transform: rotate(-135deg); }
.settings-panel-body { padding: 0 16px 16px; border-top: 1px solid var(--border); padding-top: 16px; }

/* Pastille couleur : le padding global des input réduisait le swatch à une ligne. */
input[type="color"] {
  padding: 0;
  height: 42px;
  min-height: 42px;
  cursor: pointer;
  background: transparent;
  overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}
.color-field { max-width: 140px; }
.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  vertical-align: middle;
}
.logo-preview {
  display: block;
  max-width: 220px;
  width: 100%;
  height: auto;
  margin: 0 0 16px;
  background: #1a1a1a;
  padding: 12px;
  box-sizing: border-box;
}

h2 {
  font-family: 'Bebas Neue', 'Open Sans', sans-serif; font-weight: 400; letter-spacing: 0.03em;
  color: var(--herde-black); font-size: 22px; margin: 32px 0 4px;
}
.section-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.mono-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f7f7f7;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row label { flex: 1; min-width: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-muted); }
input, select, textarea, button { font-size: 16px; padding: 8px; font-family: inherit; }
input, select, textarea { border: 1px solid var(--border); border-radius: 4px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--herde-gold); outline-offset: 1px; border-color: var(--herde-gold); }

button {
  background: var(--herde-gold); color: var(--herde-black); border: none; border-radius: 6px; padding: 10px;
  cursor: pointer; font-weight: 600; transition: background-color 150ms ease, transform 100ms ease;
}
button:hover { background: var(--herde-gold-hover); }
button:active { transform: scale(0.97); }
button:disabled { background: #ead9a4; color: #6b5d33; cursor: default; transform: none; }

/* Action secondaire répétée dans une liste (ex. "Changer" par compte) : un bouton
   plein rouge à chaque ligne devient vite trop lourd visuellement. Fond rouge très
   clair plutôt qu'un simple contour (qui, désactivé, devenait presque invisible :
   bordure et texte de la même couleur pâle — corrigé ici avec un vrai remplissage gris
   au repos, lisible même désactivé). */
.button-compact {
  flex: 0 0 auto; width: auto; font-weight: 600; border: 1px solid transparent;
  background: var(--herde-gold-pale); color: var(--herde-gold-dark);
}
.button-compact:hover:not(:disabled) { background: var(--herde-gold); color: var(--herde-black); }
.button-compact:disabled { background: #eee; color: #999; }

/* Archiver / supprimer dans Réglages (types et canaux) : distinct du bouton Enregistrer. */
.button-archive {
  background: #f3eee6;
  color: #6b5a3e;
  border-color: #d9cbb3;
}
.button-archive:hover:not(:disabled) {
  background: #e8dcc8;
  color: var(--herde-black);
  border-color: var(--herde-gold);
}
.button-danger {
  background: #f7ebe8;
  color: #8a3a2e;
  border-color: #e5c4bc;
}
.button-danger:hover:not(:disabled) {
  background: #efd2cb;
  color: #5c2118;
  border-color: #c9887c;
}

/* Menu partagé entre les pages authentifiées (voir nav.js) :
   icônes + libellés courts pour tenir sur une ligne (admin : 4 items).
   min-height réserve la place pendant le tout premier paint (avant JS). */
#main-nav {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 4px;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; min-height: 52px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  view-transition-name: todowall-nav;
}
#main-nav .nav-brand {
  height: 28px; width: 28px; object-fit: contain;
  flex: 0 0 auto; margin-right: 4px;
}
#main-nav a.nav-link {
  color: var(--text-muted); text-decoration: none;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 52px; padding: 6px 8px; border-radius: 8px; flex: 0 0 auto;
  white-space: nowrap;
}
#main-nav a.nav-link span { line-height: 1.1; }
#main-nav a.nav-link:hover { color: var(--herde-gold-dark); background: #faf7ef; }
#main-nav a.nav-link.active {
  color: var(--herde-gold-dark); font-weight: 600;
  background: var(--herde-gold-pale);
}
#main-nav .nav-logout {
  margin-left: auto; width: 36px; height: 36px; flex: 0 0 auto; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px;
}
#main-nav .nav-logout:hover { background: #f5f5f5; color: var(--herde-gold-dark); border-color: var(--herde-gold); }

.secondary-link { font-size: 14px; margin-top: 24px; }
.secondary-link a { color: var(--text-muted); }
.secondary-link a:hover { color: var(--herde-gold-dark); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 15px; }
dt { color: var(--text-muted); }
dd { margin: 0; font-weight: 600; }
#missions-list, #comptes-list, #invitees-list, #others-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
#comptes-list { margin-top: 24px; }
#missions-list li, #comptes-list li, #invitees-list li, #others-list li { border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mission-text { margin: 0; }
.list-controls { margin-bottom: 16px; }

/* Récap (NEATODO-14) : tuiles KPI + barres CSS.
   Sur PC (≥900px) : page plus large ; le saut est amorti par View Transitions. */
.kpi-grid { margin: 0 0 8px; }
.kpi-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}
@media (min-width: 900px) {
  body.page-recap { max-width: 960px; }
  .kpi-tiles { grid-template-columns: repeat(4, 1fr); }
}
.kpi-tile {
  margin: 0;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--herde-gold-pale);
  text-align: center;
}
.kpi-tile-value {
  display: block;
  font-family: 'Bebas Neue', 'Open Sans', sans-serif;
  font-size: 32px;
  letter-spacing: 0.02em;
  color: var(--herde-black);
  line-height: 1.1;
}
.kpi-tile-label {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-tile-pending { opacity: 0.55; }
.kpi-tile-pending .kpi-tile-value { color: var(--text-muted); }
.kpi-bars {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.kpi-bars-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--herde-black);
}
.kpi-bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 28%) 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.kpi-bar-row:last-child { margin-bottom: 0; }
.kpi-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi-bar-track {
  height: 10px;
  border-radius: 5px;
  background: #eee;
  overflow: hidden;
}
.kpi-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--herde-gold);
  min-width: 0;
}
.kpi-bar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--herde-black);
  min-width: 1.5em;
  text-align: right;
}
#validated-list, #events-list {
  list-style: none; margin: 0 0 24px; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
}
#validated-list li, #events-list li {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
#events-list li.event-line {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 10px 12px;
  align-items: start;
}
@media (max-width: 420px) {
  #events-list li.event-line { grid-template-columns: 1fr; gap: 2px; }
}
.event-when { margin: 0; font-size: 12px; color: var(--text-muted); }
.event-body { margin: 0; font-size: 14px; }
.empty-hint {
  border: none !important; padding: 0 !important;
  color: var(--text-muted); font-size: 14px;
  display: block !important;
}
.section-hint { font-size: 14px; color: var(--text-muted); margin: 0 0 12px; }
h2 {
  font-family: 'Bebas Neue', 'Open Sans', sans-serif; font-weight: 400;
  letter-spacing: 0.03em; font-size: 22px; color: var(--herde-black);
  margin: 28px 0 12px; text-align: left;
}
/* Récap : sections validées (ouverte) + historique (fermée) en accordéon. */
.recap-validated,
.recap-history { margin: 28px 0 24px; }
.recap-history #events-list,
.recap-validated #validated-list { margin-bottom: 12px; }
.recap-history #events-more,
.recap-validated #validated-more {
  width: 100%;
  background: #fff;
  color: var(--herde-gold-dark);
  border: 1px solid var(--herde-gold);
}
.recap-history #events-more:hover:not(:disabled),
.recap-validated #validated-more:hover:not(:disabled) {
  background: var(--herde-gold-pale);
}
.recap-history #events-more:disabled,
.recap-validated #validated-more:disabled { opacity: 0.6; }
/* Même règle que l'écran d'affichage (seuil selon le statut, calculé par l'API). */
#missions-list li.mission-alerte, #invitees-list li.mission-alerte, #others-list li.mission-alerte { border-color: var(--alert-red); border-left-width: 4px; }
.alerte-badge { margin: 0; font-size: 13px; font-weight: 600; color: var(--alert-red); }
.mission-meta { margin: 0; font-size: 13px; color: #777; }

/* Retour visuel des formulaires : même emplacement de texte, juste une couleur qui dit
   si ça a marché ou non (avant : même gris pour "Mission créée." et pour une erreur). */
#feedback, #login-feedback { min-height: 1.2em; }
.feedback-success { color: var(--success-green); }
.feedback-error { color: var(--alert-red); }

/* Bascule connexion / formulaire (voir app.js) : fondu plutôt qu'un affichage brutal. */
.fade-in { animation: fadeIn 200ms ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Bascule « Afficher les archivés » (types + canaux) : switch rather than bare checkbox. */
.show-archived-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.show-archived-toggle:hover { border-color: #ccc; }
.show-archived-toggle:has(input:checked) {
  border-color: var(--herde-gold);
  background: var(--herde-gold-pale);
  color: var(--herde-gold-dark);
}
.show-archived-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.show-archived-switch {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 22px;
  border-radius: 11px;
  background: #d0d0d0;
  transition: background 150ms ease;
}
.show-archived-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 150ms ease;
}
.show-archived-toggle input:checked + .show-archived-switch {
  background: var(--herde-gold);
}
.show-archived-toggle input:checked + .show-archived-switch::after {
  transform: translateX(14px);
}
.show-archived-toggle input:focus-visible + .show-archived-switch {
  outline: 2px solid var(--herde-gold-dark);
  outline-offset: 2px;
}
.show-archived-label { font-weight: 600; }

/* Liste types / canaux : chaque ligne est un encart repliable (sans puces). */
#types-list, #canaux-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.type-list-empty { color: var(--text-muted); font-size: 14px; padding: 8px 0; }
.type-item { margin: 0; padding: 0; border: none; }
.type-item-archived { opacity: 0.7; }
.type-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
}
.type-panel-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  user-select: none;
}
.type-panel-summary::-webkit-details-marker { display: none; }
.type-panel-summary::after {
  content: '';
  margin-left: auto;
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 150ms ease;
  flex-shrink: 0;
}
.type-panel[open] > .type-panel-summary::after { transform: rotate(-135deg); }
.type-panel-label { font-weight: 600; font-size: 15px; }
.type-panel-badge {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}
.type-panel-body {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.type-panel-actions { margin-top: 4px; }
.type-panel-actions .button-compact { flex: 1; }

/* Afficher/masquer le mot de passe (formulaire de création + changement de mot de passe) */
.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.toggle-password {
  position: absolute; right: 2px; top: 2px; bottom: 2px; width: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; color: var(--text-muted); font-size: 16px; padding: 0; border-radius: 4px;
}
.toggle-password:hover { background: #f5f5f5; }
.toggle-password:active { transform: scale(0.9); }

/* Lien vers l'écran d'affichage en mode PC (NEATODO-9) : sans intérêt sur un téléphone,
   où le tableau à 7 colonnes serait illisible. Pas dans le menu, qui passerait sur deux lignes. */
@media (max-width: 700px) { .pc-only { display: none; } }

/* Bouton « Choisir dans mes contacts » (NEATODO-6), au-dessus du champ Destinataire. */
.contact-picker { align-self: flex-start; padding: 8px 14px; }
