/*
 * ALGM Bénévoles — Styles front-end
 * Charte : Bleu marine #202346 · Or #EAB93A · Blanc #FFFFFF
 * Tous les sélecteurs sont préfixés .algm-bv- (isolation thème)
 */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────────── */
/* Source de vérité : theme-algm-block/style.css. Les valeurs ci-dessous sont
   des fallbacks pour le cas où le plugin est utilisé sur un autre thème. */
:root {
  --algm-bleu:        #202346;
  --algm-or:          #EAB93A;
  /* Décision design Phase 5.12 : l'or de marque est réservé aux fonds, CTA,
   * et textes sur fond foncé (bleu marine). Sur fond clair, tous les textes
   * d'accent passent en var(--algm-bleu) — lisibilité maximale (14.5:1) et
   * cohérence avec l'identité visuelle ALGM. */
  --algm-blanc:       #FFFFFF;
  --algm-gris:        #F5F5F5;
  --algm-gris-bord:   #E0E0E0;
  --algm-texte:       #1a1a2e;
  --algm-texte-muted: #6B7280;
  --algm-erreur:      #c0392b;
  --algm-succes:      #27ae60;
  --algm-font:        'Open Sans', Arial, sans-serif;             /* legacy alias */
  --algm-font-texte:  'Open Sans', Arial, Helvetica, sans-serif;
  --algm-font-titre:  Verdana, Geneva, sans-serif;
  --algm-radius-sm:   4px;
  --algm-radius:      8px;
  --algm-radius-lg:   12px;
  --algm-radius-pill: 999px;
  --algm-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.04);
  --algm-shadow:      0 2px 8px rgba(32, 35, 70, 0.10);
  --algm-shadow-lg:   0 6px 16px rgba(32, 35, 70, 0.12);
  --algm-transition:  0.2s ease;
}

/* ── Container principal ────────────────────────────────────────────────────── */
#algm-bv-app {
  font-family: var(--algm-font);
  color:        var(--algm-texte);
  min-height:   600px;
}

/* ── En-tête ────────────────────────────────────────────────────────────────── */
.algm-bv-header {
  background:      var(--algm-blanc);
  color:           var(--algm-bleu);
  /* border-bottom:   4px solid var(--algm-gris-bord); */
  padding:         16px 24px;
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             16px;
}

.algm-bv-header img {
  height: 52px;
  width:  auto;
}

.algm-bv-header__title {
  font-size:   1.25rem;
  font-weight: 600;
  font-family: Verdana, Geneva, sans-serif;
  color:       var(--algm-bleu);
  margin:      0;
}

.algm-bv-header__sub {
  font-size: 0.8rem;
  color:     rgba(32, 35, 70, 0.7);
  margin:    2px 0 0;
}

/* ── Navigation desktop (top nav) ─────────────────────────────────────────── */
/* Affichée par défaut. Cachée sur mobile au profit de .algm-bv-bottomnav (cf. responsive.css). */
.algm-bv-topnav {
  display:    flex;
  gap:        4px;
  padding:    0 16px;
  background: var(--algm-blanc);
  overflow-x: auto;
}

.algm-bv-topnav__link {
  padding:         12px 18px;
  color:           var(--algm-bleu);
  font-size:       0.9rem;
  font-weight:     600;
  text-decoration: none;
  border-bottom:   3px solid transparent;
  white-space:     nowrap;
  transition:      color var(--algm-transition), border-color var(--algm-transition);
  cursor:          pointer;
}

.algm-bv-topnav__link:hover,
.algm-bv-topnav__link--active,
.algm-bv-topnav__link:focus {
  color:        var(--algm-bleu);
  border-color: var(--algm-or);
}

.algm-bv-topnav__link:focus-visible {
  outline:        2px solid var(--algm-or);
  outline-offset: -2px;
}

/* ── Navigation mobile (bottom nav) ────────────────────────────────────────── */
/* Cachée par défaut sur desktop. Affichée < 768px (cf. responsive.css). */
.algm-bv-bottomnav {
  display: none;
}

