/* ====================================================
   RIFEN — Espace Membre (membre.rifen.org)
   Design System v1.0
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Sora:wght@600;700;800&display=swap');

/* ── Variables ─────────────────────────────────────── */
:root {
  --sidebar-w:      260px;
  --purple:         #6c2d7a;
  --purple-dark:    #5a2568;
  --purple-light:   #f3eaf6;
  --blue:           #0d6eb7;
  --blue-light:     #e8f4fd;
  --black:          #111827;
  --gray-900:       #1f2937;
  --gray-700:       #374151;
  --gray-500:       #6b7280;
  --gray-300:       #d1d5db;
  --gray-100:       #f3f4f6;
  --gray-50:        #f9fafb;
  --white:          #ffffff;
  --success:        #059669;
  --success-light:  #d1fae5;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #0284c7;
  --info-light:     #e0f2fe;
  --bg:             #f0f4f8;
  --card:           #ffffff;
  --border:         #e5e7eb;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --sidebar-bg:     #0f172a;
  --sidebar-text:   rgba(255,255,255,.55);
  --font-head:      'Sora', system-ui, sans-serif;
  --font-body:      'Inter', system-ui, sans-serif;
  --radius:         8px;
  --radius-sm:      4px;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); font-size: 14px; color: var(--black); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout app ────────────────────────────────────── */
.membre-app { display: flex; flex-direction: column; min-height: 100vh; }
.membre-layout { display: flex; flex: 1; min-height: 100vh; }
.membre-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.membre-content { padding: 24px 28px; flex: 1; }
.membre-content--chat { padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────── */
.m-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.m-sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); text-decoration: none; }
.m-sidebar__brand-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--purple); color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.m-sidebar__wordmark { display: block; font-family: var(--font-head); font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -.3px; }
.m-sidebar__sub { display: block; font-size: 10px; color: var(--sidebar-text); margin-top: 1px; }
.m-sidebar__nav { flex: 1; padding: 12px 10px; }
.m-sidebar__section { display: block; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.3); padding: 14px 10px 6px; }
.m-sidebar__link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 6px;
  color: var(--sidebar-text); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.m-sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.m-sidebar__link.is-active { background: rgba(108,45,122,.35); color: #fff; }
.m-sidebar__icon { width: 16px; height: 16px; flex-shrink: 0; }
.m-sidebar__footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.m-sidebar__user { display: flex; align-items: center; gap: 8px; }
.m-sidebar__avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--purple); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.m-sidebar__user-info { flex: 1; min-width: 0; }
.m-sidebar__username { display: block; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-sidebar__matricule { display: block; font-size: 10px; color: var(--sidebar-text); }
.m-sidebar__logout { color: var(--sidebar-text); display: flex; align-items: center; padding: 4px; border-radius: 4px; transition: color .15s; }
.m-sidebar__logout:hover { color: var(--danger); }

/* ── Topbar ─────────────────────────────────────────── */
.m-topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: var(--white); border-bottom: 1px solid var(--border); min-height: 58px; }
.m-topbar__left { display: flex; flex-direction: column; gap: 2px; }
.m-topbar__title { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--black); letter-spacing: -.3px; }
.m-topbar__breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray-500); }
.m-topbar__breadcrumb a { color: var(--gray-500); }
.m-topbar__breadcrumb a:hover { color: var(--purple); }
.m-topbar__breadcrumb .current { color: var(--gray-700); }
.m-topbar__actions { display: flex; align-items: center; gap: 8px; }

/* ── Auth ───────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #4c1d95 100%); }
.auth-wrapper { width: 100%; max-width: 420px; padding: 0 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand__logo { width: 44px; height: 44px; border-radius: 10px; background: var(--purple); color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; }
.auth-brand__name { font-family: var(--font-head); font-size: 22px; font-weight: 800; color: #fff; }
.auth-brand__sub { font-size: 12px; color: rgba(255,255,255,.5); }
.auth-card { background: var(--white); border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card__title { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: var(--black); margin-bottom: 4px; }
.auth-card__sub { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }
.auth-footer { text-align: center; font-size: 12px; color: rgba(255,255,255,.4); margin-top: 20px; }
.auth-footer a { color: rgba(255,255,255,.5); }

/* ── Cards & panels ─────────────────────────────────── */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel__header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel__title { font-size: 14px; font-weight: 600; color: var(--black); }
.panel__body { padding: 20px; }
.panel__body--flush { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-card__num { font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--black); }
.stat-card__label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.stat-card__icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat-card__icon--purple { background: var(--purple-light); color: var(--purple); }
.stat-card__icon--green  { background: var(--success-light); color: var(--success); }
.stat-card__icon--blue   { background: var(--blue-light);    color: var(--blue); }
.stat-card__icon--orange { background: var(--warning-light); color: var(--warning); }

/* ── Formulaires ────────────────────────────────────── */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.form-card__title { font-size: 13px; font-weight: 600; color: var(--gray-700); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field__label { font-size: 12px; font-weight: 500; color: var(--gray-700); }
.field__label .req { color: var(--danger); }
.field__input, .field__select, .field__textarea {
  padding: 9px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font-body); color: var(--black);
  background: var(--white); outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus, .field__select:focus, .field__textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(108,45,122,.12); }
.field__textarea { resize: vertical; min-height: 90px; }
.field__hint { font-size: 11px; color: var(--gray-500); }

/* ── Boutons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s, opacity .15s; text-decoration: none; }
.btn:hover { text-decoration: none; opacity: .9; }
.btn--primary { background: var(--purple); color: var(--white); }
.btn--primary:hover { background: var(--purple-dark); opacity: 1; }
.btn--success { background: var(--success); color: var(--white); }
.btn--ghost { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn--ghost:hover { background: var(--gray-50); }
.btn--danger { background: var(--danger); color: var(--white); }
.btn--full { width: 100%; justify-content: center; }
.btn--lg { padding: 12px 28px; font-size: 15px; }

/* ── Badges statuts ─────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge--actif     { background: var(--success-light); color: var(--success); }
.badge--suspendu  { background: var(--warning-light); color: var(--warning); }
.badge--expire    { background: var(--danger-light);  color: var(--danger); }
.badge--desactive { background: var(--gray-100);      color: var(--gray-500); }
.badge--attente   { background: var(--blue-light);    color: var(--blue); }
.badge--verifie   { background: var(--success-light); color: var(--success); }

/* ── Alertes ─────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert--success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert--error   { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }
.alert--warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert--info    { background: var(--info-light);    color: #075985; border: 1px solid #bae6fd; }

/* ── Table ───────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--gray-50); padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--gray-700); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--gray-50); }

/* ══════════════════════════════════════════════════════
   Carte membre — recto / verso  (format carte de crédit)
   ══════════════════════════════════════════════════════ */

/* Constantes carte (ratio CR80 = 85.6 × 54 mm → ×4 ≈ 342 × 216px) */
:root {
  --card-w: 342px;
  --card-h: 216px;
  --card-r: 16px;
}

/* ── Coque flip ─────────────────────────────────────── */
.carte-membre-scene {
  perspective: 1200px;
  width: var(--card-w);
  display: block;
}
.carte-membre-flipper {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.4,0,.2,1);
}
.carte-membre-scene.is-flipped .carte-membre-flipper {
  transform: rotateY(180deg);
}
.carte-membre--recto,
.carte-membre--verso {
  position: absolute;
  inset: 0;
  width: var(--card-w);
  height: var(--card-h);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--card-r);
  overflow: hidden;
  color: #fff;
  box-sizing: border-box;
}
.carte-membre--verso {
  transform: rotateY(180deg);
}

/* ── Arrière-plan recto ──────────────────────────────── */
.carte-membre--recto {
  background:
    linear-gradient(135deg, #0a0a1a 0%, #2d1060 45%, #6c2d7a 100%);
  box-shadow: 0 20px 60px rgba(108,45,122,.5), 0 4px 12px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
}
/* Décorations recto */
.carte-membre--recto::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 70%);
  pointer-events: none;
}
.carte-membre--recto::after {
  content: '';
  position: absolute;
  bottom: -40px; left: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160,90,200,.18) 0%, transparent 70%);
  pointer-events: none;
}
/* Bande dorée en bas */
.carte-membre__stripe {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #c9a227 0%, #f0d060 40%, #c9a227 100%);
  border-radius: 0 0 var(--card-r) var(--card-r);
}

/* ── Header recto ────────────────────────────────────── */
.carte-membre__recto-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px 0;
  gap: 8px;
}
.carte-membre__brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.carte-membre__logo {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.carte-membre__tagline {
  font-size: 7px;
  font-weight: 500;
  opacity: 0.70;
  line-height: 1.4;
  max-width: 200px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
/* QR recto (remplace le chip) */
.carte-membre__qr-wrap {
  flex-shrink: 0;
  background: #fff;
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  line-height: 0;
}

/* ── Corps recto ─────────────────────────────────────── */
.carte-membre__recto-body {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  flex: 1;
}
.carte-membre__photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid rgba(255,255,255,.45);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  flex-shrink: 0;
}
.carte-membre__photo--initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  background: rgba(255,255,255,.13);
  backdrop-filter: blur(4px);
}
.carte-membre__recto-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.carte-membre__nom {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
  letter-spacing: .01em;
}
.carte-membre__type {
  font-size: 8.5px;
  font-weight: 600;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #e8c942;
}
.carte-membre__statut-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.14);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
  align-self: flex-start;
}
.carte-membre__statut-pill::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 5px #4ade80;
  flex-shrink: 0;
}

/* ── Pied recto ──────────────────────────────────────── */
.carte-membre__recto-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px 14px;
}
.carte-membre__matricule-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.carte-membre__lbl {
  font-size: 7.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: 0.6;
}
.carte-membre__matricule {
  font-size: 12px;
  font-family: ui-monospace, 'Courier New', monospace;
  letter-spacing: .14em;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.carte-membre__recto-foot-hint {
  font-size: 8px;
  opacity: 0.4;
  letter-spacing: .05em;
}

/* ── Arrière-plan verso ──────────────────────────────── */
.carte-membre--verso {
  background:
    linear-gradient(160deg, #1a0a2e 0%, #2d1060 40%, #0f0a20 100%);
  box-shadow: 0 20px 60px rgba(108,45,122,.5), 0 4px 12px rgba(0,0,0,.4);
  padding: 0;
}
/* Bande noire en haut (comme une vraie carte) */
.carte-membre__magstrip {
  position: absolute;
  top: 18px; left: 0; right: 0;
  height: 36px;
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 100%);
  z-index: 1;
}

/* ── Contenu verso ───────────────────────────────────── */
.carte-membre__verso-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 60px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.carte-membre__verso-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.carte-membre__kv {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.carte-membre__kv span {
  font-size: 7.5px;
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.carte-membre__kv strong {
  font-size: 10px;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.3;
}
.carte-membre__verso-foot {
  font-size: 7.5px;
  opacity: 0.4;
  text-align: center;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.08);
}
/* Bande dorée verso */
.carte-membre__verso-stripe {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #c9a227 0%, #f0d060 40%, #c9a227 100%);
  border-radius: 0 0 var(--card-r) var(--card-r);
}

/* ── Bouton flip ─────────────────────────────────────── */
.carte-membre-flip-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-light);
  border: 1.5px solid rgba(108,45,122,.2);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  width: fit-content;
  margin-top: 12px;
}
.carte-membre-flip-btn:hover { background: #ecd9f5; transform: scale(1.02); }

/* ── Labels recto/verso (hors impression) ───────────── */
.carte-membre-face-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gray-500);
  margin-bottom: 6px;
}

/* ── Wrapper global de la page carte ─────────────────── */
.carte-page-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: start;
}
.carte-page-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
/* Panneau QR amélioré */
.carte-qr-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, var(--purple-light) 0%, #ede9fe 100%);
  border: 1px solid rgba(108,45,122,.15);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.carte-qr-box__url {
  flex: 1;
  min-width: 0;
}
.carte-qr-box__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.carte-qr-box__link {
  font-size: 11px;
  word-break: break-all;
  color: var(--purple);
  font-weight: 500;
}
/* Tableau détails */
.carte-details-table {
  width: 100%;
  border-collapse: collapse;
}
.carte-details-table tr:last-child td { border-bottom: none; }
.carte-details-table td {
  padding: 9px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.carte-details-table td:first-child {
  color: var(--gray-500);
  width: 40%;
  font-size: 12px;
}
.carte-details-table td:last-child {
  font-weight: 600;
  color: var(--black);
  text-align: right;
}

/* ── Page publique vérification ─────────────────────── */
.verify-card { background: var(--white); border-radius: 16px; padding: 40px; max-width: 440px; margin: 60px auto; box-shadow: var(--shadow-md); text-align: center; border: 1px solid var(--border); }
.verify-card__badge { display: inline-flex; align-items: center; gap: 6px; background: var(--success-light); color: var(--success); padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; margin-bottom: 20px; }
.verify-card__avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin: 0 auto 16px; display: block; border: 3px solid var(--purple-light); }
.verify-card__name { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--black); }
.verify-card__matricule { font-size: 13px; color: var(--gray-500); font-family: monospace; margin-top: 4px; }

/* ── Misc ───────────────────────────────────────────── */
.section-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: var(--black); margin-bottom: 12px; letter-spacing: -.2px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-500); }
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .m-sidebar { display: none; }
  .membre-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════════
   Chat — Groupes de travail  (style WhatsApp / Telegram)
   ══════════════════════════════════════════════════════ */

/* ── Variables chat ─────────────────────────────────── */
:root {
  --chat-bg:           #efeae2;   /* fond wallpaper WhatsApp */
  --chat-mine-bg:      #d9fdd3;   /* bulle moi */
  --chat-mine-text:    #111b21;
  --chat-other-bg:     #ffffff;
  --chat-other-text:   #111b21;
  --chat-header-bg:    #f0f2f5;
  --chat-composer-bg:  #f0f2f5;
  --chat-input-bg:     #ffffff;
  --chat-time-color:   #667781;
  --chat-sep-bg:       #e1ddd8;
  --chat-sep-text:     #54656f;
  --chat-sidebar-bg:   #ffffff;
  --chat-sidebar-hover:#f5f6f6;
  --chat-sidebar-active:#f0f2f5;
  --chat-green:        #00a884;
  --chat-radius-l:     16px;
  --chat-radius-s:     4px;
}

/* ── Shell : pleine hauteur dans membre-content--chat ── */
.chat-app {
  display: flex;
  height: calc(100vh - 58px);   /* 58px = topbar */
  overflow: hidden;
  background: var(--chat-sidebar-bg);
}
.membre-content--chat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ══════════════════════════════════════════════════════
   PANNEAU GAUCHE — liste des groupes
   ══════════════════════════════════════════════════════ */
.chat-panel {
  width: 340px;
  min-width: 280px;
  max-width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--chat-sidebar-bg);
}

/* En-tête panneau gauche */
.chat-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--chat-header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel__title {
  font-family: var(--font-head); font-size: 18px; font-weight: 700;
  color: var(--black);
}
.chat-panel__badge {
  background: var(--chat-green); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}

/* Barre de recherche panneau gauche */
.chat-panel__search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--chat-sidebar-bg);
  flex-shrink: 0;
}
.chat-panel__search-input {
  width: 100%; padding: 7px 14px 7px 36px;
  border-radius: 8px; border: none;
  background: #f0f2f5; font-size: 13px;
  outline: none; color: var(--black);
}
.chat-panel__search-wrap {
  position: relative;
}
.chat-panel__search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-500); pointer-events: none;
}

/* Liste des items */
.chat-panel__list {
  flex: 1; overflow-y: auto;
}

/* Item groupe dans la liste */
.chat-group-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background .12s;
  text-decoration: none;
  color: inherit;
}
.chat-group-item:hover { background: var(--chat-sidebar-hover); text-decoration: none; }
.chat-group-item.is-active { background: var(--chat-sidebar-active); }
.chat-group-item__avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-group-item__body { flex: 1; min-width: 0; }
.chat-group-item__name {
  font-weight: 600; font-size: 14px; color: var(--black);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-group-item__desc {
  font-size: 12px; color: var(--gray-500); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-group-item__meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.chat-group-item__count {
  font-size: 10px; color: var(--gray-500);
  display: flex; align-items: center; gap: 3px;
}

/* État vide */
.chat-panel__empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 12px; padding: 32px 20px;
  color: var(--gray-500); font-size: 13px; text-align: center;
}
.chat-panel__empty svg { opacity: .35; }

/* ══════════════════════════════════════════════════════
   ZONE CENTRALE — "Choisir un groupe" (quand rien sélectionné)
   ══════════════════════════════════════════════════════ */
.chat-welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--gray-500); background: var(--chat-bg);
  text-align: center; padding: 40px 20px;
}
.chat-welcome__icon {
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(108,45,122,.08);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.chat-welcome__title { font-family: var(--font-head); font-size: 19px; font-weight: 700; color: var(--black); }
.chat-welcome__sub { font-size: 13px; max-width: 320px; }

/* ══════════════════════════════════════════════════════
   ZONE DROITE — Chat actif
   ══════════════════════════════════════════════════════ */
.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-bg);
  min-width: 0;
}

