/* ==========================================================================
   REDA — Design system commun (site public + espace membres)
   ========================================================================== */
:root {
  --brand: #00AEEF;
  --brand-600: #0096CF;
  --brand-700: #0077A8;
  --brand-50: #E6F7FE;
  --brand-100: #CCEFFC;
  --navy: #0B1220;
  --navy-2: #16213A;

  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #F0F3F8;
  --border: #E3E8F0;
  --text: #0B1220;
  --text-2: #45506A;
  --muted: #7A849B;

  --good: #15803D;   --good-bg: #DCFCE7;
  --warn: #B45309;   --warn-bg: #FEF3C7;
  --bad: #B91C1C;    --bad-bg: #FEE2E2;
  --info: #0369A1;   --info-bg: #E0F2FE;

  --link: #0077A8;
  --pill-active: #0B1220;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, .06);
  --shadow: 0 6px 24px -8px rgba(11, 18, 32, .14);
  --shadow-lg: 0 24px 60px -18px rgba(11, 18, 32, .28);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070C17; --surface: #0F172A; --surface-2: #17213A; --border: #24304A;
    --text: #EEF2FA; --text-2: #B4BDD2; --muted: #8590A8;
    --brand-50: #0B2A3A; --brand-100: #0E3A50; --link: #38C6F5; --pill-active: #0096CF;
    --good: #4ADE80; --good-bg: #0E2E1C; --warn: #FBBF24; --warn-bg: #33270A;
    --bad: #F87171; --bad-bg: #3A1414; --info: #7DD3FC; --info-bg: #0B2A3A;
    --shadow: 0 6px 24px -8px rgba(0, 0, 0, .5); --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070C17; --surface: #0F172A; --surface-2: #17213A; --border: #24304A;
  --text: #EEF2FA; --text-2: #B4BDD2; --muted: #8590A8;
  --brand-50: #0B2A3A; --brand-100: #0E3A50; --link: #38C6F5; --pill-active: #0096CF;
  --good: #4ADE80; --good-bg: #0E2E1C; --warn: #FBBF24; --warn-bg: #33270A;
  --bad: #F87171; --bad-bg: #3A1414; --info: #7DD3FC; --info-bg: #0B2A3A;
  --shadow: 0 6px 24px -8px rgba(0, 0, 0, .5); --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
img, svg, video { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 800; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.2em; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; padding: .62em 1.1em;
  border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: .92rem; cursor: pointer;
  background: var(--surface-2); color: var(--text); transition: background .15s, transform .05s, box-shadow .15s; white-space: nowrap; text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff !important; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn-primary:hover { background: var(--brand-600); }
.btn-dark { background: var(--navy); color: #fff !important; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad-bg); color: var(--bad) !important; }
.btn-danger:hover { filter: brightness(.96); }
.btn-success { background: var(--good-bg); color: var(--good) !important; }
.btn-sm { padding: .4em .75em; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .85em 1.5em; font-size: 1rem; border-radius: 12px; }
.btn-icon { padding: .5em; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: .35em; margin-bottom: 1rem; }
.field > span, .label { font-size: .82rem; font-weight: 700; color: var(--text-2); }
.field small { color: var(--muted); font-size: .78rem; }
.input, .select, .textarea {
  width: 100%; padding: .65em .85em; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.textarea { min-height: 110px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .55em; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Cartes & mise en page ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; align-items: center; gap: .75rem; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: .84rem; }
.xs { font-size: .75rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; border: 0; }

/* ---------- Badges, puces, avatars ---------- */
.badge { display: inline-flex; align-items: center; gap: .35em; padding: .2em .6em; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-brand { background: var(--brand-50); color: var(--link); }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.role-chip { display: inline-flex; align-items: center; gap: .35em; font-size: .72rem; font-weight: 700; padding: .15em .55em; border-radius: 6px; border: 1px solid var(--border); color: var(--text-2); }
.role-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--brand)); }
.avatar { --s: 38px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-weight: 800; font-size: calc(var(--s) * .38); color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-700)); object-fit: cover; overflow: hidden; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { --s: 28px; } .avatar-lg { --s: 64px; } .avatar-xl { --s: 104px; }
.presence { position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; border-radius: 50%; background: #22C55E; border: 2px solid var(--surface); }

/* ---------- Progression ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.progress.lg { height: 12px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: .7rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tab { padding: .7rem 1rem; border: 0; background: none; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: .45em; align-items: center; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--link); border-bottom-color: var(--brand); }
.pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.pill { padding: .4em .9em; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--text-2); }
.pill.active { background: var(--pill-active); color: #fff; border-color: var(--pill-active); }

/* ---------- Modale ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(7, 12, 23, .55); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 1rem; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.4rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.4rem; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Notifications toast ---------- */
.toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: calc(100vw - 2.5rem); }
.toast { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); min-width: 260px; max-width: 400px; animation: slide .25s cubic-bezier(.2, .9, .3, 1.2); font-size: .9rem; }
.toast.error { background: #991B1B; }
.toast.success { background: #166534; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }

/* ---------- États vides & chargement ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .icon { width: 44px; height: 44px; margin: 0 auto 1rem; opacity: .5; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 40%, var(--surface)), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 4rem; }

/* ---------- Contenu Markdown ---------- */
.prose { font-size: 1.02rem; line-height: 1.75; color: var(--text); }
.prose h2 { font-size: 1.45rem; margin-top: 1.8em; }
.prose h3 { font-size: 1.2rem; margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin: .3em 0; }
.prose blockquote { margin: 1.5em 0; padding: .8em 1.2em; border-left: 4px solid var(--brand); background: var(--brand-50); border-radius: 0 10px 10px 0; font-style: italic; }
.prose img { border-radius: 12px; margin: 1.2em 0; }
.prose code { background: var(--surface-2); padding: .1em .4em; border-radius: 5px; font-size: .9em; }
.prose a { text-decoration: underline; }

/* ---------- Statistiques ---------- */
.stat { padding: 1.15rem 1.25rem; }
.stat .label { display: flex; align-items: center; gap: .45em; font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: .35rem; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--link); }
