:root {
  --es-primary: #174a70;
  --es-primary-dark: #0f324d;
  --es-primary-light: #246a9e;
  --es-accent: #f59e0b;
  --es-accent-hover: #d97706;
  --es-bg: #f8fafc;
  --es-card-bg: #ffffff;
  --es-text-main: #1e293b;
  --es-text-muted: #64748b;
  --es-border: #e2e8f0;
  --es-sidebar-w: 260px;
}

body {
  background: var(--es-bg);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--es-text-main);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.es-sidebar {
  width: var(--es-sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--es-primary-dark) 0%, var(--es-primary) 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 1030;
  box-shadow: 2px 0 10px rgba(0,0,0,.08);
}

.es-sidebar .brand {
  padding: 1.25rem 1.2rem;
  font-weight: 800;
  font-size: 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: .6rem;
  letter-spacing: -0.02em;
}

/* Une raison sociale peut être longue : le logo ne rétrécit jamais et le
   libellé reste contenu dans la colonne sans repousser les éléments de menu. */
.es-sidebar .brand .es-brand-logo { flex: 0 0 34px; }
.es-sidebar .brand .es-brand-name {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* Photo d'identité privée affichée dans le détail d'un dossier candidat. */
.candidate-photo-wrap { position:relative; display:grid; place-items:center; flex:0 0 48px; width:48px; height:48px; overflow:hidden; border:2px solid #d7e5ec; border-radius:50%; color:var(--es-primary); background:#edf5f8; }
.candidate-photo { position:absolute; inset:0; z-index:1; width:100%; height:100%; object-fit:cover; }.candidate-photo-placeholder { font-size:1.35rem; }.candidate-photo-wrap:has(.candidate-photo) .candidate-photo-placeholder { display:none; }.candidate-photo-wrap.photo-unavailable .candidate-photo { display:none; }.candidate-photo-wrap.photo-unavailable .candidate-photo-placeholder { display:block; }
.student-card-photo-image { width:100%; height:100%; object-fit:cover; }

.es-sidebar a.nav-link {
  color: rgba(255,255,255,.8);
  padding: .65rem 1.2rem;
  border-left: 4px solid transparent;
  font-size: .9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: all .15s ease-in-out;
}

.es-sidebar a.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: rgba(245, 158, 11, .5);
}

.es-sidebar a.nav-link.active {
  background: rgba(255,255,255,.14);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--es-accent);
}

.es-sidebar .nav-section {
  text-transform: uppercase;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(255,255,255,.45);
  padding: 1.1rem 1.2rem .35rem;
}

/* Layout */
.es-main {
  margin-left: var(--es-sidebar-w);
  padding: 1.75rem;
  min-height: calc(100vh - 65px);
}

.es-topbar {
  margin-left: var(--es-sidebar-w);
  background: var(--es-card-bg);
  border-bottom: 1px solid var(--es-border);
  padding: .75rem 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.es-topbar-start { min-width: 0; flex: 1 1 auto; }
.es-heading-block { min-width: 0; }
.es-institution-name {
  max-width: clamp(9rem, 22vw, 20rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.es-topbar-actions { flex: 0 0 auto; }

@media (max-width: 1200px) {
  .es-institution-name { max-width: 11rem; }
  .es-topbar { padding-inline: 1rem; }
  .es-topbar-actions { gap: .75rem !important; }
}

.es-app-footer {
  margin-left: var(--es-sidebar-w);
  min-height: 42px;
  padding: .7rem 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem 1rem;
  color: var(--es-text-muted);
  background: var(--es-card-bg);
  border-top: 1px solid var(--es-border);
  font-size: .78rem;
}

/* Cards */
.card {
  border: 1px solid var(--es-border);
  border-radius: .85rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  background: var(--es-card-bg);
}

.stat-card {
  border: 1px solid var(--es-border);
  border-radius: .85rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

/* Badges */
.badge {
  font-weight: 600;
  padding: .35em .65em;
  border-radius: .4rem;
}
.badge-status-ACTIVE, .badge-status-ADMIS, .badge-status-VALIDEE, .badge-status-PRESENT, .badge-status-AVAILABLE {
  background: #10b981 !important; color: #fff;
}
.badge-status-INACTIVE, .badge-status-SUSPENDUE, .badge-status-ABSENT, .badge-status-REFUSEE, .badge-status-LOST {
  background: #ef4444 !important; color: #fff;
}
.badge-status-EN_ATTENTE, .badge-status-RETARD, .badge-status-LOANED {
  background: #f59e0b !important; color: #fff;
}
.badge-status-AJOURNE, .badge-status-NON_VALIDE {
  background: #ea580c !important; color: #fff;
}
.badge-status-ABSENCE_JUSTIFIEE {
  background: #6366f1 !important; color: #fff;
}
.badge-status-GRADUATED, .badge-status-DIPLOME {
  background: #0284c7 !important; color: #fff;
}
/* Module stages — conventions, cartes et rapports de stage */
.badge-status-SIGNEE, .badge-status-EMISE, .badge-status-VALIDE, .badge-status-DEPOSE {
  background: #10b981 !important; color: #fff;
}
.badge-status-EN_COURS, .badge-status-EN_VERIFICATION, .badge-status-SOUTENU {
  background: #0ea5e9 !important; color: #fff;
}
.badge-status-REJETE, .badge-status-PERDUE, .badge-status-EXPIREE {
  background: #ef4444 !important; color: #fff;
}

/* Portail étudiant — statuts des modules eSchoolApp */
.badge-status-SOUMIS, .badge-status-PUBLISHED, .badge-status-COMPLETED, .badge-status-CORRIGE,
.badge-status-ELIGIBLE, .badge-status-READY, .badge-status-COLLECTED, .badge-status-COMPLETED,
.badge-status-RESOLVED, .badge-status-ACCEPTE, .badge-status-CLOSED, .badge-status-SUCCESS,
.badge-status-PAID, .badge-status-OFFERED, .badge-status-GRADUATED, .badge-status-DIPLOME {
  background: #10b981 !important; color: #fff;
}
.badge-status-A_FAIRE, .badge-status-EN_RETARD, .badge-status-A_VENIR, .badge-status-PENDING_ADVISOR,
.badge-status-IN_REVIEW, .badge-status-IN_PROGRESS, .badge-status-REVIEWING, .badge-status-PENDING,
.badge-status-PREPARING, .badge-status-SUBMITTED, .badge-status-WAITLISTED, .badge-status-WAITLIST,
.badge-status-HIGH, .badge-status-MEDIUM, .badge-status-CARTE_JAUNE {
  background: #f59e0b !important; color: #fff;
}
.badge-status-REDOUBLE, .badge-status-EXCLU, .badge-status-CANCELLED, .badge-status-ANNULEE,
.badge-status-EXPIRED, .badge-status-REVOKED, .badge-status-BLOCKED, .badge-status-FAILED,
.badge-status-REJECTED, .badge-status-CARTE_PENALITE, .badge-status-EMERGENCY {
  background: #ef4444 !important; color: #fff;
}
.badge-status-EN_COURS, .badge-status-OPEN, .badge-status-IN_PROGRESS_LMS, .badge-status-NOT_STARTED,
.badge-status-IN_PROGRESS_C, .badge-status-QUESTIONNAIRE, .badge-status-NORMAL {
  background: #0ea5e9 !important; color: #fff;
}

/* Utilitaires de mise en page */
.min-width-0 { min-width: 0; }
.text-break-anywhere { overflow-wrap: anywhere; word-break: break-word; }
.cursor-pointer { cursor: pointer; }

/* Student Digital ID Card */
.student-id-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0,0,0,.25);
  position: relative;
  overflow: hidden;
}

.student-id-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(245,158,11,.35) 0%, rgba(245,158,11,0) 70%);
  border-radius: 50%;
}