/* Note : les sous-onglets du hub Missions utilisent .algm-bv-subtabs / __btn
 * (mêmes classes que la Boîte à outils, définies dans components.css). */

/* ── Menu utilisateur (avatar + prénom + chevron + dropdown) ─────────────── */
/* v1.12.0 — Le bouton déclencheur n'est plus l'avatar seul mais un trigger
 * « pill » composé : avatar + prénom + chevron. Objectif UX : sur mobile comme
 * sur desktop, le bénévole identifie immédiatement « ceci est mon compte ». */
.algm-bv-user-menu {
  position: relative;
  flex-shrink: 0;
}

.algm-bv-user-menu__trigger {
  display:         inline-flex;
  align-items:     center;
  gap:             10px;
  padding:         4px 12px 4px 4px;
  background:      var(--algm-blanc);
  border:          1px solid var(--algm-gris-bord);
  border-radius:   999px;
  color:           var(--algm-bleu);
  font-family:     inherit;
  font-size:       0.9rem;
  font-weight:     600;
  cursor:          pointer;
  transition:      background var(--algm-transition), border-color var(--algm-transition), box-shadow var(--algm-transition);
  min-height:      48px;
}

.algm-bv-user-menu__trigger:hover {
  background:   #fdf9ec; /* teinte chaude très pâle (or à 5 %) */
  border-color: var(--algm-or);
}

.algm-bv-user-menu__trigger:focus-visible {
  outline:        2px solid var(--algm-or);
  outline-offset: 2px;
}

.algm-bv-user-menu__trigger--open {
  background:   #fdf9ec;
  border-color: var(--algm-or);
  box-shadow:   0 0 0 3px rgba(234, 185, 58, 0.18);
}

.algm-bv-user-menu__avatar {
  width:           40px;
  height:          40px;
  border-radius:   50%;
  background:      var(--algm-bleu);
  color:           var(--algm-or);
  border:          2px solid var(--algm-or);
  font-size:       0.95rem;
  font-weight:     700;
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  overflow:        hidden;
  flex-shrink:     0;
}

.algm-bv-user-menu__avatar-img {
  width:      100%;
  height:     100%;
  object-fit: cover;
  display:    block;
}

.algm-bv-user-menu__avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Modificateur appliqué quand une photo est chargée — supprime le fond bleu
 * (qui transparaîtrait via les coins arrondis de l'image) tout en gardant la bordure. */
.algm-bv-user-menu__avatar--photo {
  background: var(--algm-blanc);
}

.algm-bv-user-menu__name {
  max-width:     140px;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
  line-height:   1.2;
}

.algm-bv-user-menu__chevron {
  color:      var(--algm-bleu);
  opacity:    0.55;
  transition: transform var(--algm-transition), opacity var(--algm-transition);
  flex-shrink: 0;
}

.algm-bv-user-menu__trigger:hover .algm-bv-user-menu__chevron,
.algm-bv-user-menu__trigger--open .algm-bv-user-menu__chevron {
  opacity: 1;
}

.algm-bv-user-menu__trigger--open .algm-bv-user-menu__chevron {
  transform: rotate(180deg);
}

.algm-bv-user-menu__dropdown {
  position:    absolute;
  top:         calc(100% + 8px);
  right:       0;
  min-width:   200px;
  background:  var(--algm-blanc);
  border:      1px solid var(--algm-gris-bord);
  border-radius: 10px;
  box-shadow:  0 8px 24px rgba(32, 35, 70, 0.15);
  padding:     6px;
  z-index:     100;
  animation:   algmFadeIn 0.15s ease;
}

.algm-bv-user-menu__item {
  display:        flex;
  align-items:    center;
  gap:            10px;
  width:          100%;
  padding:        10px 12px;
  background:     transparent;
  border:         none;
  border-radius:  6px;
  color:          var(--algm-texte);
  font-family:    inherit;
  font-size:      0.9rem;
  font-weight:    500;
  text-align:     left;
  cursor:         pointer;
  transition:     background var(--algm-transition);
}

.algm-bv-user-menu__item:hover {
  background: var(--algm-gris);
}

.algm-bv-user-menu__item:focus-visible {
  outline:        2px solid var(--algm-or);
  outline-offset: -2px;
}

.algm-bv-user-menu__item--danger {
  color:      var(--algm-erreur);
  margin-top: 4px;
  border-top: 1px solid var(--algm-gris-bord);
  border-radius: 0 0 6px 6px;
  padding-top: 12px;
}

.algm-bv-user-menu__icon {
  width:           20px;
  height:          20px;
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  flex-shrink:     0;
  font-size:       1rem;
  line-height:     1;
}

.algm-bv-user-menu__icon svg {
  display: block;
  width:   18px;
  height:  18px;
}

/* ── Contenu ────────────────────────────────────────────────────────────────── */
.algm-bv-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Cartes ─────────────────────────────────────────────────────────────────── */
.algm-bv-card {
  background:    var(--algm-blanc);
  border:        1px solid var(--algm-gris-bord);
  border-radius: var(--algm-radius);
  padding:       20px;
  box-shadow:    var(--algm-shadow);
}

.algm-bv-card__title {
  font-size:     1rem;
  font-weight:   600;
  color:         var(--algm-bleu);
  font-family:   Verdana, Geneva, sans-serif;
  border-bottom: 2px solid var(--algm-or);
  padding-bottom: 8px;
  margin:        0 0 16px;
}

/* ── Statistiques rapides ────────────────────────────────────────────────────── */
.algm-bv-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.algm-bv-stat-card {
  background:    var(--algm-bleu);
  color:         var(--algm-blanc);
  border-radius: var(--algm-radius);
  padding:       20px 16px;
  text-align:    center;
}

.algm-bv-stat-card__value {
  font-size:   2rem;
  font-weight: 700;
  color:       var(--algm-or);
  line-height: 1;
}

.algm-bv-stat-card__label {
  font-size:  0.75rem;
  margin-top: 6px;
  opacity:    0.85;
}

/* ── Boutons ────────────────────────────────────────────────────────────────── */
.algm-bv-btn {
  display:         inline-flex;
  align-items:     center;
  gap:             6px;
  padding:         9px 18px;
  border-radius:   var(--algm-radius);
  font-size:       0.875rem;
  font-weight:     600;
  font-family:     var(--algm-font);
  cursor:          pointer;
  transition:      all var(--algm-transition);
  text-decoration: none;
  border:          none;
}

.algm-bv-btn--primary {
  background: var(--algm-or);
  color:      var(--algm-bleu);
}
.algm-bv-btn--primary:hover {
  background: #d4a52e;
  color:      var(--algm-bleu);
}

.algm-bv-btn--outline {
  background:  transparent;
  color:       var(--algm-bleu);
  border:      2px solid var(--algm-bleu);
}
.algm-bv-btn--outline:hover {
  background: var(--algm-bleu);
  color:      var(--algm-blanc);
}

.algm-bv-btn--danger {
  background: var(--algm-erreur);
  color:      var(--algm-blanc);
}

.algm-bv-btn:disabled {
  opacity: 0.5;
  cursor:  not-allowed;
}

.algm-bv-btn--sm {
  padding:   5px 12px;
  font-size: 0.8rem;
}

/* ── Tableaux ───────────────────────────────────────────────────────────────── */
.algm-bv-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       0.875rem;
}

.algm-bv-table th {
  background: var(--algm-bleu);
  color:      var(--algm-blanc);
  padding:    10px 14px;
  text-align: left;
  font-weight: 600;
}

.algm-bv-table td {
  padding:       9px 14px;
  border-bottom: 1px solid var(--algm-gris-bord);
  vertical-align: middle;
}

.algm-bv-table tr:nth-child(even) td {
  background: var(--algm-gris);
}

.algm-bv-table tr:hover td {
  background: #eef0f8;
}

/* ── Badges de statut ────────────────────────────────────────────────────────── */
.algm-bv-badge {
  display:       inline-block;
  padding:       2px 10px;
  border-radius: 20px;
  font-size:     0.75rem;
  font-weight:   600;
}

.algm-bv-badge--actif     { background: #d4edda; color: #155724; }
.algm-bv-badge--inactif   { background: #f8d7da; color: #721c24; }
.algm-bv-badge--nouveau   { background: #cce5ff; color: #004085; }
.algm-bv-badge--confirme  { background: #fff3cd; color: #856404; }
.algm-bv-badge--expert    { background: #d6d8f7; color: #202346; }
.algm-bv-badge--legende   { background: #ffeaa7; color: #6c4a00; }

/* ── Formulaires ────────────────────────────────────────────────────────────── */
.algm-bv-form-group {
  margin-bottom: 16px;
}

.algm-bv-form-group label {
  display:       block;
  font-size:     0.875rem;
  font-weight:   600;
  color:         var(--algm-bleu);
  margin-bottom: 5px;
}

.algm-bv-form-group input,
.algm-bv-form-group select,
.algm-bv-form-group textarea {
  width:         100%;
  padding:       9px 12px;
  border:        1px solid var(--algm-gris-bord);
  border-radius: var(--algm-radius);
  font-size:     0.875rem;
  font-family:   var(--algm-font);
  box-sizing:    border-box;
  transition:    border-color var(--algm-transition);
}

.algm-bv-form-group input:focus,
.algm-bv-form-group select:focus,
.algm-bv-form-group textarea:focus {
  outline:       none;
  border-color:  var(--algm-bleu);
  box-shadow:    0 0 0 3px rgba(32, 35, 70, 0.12);
}

/* ── Barre de recherche & filtres ───────────────────────────────────────────── */
.algm-bv-filters {
  display:    flex;
  flex-wrap:  wrap;
  gap:        10px;
  margin-bottom: 20px;
  align-items: center;
}

.algm-bv-search {
  flex:          1;
  min-width:     200px;
  position:      relative;
}

.algm-bv-search input {
  width:          100%;
  padding:        9px 36px 9px 12px;
  border:         1px solid var(--algm-gris-bord);
  border-radius:  var(--algm-radius);
  font-size:      0.875rem;
  box-sizing:     border-box;
}

/* ── Alertes / Notices ────────────────────────────────────────────────────────── */
.algm-bv-notice {
  padding:       12px 16px;
  border-radius: var(--algm-radius);
  font-size:     0.875rem;
  margin-bottom: 16px;
}

.algm-bv-notice--info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }
.algm-bv-notice--success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.algm-bv-notice--warning { background: #fff3cd; color: #856404; border-left: 4px solid #ffc107; }
.algm-bv-notice--danger  { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.algm-bv-pagination {
  display:     flex;
  gap:         4px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}

.algm-bv-pagination__btn {
  padding:       6px 12px;
  border:        1px solid var(--algm-gris-bord);
  border-radius: var(--algm-radius);
  background:    var(--algm-blanc);
  cursor:        pointer;
  font-size:     0.8rem;
  transition:    all var(--algm-transition);
}

.algm-bv-pagination__btn--active {
  background: var(--algm-bleu);
  color:      var(--algm-blanc);
  border-color: var(--algm-bleu);
}

.algm-bv-pagination__btn:hover:not(.algm-bv-pagination__btn--active) {
  background: var(--algm-gris);
}

/* ── Loading ─────────────────────────────────────────────────────────────────── */
.algm-bv-loading {
  display:    flex;
  align-items: center;
  justify-content: center;
  padding:    48px;
  color:      var(--algm-bleu);
  opacity:    0.6;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .algm-bv-content  { padding: 16px; }
  .algm-bv-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .algm-bv-table th:nth-child(n+4),
  .algm-bv-table td:nth-child(n+4) { display: none; }
}

@media (max-width: 480px) {
  .algm-bv-stats-grid { grid-template-columns: 1fr 1fr; }
  .algm-bv-header { flex-direction: column; text-align: center; }
}

/* ─── Auth (login / register) ─────────────────────────────────────────────── */
/* Tokens consommés depuis le thème (theme-algm-block) : --algm-bleu, --algm-or,
   --algm-blanc, --algm-gris-bord, --algm-texte-muted, --algm-erreur, --algm-succes,
   --algm-font-titre, --algm-radius, --algm-radius-lg. */
.algm-auth-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  min-height: 60vh;
}
.algm-auth-card {
  background: var(--algm-blanc);
  border-radius: var(--algm-radius-lg);
  box-shadow: 0 4px 24px rgba(32, 35, 70, 0.12);
  padding: 36px 32px;
  width: 100%;
  max-width: 500px;
  border-top: 4px solid var(--algm-or);
}
.algm-auth-header { text-align: center; margin-bottom: 24px; }
.algm-auth-logo {
  font-family: var(--algm-font-titre);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--algm-bleu);
  letter-spacing: 1px;
}
.algm-auth-subtitle { color: var(--algm-texte-muted); font-size: 13px; margin: 4px 0 0; }
.algm-auth-title {
  font-family: var(--algm-font-titre);
  font-size: 1.1rem;
  color: var(--algm-bleu);
  margin: 0 0 20px;
  text-align: center;
}
.algm-auth-desc { color: var(--algm-texte-muted); font-size: 13px; margin: -12px 0 20px; text-align: center; }
.algm-auth-form { display: flex; flex-direction: column; gap: 14px; }
.algm-auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.algm-auth-field { display: flex; flex-direction: column; gap: 5px; }
.algm-auth-field label { font-size: 12px; font-weight: 600; color: var(--algm-bleu); }
.algm-auth-field input,
.algm-auth-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--algm-gris-bord);
  border-radius: var(--algm-radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
  width: 100%;
}
.algm-auth-field input:focus,
.algm-auth-field textarea:focus { border-color: var(--algm-bleu); }
.algm-auth-field textarea { resize: vertical; }

/* État d'erreur d'un champ : surligne en rouge le champ concerné par
   l'erreur retournée par le handler PHP. Les autres champs gardent leur
   apparence normale et leurs valeurs saisies (cf. Shortcodes::render_register). */
.algm-auth-field--error > input,
.algm-auth-field--error > textarea,
.algm-auth-field--error > select { border-color: var(--algm-erreur) !important; background: #fff7f7; }
.algm-auth-field--error.algm-bv-rgpd-consent,
.algm-auth-field--error.algm-bv-poles-picker > .algm-bv-poles-picker__list { border-color: var(--algm-erreur); background: #fff7f7; }
.algm-auth-field--error > label { color: var(--algm-erreur); }
/* Cas particulier : la photo a un input file caché (display:none),
   on rend l'erreur visible sur le cercle interactif lui-même. */
.algm-auth-field--error.algm-bv-photo-upload .algm-bv-photo-upload__circle { border-color: var(--algm-erreur); background: #fff7f7; }
.algm-auth-remember { font-size: 13px; color: var(--algm-texte-muted); display: flex; align-items: center; gap: 6px; }
.algm-auth-remember input { width: auto; }
.algm-auth-btn {
  background: var(--algm-or);
  color: var(--algm-bleu);
  border: none;
  border-radius: var(--algm-radius);
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--algm-font-titre);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-top: 4px;
}
.algm-auth-btn:hover,
.algm-auth-btn:focus-visible {
  background: var(--algm-bleu);
  color: var(--algm-or);
  outline: none;
}
.algm-auth-notice {
  padding: 12px 14px;
  border-radius: var(--algm-radius);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.algm-auth-notice--error   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--algm-erreur); }
.algm-auth-notice--success { background: #d4edda; color: #155724; border-left: 4px solid var(--algm-succes); }
.algm-auth-link { text-align: center; font-size: 13px; color: var(--algm-texte-muted); margin: 12px 0 0; }
.algm-auth-link a { color: var(--algm-bleu); font-weight: 600; text-decoration: none; }
.algm-auth-link a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .algm-auth-card { padding: 24px 18px; }
  .algm-auth-row  { grid-template-columns: 1fr; }
}
