/* Espace Alliance Française — thème bleu AF (#0055A4) sur fond clair Evotic. */
:root {
  /* Charte officielle Alliance Française : ROUGE PANTONE 186 C (#DA002E) + GRIS Cool Gray 8 C (#8C8D8F).
     La variable garde le nom --af-blue (valeur rouge) pour ne pas renommer tout le CSS ; elle est
     de toute façon surchargée à l'exécution par space.primary_color. */
  --af-blue: #DA002E;
  --af-blue-d: #A80022;
  --af-red: #DA002E;
  --af-gray: #8C8D8F;
  --af-ink: #1a1a2e;
  --af-muted: #5b6472;
  --af-card: #ffffff;
  --af-bg: #f4f6fb;
  --af-line: #e6e9f2;
}
* { box-sizing: border-box; }
.af-body {
  margin: 0; background: var(--af-bg); color: var(--af-ink);
  font-family: Nunito, system-ui, sans-serif; -webkit-tap-highlight-color: transparent;
}
.af-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--af-blue); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
}
.af-header .af-back { color: #fff; font-size: 20px; text-decoration: none; opacity: .95; }
.af-header .af-h-title { font-weight: 800; font-size: 17px; line-height: 1.1; }
.af-header .af-h-title small { display: block; font-weight: 600; font-size: 11px; opacity: .8; }
.af-header .af-h-logo { width: 34px; height: 34px; border-radius: 8px; background: #fff; object-fit: contain; padding: 3px; }

.af-hero {
  background: linear-gradient(135deg, var(--af-blue), var(--af-blue-d));
  color: #fff; padding: 20px 16px 26px;
}
.af-hero h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.af-hero .af-city { font-size: 13px; opacity: .85; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.af-hero p { margin: 12px 0 0; font-size: 14px; line-height: 1.5; opacity: .95; }
.af-hero .af-contact { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.af-hero .af-contact a {
  color: #fff; text-decoration: none; font-size: 12.5px; font-weight: 700;
  background: rgba(255,255,255,.16); padding: 7px 11px; border-radius: 999px;
}

.af-wrap { padding: 14px 14px 40px; max-width: 720px; margin: 0 auto; }
.af-section-title { font-size: 15px; font-weight: 800; margin: 22px 4px 10px; color: var(--af-ink); display: flex; align-items: center; gap: 8px; }
.af-section-title i { color: var(--af-blue); }

/* ── Carte d'adhérent ─────────────────────────────────────────────────────── */
.af-card {
  border-radius: 16px; overflow: hidden; color: #fff;
  background: linear-gradient(135deg, var(--af-blue), var(--af-blue-d));
  box-shadow: 0 8px 24px rgba(0,60,120,.25);
}
.af-card-top { padding: 16px 16px 8px; display: flex; justify-content: space-between; align-items: flex-start; }
.af-card-top .af-card-org { font-weight: 800; font-size: 14px; }
.af-card-top .af-card-org small { display: block; font-weight: 600; font-size: 11px; opacity: .8; }
.af-badge-verified { background: #16a34a; color: #fff; font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.af-badge-pending { background: #d97706; }
.af-badge-expired { background: #6b7280; }
.af-card-body { padding: 4px 16px 16px; display: flex; gap: 14px; align-items: center; }
.af-card-info { flex: 1; min-width: 0; }
.af-card-name { font-size: 18px; font-weight: 800; }
.af-card-no { font-size: 13px; opacity: .9; margin-top: 2px; }
.af-card-meta { font-size: 11.5px; opacity: .75; margin-top: 6px; }
.af-qr { width: 96px; height: 96px; border-radius: 10px; background: #fff; padding: 6px; flex-shrink: 0; }
.af-qr canvas { width: 100%; height: 100%; display: block; }

/* ── Boutons / formulaires ────────────────────────────────────────────────── */
.af-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--af-blue); color: #fff; border: none; border-radius: 12px;
  padding: 13px 18px; font: 800 15px Nunito, sans-serif; cursor: pointer; width: 100%;
}
.af-btn:disabled { opacity: .6; cursor: default; }
.af-btn.ghost { background: transparent; color: var(--af-blue); border: 1.5px solid var(--af-blue); }
.af-btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.af-btn.red { background: var(--af-red); }
.af-input {
  width: 100%; border: 1.5px solid var(--af-line); border-radius: 12px;
  padding: 12px 14px; font: 600 15px Nunito, sans-serif; margin-bottom: 10px; background: #fff;
}
/* ── Barre de recherche adhérents ─────────────────────────────────────────── */
.af-search { position: relative; margin-bottom: 10px; }
.af-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--af-muted); font-size: 14px; pointer-events: none; }
.af-search .af-input { margin-bottom: 0; padding-left: 40px; padding-right: 40px; }
.af-search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--af-muted); font-size: 16px; cursor: pointer; padding: 6px; line-height: 1; }
.af-search-clear:hover { color: var(--af-ink); }
.af-mem-count { font-size: 12.5px; color: var(--af-muted); margin: 0 2px 8px; }

.af-panel { background: var(--af-card); border: 1px solid var(--af-line); border-radius: 14px; padding: 16px; }
.af-note { font-size: 12.5px; color: var(--af-muted); line-height: 1.5; }

/* ── Événements ───────────────────────────────────────────────────────────── */
.af-events { display: flex; flex-direction: column; gap: 12px; }
.af-event { background: var(--af-card); border: 1px solid var(--af-line); border-radius: 14px; overflow: hidden; }
.af-event-cover { height: 120px; background: #dde3ef center/cover no-repeat; }
.af-event-body { padding: 13px 14px; }
.af-event-cat { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--af-blue); }
.af-event-title { font-size: 16px; font-weight: 800; margin: 3px 0 6px; }
.af-event-meta { font-size: 12.5px; color: var(--af-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.af-event-meta i { color: var(--af-blue); margin-right: 4px; }
.af-event-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; }
.af-price { font-weight: 800; font-size: 14px; color: var(--af-ink); }
.af-price.free { color: #16a34a; }
.af-rsvp-count { font-size: 12px; color: var(--af-muted); }

.af-empty { text-align: center; color: var(--af-muted); padding: 30px 12px; }
.af-empty i { font-size: 34px; color: var(--af-line); display: block; margin-bottom: 10px; }
.af-loading { text-align: center; color: var(--af-muted); padding: 24px; }
.af-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1a1a2e; color: #fff; padding: 11px 18px; border-radius: 999px;
  font: 700 13px Nunito, sans-serif; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.af-toast.show { opacity: 1; }

/* ── Gate PIN (back-office staff AF) ──────────────────────────────────────── */
.af-gate {
  position: fixed; inset: 0; z-index: 100; background: linear-gradient(160deg, var(--af-blue), var(--af-blue-d));
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.af-gate-icon { font-size: 44px; margin-bottom: 12px; opacity: .95; }
.af-gate h1 { font-size: 22px; margin: 0 0 6px; }
.af-gate p { font-size: 14px; opacity: .9; max-width: 340px; line-height: 1.5; margin: 0 0 16px; }
.af-pin-input {
  width: 220px; max-width: 80vw; text-align: center; letter-spacing: 8px;
  font: 800 22px Nunito, sans-serif; border: none; border-radius: 12px; padding: 14px; margin-bottom: 12px;
}
.af-gate .af-err { color: #ffd7d0; font-weight: 700; font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.af-gate .af-btn { max-width: 260px; }
.af-gate .af-btn.ghost { color: #fff; border-color: rgba(255,255,255,.6); }

/* ── Back-office tabs / listes ────────────────────────────────────────────── */
.af-tabs { display: flex; gap: 6px; padding: 10px 14px 0; background: var(--af-blue); }
.af-tab { flex: 1; background: transparent; border: none; color: rgba(255,255,255,.7); font: 800 14px Nunito, sans-serif; padding: 10px; border-bottom: 3px solid transparent; cursor: pointer; }
.af-tab.active { color: #fff; border-bottom-color: #fff; }
.af-row { background: #fff; border: 1px solid var(--af-line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.af-row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.af-row-name { font-weight: 800; font-size: 15px; }
.af-row-sub { font-size: 12.5px; color: var(--af-muted); margin-top: 2px; }
.af-chip { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.af-chip.pending { background: #fef3c7; color: #92400e; }
.af-chip.active { background: #dcfce7; color: #166534; }
.af-chip.rejected { background: #fee2e2; color: #991b1b; }
.af-chip.draft { background: #e5e7eb; color: #374151; }
.af-chip.published { background: #dbeafe; color: #1e40af; }
.af-chip.cancelled { background: #fee2e2; color: #991b1b; }
.af-row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.af-fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 56px; height: 56px; border-radius: 50%; background: var(--af-red); color: #fff; border: none; font-size: 22px; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 40; cursor: pointer; }
.af-modal { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.45); display: none; align-items: flex-end; }
.af-modal.open { display: flex; }
.af-sheet { background: #fff; width: 100%; max-width: 620px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px); max-height: 90vh; overflow: auto; }
.af-sheet h2 { margin: 0 0 4px; font-size: 18px; }
.af-sheet .af-close { position: absolute; top: 14px; right: 16px; font-size: 22px; color: var(--af-muted); background: none; border: none; cursor: pointer; }

/* ── Lecteur médiathèque (lecture seule) ──────────────────────────────────── */
.af-reader { position: fixed; inset: 0; z-index: 90; background: #FBF9F4; display: flex; flex-direction: column; }
.af-reader-bar { background: var(--af-blue); color: #fff; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px; }
.af-reader-bar .af-back { color: #fff; font-size: 20px; background: none; border: none; cursor: pointer; }
.af-reader-bar .af-reader-title { font-weight: 800; font-size: 15px; line-height: 1.1; flex: 1; }
.af-reader-bar .af-reader-title small { display: block; font-weight: 600; font-size: 11px; opacity: .8; }
.af-reader-notice { font-size: 11px; color: var(--af-blue); padding: 8px 18px; }
.af-reader-body { flex: 1; overflow: auto; padding: 6px 20px 40px; }
.af-reader-body p { font-size: 16px; line-height: 1.65; color: #2a2a2a; white-space: pre-wrap; margin: 0; }
.af-catalog { display: flex; flex-direction: column; gap: 12px; }
.af-book { background: var(--af-card); border: 1px solid var(--af-line); border-radius: 14px; padding: 14px; }
.af-book-title { font-weight: 800; font-size: 15px; }
.af-book-author { font-size: 12.5px; color: var(--af-muted); }
.af-book-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ── Actions adhérent (icônes, pas de grosse carte) ───────────────────────── */
.af-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.af-action-ic {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: none; border: none; cursor: pointer; text-decoration: none;
  padding: 2px; font-family: inherit; color: var(--af-ink); width: 76px;
}
.af-action-badge {
  width: 56px; height: 56px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  background: var(--af-blue); color: #fff; font-size: 22px;
  box-shadow: 0 4px 12px rgba(218,0,46,.28);
}
.af-action-lbl { font-size: 11.5px; font-weight: 800; text-align: center; line-height: 1.15; }
.af-action-ic:active { transform: scale(.95); }
.af-ic-pending .af-action-badge { background: #d97706; box-shadow: 0 4px 12px rgba(217,119,6,.28); }

/* ── Hub réseau (autres Alliances) ────────────────────────────────────────── */
.af-network { margin: 2px 0 14px; }
.af-network > summary {
  list-style: none; cursor: pointer; font-weight: 800; font-size: 13.5px; color: var(--af-blue);
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--af-card); border: 1px solid var(--af-line); border-radius: 12px;
}
.af-network > summary::-webkit-details-marker { display: none; }
.af-network[open] > summary { border-radius: 12px 12px 0 0; }
.af-network-list { border: 1px solid var(--af-line); border-top: none; border-radius: 0 0 12px 12px; overflow: hidden; }
.af-network-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; text-decoration: none;
  color: var(--af-ink); background: var(--af-card); border-top: 1px solid var(--af-line);
}
.af-network-item:first-child { border-top: none; }
.af-network-item img, .af-network-fallback {
  width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: #fff;
  display: flex; align-items: center; justify-content: center; color: var(--af-blue); font-size: 18px;
  border: 1px solid var(--af-line);
}
.af-network-name { flex: 1; font-weight: 800; font-size: 14px; line-height: 1.15; }
.af-network-name small { display: block; font-weight: 600; font-size: 11.5px; color: var(--af-muted); }
.af-network-go { color: var(--af-muted); font-size: 13px; }

/* ── Carte modale (adhésion / confirmation) ───────────────────────────────── */
.af-modal-card {
  background: #fff; width: 100%; max-width: 620px; margin: 0 auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  max-height: 90vh; overflow: auto; animation: af-sheet-up 200ms cubic-bezier(.22,1,.36,1);
}
@keyframes af-sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.af-modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 17px; margin-bottom: 10px; }
.af-modal-head i { color: var(--af-blue); }
.af-modal-x { background: none; border: none; font-size: 20px; color: var(--af-muted); cursor: pointer; }
.af-confirm { text-align: center; padding: 8px 4px 0; }
.af-confirm-ic { font-size: 46px; color: #16a34a; margin-bottom: 4px; }
.af-confirm-title { font-size: 22px; font-weight: 900; margin-bottom: 6px; }
.af-confirm-org { font-weight: 800; font-size: 15px; color: var(--af-blue); margin: 10px 0 6px; }
.af-confirm-contact { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.af-confirm-line {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  color: var(--af-ink); text-decoration: none; font-weight: 700; font-size: 14px;
}
.af-confirm-line i { color: var(--af-blue); }

/* Deep-link : mise en avant temporaire de l'événement AF ouvert depuis un fil. */
.af-event-focus { outline: 2px solid var(--af-blue); outline-offset: 2px; border-radius: 14px; transition: outline-color .3s; }

/* ── Boutons du header (topbar) : réseau + adhérent ───────────────────────── */
.af-h-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.af-h-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: rgba(255,255,255,0.16); color: #fff; border: none; border-radius: 999px;
  padding: 8px 11px; font-family: inherit; font-size: 14px; font-weight: 800;
}
.af-h-btn:active { transform: scale(.95); }
.af-h-btn-primary { background: #fff; color: var(--af-blue); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.af-h-btn-lbl { font-size: 12.5px; font-weight: 800; white-space: nowrap; }
/* Sur petits écrans, le bouton adhérent garde son libellé ; le réseau reste une icône seule. */
@media (max-width: 360px) { .af-h-btn-lbl { display: none; } }

/* Libellés de champ du formulaire d'adhésion. */
.af-field-lbl { display: block; font-size: 12px; font-weight: 800; color: var(--af-muted); margin: 8px 0 3px; }
.af-field-lbl:first-of-type { margin-top: 2px; }

/* ── Emploi du temps ────────────────────────────────────────────────────────── */
.af-day { margin: 0 4px 14px; }
.af-day-name { font-size: 13px; font-weight: 800; color: var(--af-blue); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.af-slot {
  display: flex; gap: 12px; align-items: stretch;
  background: var(--af-card); border: 1px solid var(--af-line); border-left: 4px solid var(--af-blue);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.af-slot-time { font-weight: 800; font-size: 13px; color: var(--af-ink); min-width: 92px; white-space: nowrap; padding-top: 1px; }
.af-slot-title { font-weight: 700; font-size: 14.5px; color: var(--af-ink); }
.af-slot-level { font-size: 11px; font-weight: 800; color: #fff; background: var(--af-blue); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
.af-slot-room { font-size: 12.5px; color: var(--af-muted); margin-top: 3px; }
.af-slot-room i { color: var(--af-blue); }

/* ── Annonces ciblées ───────────────────────────────────────────────────────── */
.af-announces { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.af-announce {
  background: var(--af-card); border: 1px solid var(--af-line); border-radius: 12px;
  padding: 11px 13px; border-left: 4px solid var(--af-gray);
}
.af-announce-info { border-left-color: var(--af-blue); }
.af-announce-schedule { border-left-color: #E08A00; background: #FFF8EE; }
.af-announce-urgent { border-left-color: #C1121F; background: #FDECEE; }
.af-announce-head { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--af-muted); display: flex; align-items: center; gap: 6px; }
.af-announce-info .af-announce-head { color: var(--af-blue); }
.af-announce-schedule .af-announce-head { color: #B26A00; }
.af-announce-urgent .af-announce-head { color: #C1121F; }
.af-announce-date { margin-left: auto; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--af-muted); }
.af-announce-title { font-weight: 800; font-size: 15px; color: var(--af-ink); margin: 4px 0 2px; }
.af-announce-body { font-size: 13.5px; color: var(--af-ink); line-height: 1.4; white-space: pre-wrap; }

/* ── Pont Arc-en-Ciel (back-office) ─────────────────────────────────────────── */
.af-arc-card { background: var(--af-card); border: 1px solid var(--af-line); border-radius: 12px; padding: 12px 14px; margin: 0 4px 10px; }
.af-arc-card b { font-size: 14px; color: var(--af-ink); }
.af-arc-card .af-note { margin: 3px 0 8px; }
.af-file { display: block; width: 100%; font-family: inherit; font-size: 13px; color: var(--af-muted); }
.af-file::file-selector-button { font-family: inherit; font-weight: 800; font-size: 13px; color: #fff; background: var(--af-blue); border: none; border-radius: 10px; padding: 8px 12px; margin-right: 10px; cursor: pointer; }
.af-arc-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 4px 6px; }

/* ── Upload affiche événement (back-office) ─────────────────────────────────── */
.af-cover-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 120px; border: 2px dashed var(--af-line); border-radius: 12px;
  color: var(--af-blue); font-weight: 800; font-size: 14px; cursor: pointer; background: var(--af-card);
}
.af-cover-prev { position: relative; border-radius: 12px; overflow: hidden; }
.af-cover-prev img { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.af-cover-rm {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 999px;
  border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px;
}
.af-ev-thumb { width: 100%; max-height: 150px; object-fit: cover; border-radius: 10px 10px 0 0; display: block; margin: -14px -14px 10px; width: calc(100% + 28px); }

/* ── Équipe & rôles ─────────────────────────────────────────────────────────── */
.af-cred { background: var(--af-bg); border: 1px solid var(--af-line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.af-cred > div { display: flex; flex-direction: column; }
.af-cred span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--af-muted); }
.af-cred b { font-size: 14px; color: var(--af-ink); word-break: break-all; }
.af-perms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 2px; }
.af-perm { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--af-ink); background: var(--af-card); border: 1px solid var(--af-line); border-radius: 10px; padding: 9px 11px; cursor: pointer; }
.af-perm input { width: 17px; height: 17px; accent-color: var(--af-blue); }
@media (max-width: 380px) { .af-perms { grid-template-columns: 1fr; } }