.student-card-photo {
  width: 84px;
  height: 84px;
  border-radius: .75rem;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,.3);
  background: #334155;
}

/* Bulletin & Receipt Print Styles */
.official-doc {
  background: #fff;
  color: #000;
  padding: 2.5rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  border: 1px solid #cbd5e1;
  border-radius: .5rem;
}

.official-header {
  border-bottom: 2px solid #0f324d;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

@media print {
  body * { visibility: hidden; }
  .printable-area, .printable-area * { visibility: visible; }
  .printable-area { position: absolute; left: 0; top: 0; width: 100%; padding: 0; margin: 0; }
  .no-print { display: none !important; }
}

@media (max-width: 900px) {
  .es-sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1); }
  .es-sidebar.open { transform: translateX(0); }
  .es-main, .es-topbar, .es-app-footer { margin-left: 0; }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--es-primary-dark) 0%, #1e3a8a 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 20px 45px rgba(0,0,0,.3);
}

.role-badge-btn {
  font-size: .78rem;
  padding: .35rem .65rem;
  border-radius: .5rem;
  transition: all .15s ease;
}

/* ============================================================
   Design tokens complémentaires (espacement, rayon, ombres)
   ============================================================ */
:root {
  --es-radius-sm: .5rem;
  --es-radius:    .85rem;
  --es-radius-lg: 1.25rem;
  --es-shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --es-shadow:    0 4px 14px rgba(0,0,0,.08);
  --es-shadow-lg: 0 12px 32px rgba(0,0,0,.14);
  --es-space:     1rem;
}

/* ============================================================
   Mode sombre — piloté par data-bs-theme="dark" (Bootstrap 5.3).
   On redéfinit les tokens --es-*, puis un « shim » remappe les
   utilitaires Bootstrap les plus utilisés dans les vues afin
   d'éviter d'éditer chaque page (text-dark, bg-white, bg-light…).
   ============================================================ */
[data-bs-theme="dark"] {
  --es-bg:        #0b1220;
  --es-card-bg:   #131f33;
  --es-text-main: #e5edf7;
  --es-text-muted:#93a4bd;
  --es-border:    #243449;
  --es-shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --es-shadow:    0 4px 14px rgba(0,0,0,.45);
}
[data-bs-theme="dark"] body { background: var(--es-bg); color: var(--es-text-main); }

/* Shim : rétro-compatibilité des utilitaires clairs en mode sombre. */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-body { background-color: var(--es-card-bg) !important; }
[data-bs-theme="dark"] .bg-light { background-color: #1a2842 !important; }
[data-bs-theme="dark"] .text-dark { color: var(--es-text-main) !important; }
[data-bs-theme="dark"] .text-muted { color: var(--es-text-muted) !important; }
[data-bs-theme="dark"] .border { border-color: var(--es-border) !important; }
[data-bs-theme="dark"] .card { box-shadow: var(--es-shadow-sm); }
[data-bs-theme="dark"] .bg-primary-subtle { background-color: rgba(36,106,158,.20) !important; }
[data-bs-theme="dark"] .bg-secondary-subtle { background-color: rgba(148,164,189,.16) !important; }
[data-bs-theme="dark"] .bg-success-subtle { background-color: rgba(16,185,129,.16) !important; }

/* Bouton bascule de thème */
.theme-toggle .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }
[data-bs-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }
