/* =============================================
   MBA Ponts Alumni Morocco — Feuille de styles principale
   Toutes les couleurs, rayons et ombres viennent de tokens.css
   ============================================= */

/* Alias historiques (anciens templates) — pointent vers les tokens */
:root {
  --mba-bleu: var(--color-primary-700);
  --mba-bleu-clair: var(--color-primary-500);
  --mba-or: var(--color-accent-500);
  --mba-or-clair: var(--color-accent-600);
  --mba-gris: var(--color-bg);
}

/* ─── Layout ────────────────────────────────────────────────────── */
main.container, main.container-fluid { padding-left: var(--gutter); padding-right: var(--gutter); }
@media (min-width: 768px) { :root { --gutter: 24px; } }
@media (min-width: 1200px) { :root { --gutter: 32px; } }
.container { max-width: 1200px; }

.min-width-0 { min-width: 0; }
main, .card, .card-body { overflow-wrap: anywhere; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  --bs-card-border-radius: var(--radius-lg);
  --bs-card-bg: var(--color-surface);
  --bs-card-border-color: var(--color-border);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

@media (hover: hover) {
  .card:hover { transform: translateY(-1px); }
}

/* ─── Profil — jauge de complétion ──────────────────────────────── */
.completion-gauge .progress {
  height: 10px;
  border-radius: var(--radius-sm);
}

.completion-gauge .progress-bar {
  background: linear-gradient(90deg, var(--color-primary-500), var(--color-accent-500));
}

/* ─── Carte de membre numérique ─────────────────────────────────── */
.carte-membre {
  background: linear-gradient(135deg, var(--color-primary-900) 55%, var(--color-primary-500));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.carte-membre .badge-promo {
  background-color: var(--color-accent-500);
  color: var(--color-primary-900);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

/* ─── Annuaire ──────────────────────────────────────────────────── */
.profil-card .avatar {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--color-accent-500);
}

.badge-disponible {
  background-color: var(--color-success-50);
  color: var(--color-success);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

/* ─── Événements ─────────────────────────────────────────────────── */
.event-card .event-date {
  background-color: var(--color-primary-50);
  color: var(--color-primary-700);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
  min-width: 56px;
}

.event-card .event-date .day {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.event-card .event-date .month {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ─── Messagerie ─────────────────────────────────────────────────── */
.chat-bubble {
  max-width: 70%;
  border-radius: 18px;
  padding: 10px 16px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.chat-bubble.sent {
  background-color: var(--color-primary-700);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-bubble.received {
  background-color: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

/* ─── Footer ─────────────────────────────────────────────────────── */


/* ─── PWA offline ───────────────────────────────────────────────── */
.offline-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ─── Accessibilité ──────────────────────────────────────────────── */
.badge.bg-light { color: var(--color-text); }

a.text-dark:hover { color: var(--color-primary-700); }

img[loading="lazy"] { content-visibility: auto; }

/* ─── Mentorat ──────────────────────────────────────────────────── */
.hover-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.hover-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ─── Bottom Navigation Mobile ──────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 16px rgba(11, 37, 69, .08);
  display: flex;
  align-items: stretch;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 2px;
  transition: color 0.15s;
  min-width: 0;
}

.bottom-nav-item i {
  font-size: 1.35rem;
  line-height: 1;
}

.bottom-nav-item.active {
  color: var(--color-primary-700);
  font-weight: 700;
}
[data-bs-theme="dark"] .bottom-nav-item.active { color: var(--color-primary-500); }

.bottom-nav-item:active { opacity: 0.7; }

.bottom-nav-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-align: center;
  background: var(--color-danger);
  color: #fff;
  border-radius: 8px;
  padding: 0 3px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .carte-membre { max-width: 100%; }
  .chat-bubble { max-width: 90%; }
}

@media (max-width: 991.98px) {
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }

  .btn-stack-mobile { flex-direction: column; }
  .btn-stack-mobile .btn { width: 100%; }
}

@media (min-width: 576px) {
  .btn-stack-mobile { flex-direction: row; }
  .btn-stack-mobile .btn { width: auto; }
}

/* ─── Mode sombre ───────────────────────────────────────────────────────────────
   Les couleurs viennent des tokens (tokens.css) et des variables Bootstrap 5.3.
   Restent uniquement les classes utilitaires Bootstrap qui forcent une couleur
   claire avec !important : on les neutralise ici (justifié). */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
  background-color: var(--color-surface) !important; /* utilitaires Bootstrap en !important */
  color: var(--color-text);
}
[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] a.text-dark {
  color: var(--color-text) !important; /* idem */
}
[data-bs-theme="dark"] a.text-dark:hover { color: var(--color-primary-500) !important; }
[data-bs-theme="dark"] .badge.bg-light,
[data-bs-theme="dark"] .badge.bg-secondary {
  background-color: var(--color-surface-2) !important;
  color: var(--color-text) !important;
}

/* ─── En-tête ──────────────────────────────────────────────────── */
.site-header {
  background: var(--nav-bg);
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 1020;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 0 var(--gutter);
  flex-wrap: nowrap;
}
@media (min-width: 992px) { .site-nav { min-height: 64px; gap: var(--space-4); } }
.site-brand { flex-shrink: 0; display: flex; align-items: center; }
.site-brand img { height: 36px; max-width: 150px; object-fit: contain; }

.nav-main {
  list-style: none; margin: 0; padding: 0;
  align-items: center; gap: 2px; flex-wrap: nowrap;
}
.nav-main .nav-link {
  position: relative;
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem .7rem;
  color: var(--nav-fg-muted);
  font-weight: 500; font-size: .9375rem; white-space: nowrap;
}
.nav-main .nav-link:hover { color: var(--nav-fg); }
.nav-main .nav-link.active { color: var(--nav-fg); font-weight: 600; }
.nav-main .nav-link.active::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: -.2rem;
  height: 2px; background: var(--color-accent-500); border-radius: 2px;
}
.nav-main .nav-link i { font-size: 1.05rem; }
@media (max-width: 1199.98px) { .nav-main .nav-link > i:first-child { display: none; } }
.nav-main .nav-link i.nav-lock { font-size: .7rem; opacity: .8; }
.nav-main .dropdown-menu { margin-top: .5rem; }

.site-actions {
  margin-left: auto; display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--nav-fg); text-decoration: none; font-size: 1.25rem;
}
.icon-btn:hover { background: rgba(255,255,255,.12); color: var(--nav-fg); }
.icon-badge {
  position: absolute; top: 4px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: .6875rem; font-weight: 700; line-height: 18px; text-align: center;
  color: #fff; background: var(--color-danger); border-radius: 9px;
}
.avatar-toggle { display: flex; align-items: center; padding: 4px; border-radius: var(--radius-full); }
.avatar-toggle img { border: 2px solid rgba(255,255,255,.85); object-fit: cover; }
.nav-visiteur { color: var(--nav-fg); text-decoration: none; font-weight: 500; padding: .4rem .5rem; }

.subnav {
  display: flex; gap: var(--space-4); overflow-x: auto;
  padding: 0 var(--gutter); background: rgba(0,0,0,.18);
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  color: var(--nav-fg-muted); text-decoration: none; font-weight: 500;
  padding: .65rem 0; white-space: nowrap; border-bottom: 2px solid transparent;
}
.subnav a.active { color: var(--nav-fg); border-bottom-color: var(--color-accent-500); }

/* ─── Lien retour contextuel ───────────────────────────────────── */
.back-link {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--color-text-muted); text-decoration: none; font-weight: 500;
  min-height: 44px;
}
.back-link:hover { color: var(--color-primary-700); }

/* ─── Pied de page ─────────────────────────────────────────────── */
.site-footer {
  background: var(--color-primary-900);
  color: rgba(255,255,255,.78);
  padding: var(--space-6) 0 var(--space-5);
  margin-top: var(--space-7);
}
.site-footer a { color: rgba(255,255,255,.85); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-title { color: #fff; font-weight: 600; margin-bottom: var(--space-2); }
.footer-sep { border-color: rgba(255,255,255,.18); opacity: 1; }
.footer-legal a { margin: 0 var(--space-2); }
@media (max-width: 991.98px) {
  .site-footer { padding-bottom: calc(var(--space-5) + 60px + env(safe-area-inset-bottom, 0px)); margin-bottom: 0; }
  body { padding-bottom: 0; }
}

/* ─── Feuille « Plus » (bottom sheet) ──────────────────────────── */
.sheet-plus {
  --bs-offcanvas-height: auto;
  max-height: 88vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface);
}
.sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--color-border); margin: 8px auto 0;
}
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.sheet-grid a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 76px; padding: var(--space-2);
  border-radius: var(--radius-md); background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text); text-decoration: none; text-align: center;
  font-size: .8125rem; font-weight: 500; line-height: 1.2;
}
.sheet-grid a i:first-child { font-size: 1.4rem; color: var(--color-primary-700); }
[data-bs-theme="dark"] .sheet-grid a i:first-child { color: var(--color-primary-500); }
.sheet-grid a:active { background: var(--color-primary-50); }
.sheet-cta {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  background: var(--color-accent-50); border: 1px solid var(--color-accent-500);
  border-radius: var(--radius-md); color: var(--color-text); text-decoration: none;
}
.sheet-cta > span { flex: 1; display: flex; flex-direction: column; }
.sheet-cta small { color: var(--color-text-muted); }
.sheet-cta > i:first-child { font-size: 1.4rem; color: var(--color-accent-700); }
#offcanvas-plus .btn { min-height: 44px; }

/* #bottom-nav : le bouton « Plus » hérite du style des liens */
button.bottom-nav-item { background: none; border: 0; }

/* ─── Tableaux : en-têtes de colonnes sur une seule ligne ─────────── */
.table > thead > tr > th { white-space: nowrap; font-size: .8125rem; }
.table-responsive { -webkit-overflow-scrolling: touch; }