/* ── En-tête (zone droite) ───────────────────────────── */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--chat-header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 10px;
}
.chat-header__info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.chat-header__avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-header__name { font-weight: 600; font-size: 15px; color: var(--black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header__desc { font-size: 12px; color: var(--chat-time-color); margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.chat-header__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.chat-header__meta { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--chat-time-color); }

/* ── Fil de messages ─────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px 5% 8px;
  display: flex; flex-direction: column; gap: 2px;
  scroll-behavior: smooth;
  background-color: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='40' cy='40' r='18' fill='none' stroke='%23c8bfb3' stroke-width='.4'/%3E%3Ccircle cx='40' cy='40' r='8' fill='none' stroke='%23c8bfb3' stroke-width='.4'/%3E%3C/svg%3E");
  background-size: 80px 80px;
}

/* ── Séparateur de jour (pill centré style WhatsApp) ─── */
.chat-day-sep {
  display: flex; align-items: center; justify-content: center;
  margin: 14px 0 10px; pointer-events: none;
}
.chat-day-sep span {
  background: rgba(225,221,216,.92); color: var(--chat-sep-text);
  font-size: 11.5px; font-weight: 500;
  padding: 4px 12px; border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08); backdrop-filter: blur(4px);
}

/* ── Message ─────────────────────────────────────────── */
.chat-msg {
  display: flex; align-items: flex-end; gap: 6px;
  max-width: 68%; position: relative; margin-bottom: 2px;
}
.chat-msg--mine  { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg--other { align-self: flex-start; }
.chat-msg--first-of-group { margin-top: 8px; }

.chat-msg__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: flex-end;
}
.chat-msg:not(.chat-msg--first-of-group).chat-msg--other .chat-msg__avatar { visibility: hidden; }

.chat-msg__body { display: flex; flex-direction: column; gap: 1px; max-width: 100%; }
.chat-msg--mine  .chat-msg__body { align-items: flex-end; }
.chat-msg--other .chat-msg__body { align-items: flex-start; }

.chat-msg__author { font-size: 12px; font-weight: 600; color: var(--purple); padding: 0 4px; margin-bottom: 2px; }

/* ── Bulle ────────────────────────────────────────────── */
.chat-msg__bubble {
  padding: 7px 12px 20px;
  border-radius: var(--chat-radius-l);
  font-size: 13.5px; line-height: 1.45;
  word-break: break-word; position: relative;
  max-width: 100%; min-width: 72px;
  box-shadow: 0 1px 2px rgba(0,0,0,.10);
}
.chat-msg--other .chat-msg__bubble {
  background: var(--chat-other-bg); color: var(--chat-other-text);
  border-bottom-left-radius: var(--chat-radius-s);
}
.chat-msg--first-of-group.chat-msg--other .chat-msg__bubble::before {
  content: '';
  position: absolute; bottom: 0; left: -7px;
  border: 7px solid transparent;
  border-right-color: var(--chat-other-bg);
  border-bottom-color: var(--chat-other-bg);
}
.chat-msg--mine .chat-msg__bubble {
  background: var(--chat-mine-bg); color: var(--chat-mine-text);
  border-bottom-right-radius: var(--chat-radius-s);
}
.chat-msg--first-of-group.chat-msg--mine .chat-msg__bubble::after {
  content: '';
  position: absolute; bottom: 0; right: -7px;
  border: 7px solid transparent;
  border-left-color: var(--chat-mine-bg);
  border-bottom-color: var(--chat-mine-bg);
}

/* Horodatage intégré bas-droite dans la bulle */
.chat-msg__time {
  position: absolute; bottom: 4px; right: 8px;
  font-size: 10.5px; color: var(--chat-time-color);
  white-space: nowrap; line-height: 1; pointer-events: none;
}

/* ── Bulle fichier ───────────────────────────────────── */
.chat-msg__bubble--file { padding: 0; background: transparent; box-shadow: none; }
.chat-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 24px;
  border-radius: var(--chat-radius-l);
  background: var(--chat-other-bg);
  min-width: 230px; max-width: 310px;
  box-shadow: 0 1px 2px rgba(0,0,0,.10);
  position: relative;
}
.chat-msg--mine .chat-file { background: var(--chat-mine-bg); }
.chat-file__icon { font-size: 26px; flex-shrink: 0; }
.chat-file__info { flex: 1; min-width: 0; }
.chat-file__name { font-size: 13px; font-weight: 600; color: var(--black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file__size { font-size: 11px; color: var(--chat-time-color); margin-top: 2px; }
.chat-file__dl {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--chat-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s; text-decoration: none;
}
.chat-file__dl:hover { background: #008c6e; transform: scale(1.08); text-decoration: none; }

/* ── Message supprimé ─────────────────────────────────── */
.chat-msg__bubble--deleted {
  background: rgba(0,0,0,.04) !important; color: var(--chat-time-color) !important;
  font-style: italic; padding-bottom: 8px; box-shadow: none !important;
}
.chat-msg__bubble--deleted::before, .chat-msg__bubble--deleted::after { display: none !important; }

/* ── Empty state ─────────────────────────────────────── */
.chat-empty {
  align-self: center; margin: auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; color: var(--chat-sep-text); font-size: 13px; text-align: center; padding: 20px;
}
.chat-empty span {
  background: rgba(225,221,216,.92); padding: 6px 16px;
  border-radius: 8px; font-size: 12px; color: var(--chat-sep-text);
}

/* ── Composer ────────────────────────────────────────── */
.chat-composer {
  background: var(--chat-composer-bg);
  padding: 8px 12px 10px; flex-shrink: 0;
  border-top: 1px solid rgba(0,0,0,.06);
}
.chat-composer__row { display: flex; align-items: flex-end; gap: 8px; }

.chat-composer__attach {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); cursor: pointer; background: transparent;
  transition: background .15s, color .15s;
}
.chat-composer__attach:hover { background: rgba(0,0,0,.06); color: var(--purple); }

.chat-composer__input {
  flex: 1; resize: none; border: none; border-radius: 22px;
  padding: 10px 18px; font-size: 14px; font-family: var(--font-body);
  color: var(--black); background: var(--chat-input-bg);
  outline: none; line-height: 1.45; overflow-y: auto; max-height: 160px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: box-shadow .15s;
}
.chat-composer__input:focus { box-shadow: 0 1px 5px rgba(108,45,122,.18); }
.chat-composer__input::placeholder { color: var(--gray-500); }

.chat-composer__send {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  background: var(--chat-green); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, transform .1s;
  box-shadow: 0 2px 6px rgba(0,168,132,.3);
}
.chat-composer__send:hover { background: #008c6e; transform: scale(1.06); }
.chat-composer__send:disabled { background: var(--gray-300); box-shadow: none; }

.chat-composer__hint { font-size: 10px; color: var(--gray-500); margin-top: 5px; text-align: center; }

/* ── Pièces jointes (chips pré-envoi) ─────────────────── */
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 8px; }
.chat-att-chip {
  display: flex; align-items: center; gap: 5px;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 12px; padding: 5px 10px 5px 8px;
  font-size: 12px; color: var(--black); max-width: 230px; box-shadow: var(--shadow-sm);
}
.chat-att-chip__icon { font-size: 16px; flex-shrink: 0; }
.chat-att-chip__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; max-width: 120px; }
.chat-att-chip__size { color: var(--gray-500); font-size: 10.5px; flex-shrink: 0; }
.chat-att-chip__rm { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 13px; padding: 0 2px; line-height: 1; transition: color .15s; margin-left: 2px; }
.chat-att-chip__rm:hover { color: var(--danger); }

/* ── Barre progression upload ─────────────────────────── */
.chat-progress { display: flex; align-items: center; gap: 10px; padding: 6px 4px 8px; }
.chat-progress__bar { flex: 1; height: 3px; border-radius: 99px; background: var(--chat-green); transition: width .2s ease; width: 0%; }
.chat-progress__label { font-size: 11px; color: var(--chat-sep-text); white-space: nowrap; }

/* ── Messages pending ─────────────────────────────────── */
.chat-msg--pending { opacity: .55; transition: opacity .3s; }

/* ── Mode sélection multi ─────────────────────────────── */
.chat-messages--select .chat-msg { cursor: pointer; user-select: none; }
.chat-msg { position: relative; }
.chat-msg__check {
  display: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.18); background: #fff; color: #fff;
  font-size: 12px; font-weight: 900;
  position: absolute; bottom: 6px; right: -30px;
  box-shadow: var(--shadow-sm); align-items: center; justify-content: center;
}
.chat-msg--mine .chat-msg__check { right: auto; left: -30px; }
.chat-messages--select .chat-msg__check { display: inline-flex; }
.chat-msg--selected .chat-msg__check { background: var(--chat-green); border-color: var(--chat-green); }
.chat-msg--selected .chat-msg__bubble { filter: brightness(.96); }

/* Barre de sélection header */
.chat-selectbar { align-items: center; gap: 8px; background: var(--purple-light); padding: 4px 10px 4px 14px; border-radius: 20px; }
.chat-selectbar__count { font-weight: 700; font-size: 13px; color: var(--purple); }

/* ── Statut connexion ─────────────────────────────────── */
.chat-status { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--chat-time-color); }
.chat-status__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: background .4s; }
.chat-status__dot--ok  { background: var(--chat-green); }
.chat-status__dot--off { background: var(--warning); }

/* ── Toast ─────────────────────────────────────────────── */
.chat-toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #333; color: #fff; padding: 10px 22px; border-radius: 24px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 9999; white-space: nowrap; max-width: 90vw;
}
.chat-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.chat-toast--error   { background: var(--danger); }
.chat-toast--success { background: var(--chat-green); }

/* ── Drag & drop ─────────────────────────────────────── */
.chat-messages--dragover { outline: 2px dashed var(--chat-green); outline-offset: -4px; background-color: #e5f9f4; }

/* ── Responsive ──────────────────────────────────────── */
@media (min-width: 601px) and (max-width: 860px) {
  .chat-panel { width: 72px; min-width: 72px; }
  .chat-panel__title, .chat-panel__search, .chat-group-item__body,
  .chat-group-item__meta, .chat-panel__badge { display: none; }
  .chat-group-item { justify-content: center; padding: 10px 0; }
  .chat-group-item__avatar { width: 44px; height: 44px; font-size: 17px; }
  .chat-panel__head { justify-content: center; padding: 12px 0; }
}
@media (max-width: 600px) {
  /* Drawer mobile : la liste des groupes devient un panneau coulissant */
  .chat-panel {
    position: fixed;
    top: 58px; /* sous la topbar */
    left: 0;
    bottom: 0;
    width: min(92vw, 360px);
    max-width: 360px;
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .18s ease;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
    border-right: 1px solid var(--border);
  }
  .chat-app.is-panel-open .chat-panel { transform: translateX(0); }

  .chat-panel-backdrop {
    display: none;
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.22);
    z-index: 40;
  }
  .chat-app.is-panel-open .chat-panel-backdrop { display: block; }

  /* Zone droite en plein écran */
  .chat-wrap { flex: 1; }

  /* Bouton “Groupes” dans l’en-tête du chat */
  .chat-mob-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(0,0,0,.06);
    border: 1px solid rgba(0,0,0,.08);
    font-size: 12px;
    color: var(--black);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
  }
  .chat-mob-btn:hover { background: rgba(0,0,0,.09); text-decoration: none; }

  .chat-msg { max-width: 88%; }
  .chat-file { min-width: 0; max-width: 260px; }
}
