:root {
  --brand: #0b3d6b;
  --brand-dark: #082c4d;
  --brand-light: #12558f;
  --accent: #c8a04a;
  --accent-soft: #f0e2c2;
  --bg: #eef2f7;
  --surface: #ffffff;
  --ink: #1f2a37;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(11, 61, 107, .28);
  --shadow-sm: 0 2px 10px -4px rgba(15, 23, 42, .18);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, .navbar-brand {
  font-family: "Poppins", "Inter", system-ui, sans-serif;
  letter-spacing: -.01em;
}

main { flex: 1 0 auto; }

/* ---------- En-tete ---------- */
.app-navbar {
  background: linear-gradient(100deg, var(--brand-dark), var(--brand) 55%, var(--brand-light));
  box-shadow: var(--shadow-sm);
}
.app-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 600;
  color: #fff;
}
.brand-emblem {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--accent), #a97f2a);
  color: #1b2a1a;
  font-size: 1.25rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.brand-emblem i { color: #14243f; }
.brand-logo {
  height: 44px; width: auto; padding: 3px 6px;
  background: #fff; border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}
.lang-switcher .nav-link { cursor: pointer; }
.lang-switcher .dropdown-item.active { background: var(--brand); color: #fff; }
.brand-titles small {
  display: block;
  font-size: .68rem;
  font-weight: 400;
  color: rgba(255,255,255,.72);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.app-navbar .nav-link {
  color: rgba(255,255,255,.85) !important;
  font-weight: 500;
  border-radius: 8px;
  padding: .4rem .75rem !important;
  transition: background .15s ease;
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link.active { background: rgba(255,255,255,.14); color:#fff !important; }
.navbar-user {
  color: #fff; font-size: .85rem; line-height: 1.1;
  padding-left: .9rem; margin-left: .4rem;
  border-left: 1px solid rgba(255,255,255,.25);
}
.navbar-user .role-pill {
  display: inline-block; margin-top: 2px;
  font-size: .68rem; padding: .05rem .5rem; border-radius: 999px;
  background: rgba(255,255,255,.16); color: var(--accent-soft);
}

/* ---------- Cartes & surfaces ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-elevated { box-shadow: var(--shadow); border: none; }
.section-title { font-size: 1.05rem; font-weight: 600; color: var(--brand); margin-bottom: .75rem; }
.page-title { font-weight: 600; color: var(--brand-dark); }
.page-subtitle { color: var(--muted); }

/* ---------- Cartes statistiques ---------- */
.stat-card {
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  color: #fff;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 2.3rem; font-weight: 700; line-height: 1; font-family: "Poppins", sans-serif; }
.stat-card .stat-label { opacity: .9; font-size: .9rem; }
.stat-card .stat-icon {
  position: absolute; right: -6px; bottom: -10px;
  font-size: 4.2rem; opacity: .18;
}
.stat-brand  { background: linear-gradient(135deg, var(--brand), var(--brand-light)); }
.stat-amber  { background: linear-gradient(135deg, #b7791f, #d69e2e); }
.stat-green  { background: linear-gradient(135deg, #1f7a4d, #2f9e68); }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line);
}
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-card .table td { vertical-align: middle; }

/* ---------- Badges de statut ---------- */
.badge { font-weight: 600; padding: .4em .7em; border-radius: 999px; letter-spacing: .01em; }

/* ---------- Boutons ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1b2a1a; }
.btn-accent:hover { background: #b7902f; border-color: #b7902f; color: #1b2a1a; }

/* ---------- Formulaires ---------- */
.form-control, .form-select { border-radius: 10px; border-color: var(--line); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 .2rem rgba(18, 85, 143, .15);
}
.form-label { font-weight: 500; font-size: .9rem; color: #334155; }

/* ---------- Page d'authentification ---------- */
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%; max-width: 940px;
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--surface); border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow);
}
.auth-aside {
  background: linear-gradient(155deg, var(--brand-dark), var(--brand) 60%, var(--brand-light));
  color: #fff; padding: 2.5rem; display: flex; flex-direction: column; justify-content: center;
}
.emblem-lg {
  width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--accent), #a97f2a); color: #14243f; font-size: 1.9rem;
}
.auth-aside .emblem-lg { margin-bottom: 1.2rem; }
.auth-aside h2 { font-size: 1.55rem; margin-bottom: .5rem; }
.auth-aside p { color: rgba(255,255,255,.8); }
.auth-aside .feature { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; font-size: .92rem; color: rgba(255,255,255,.9); }
.auth-aside .feature i { color: var(--accent); margin-top: .15rem; }
.auth-body { padding: 2.5rem; }
@media (max-width: 767px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* ---------- Pied de page ---------- */
.app-footer {
  flex-shrink: 0;
  background: var(--brand-dark); color: rgba(255,255,255,.72);
  font-size: .85rem; padding: 1rem 0; margin-top: 2.5rem;
}

/* ---------- Espace Gestion (back-office avec barre laterale) ---------- */
.gestion-layout { display: flex; min-height: 100vh; align-items: stretch; }
.gestion-sidebar {
  width: 260px; color: #fff;
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
}
@media (min-width: 992px) {
  .gestion-sidebar { position: sticky; top: 0; height: 100vh; }
}
.gestion-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.gestion-topbar {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1.25rem; background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.gestion-content { padding: 1.5rem; flex: 1 0 auto; }
.sidebar-head { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem .4rem; }
.sidebar-head .brand-logo { height: 42px; }
.sidebar-brand-titles { font-family: "Poppins", sans-serif; font-weight: 600; line-height: 1.15; color:#fff; }
.sidebar-brand-titles small {
  display: block; font-size: .66rem; font-weight: 400; color: rgba(255,255,255,.7);
  text-transform: uppercase; letter-spacing: .05em;
}
.sidebar-brand { font-family: "Poppins", sans-serif; font-weight: 600; }
.sidebar-nav { display: flex; flex-direction: column; padding: .75rem; gap: .15rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .85rem; border-radius: 10px;
  color: rgba(255,255,255,.85); text-decoration: none; font-weight: 500;
  transition: background .15s ease;
}
.sidebar-link i { font-size: 1.05rem; }
.sidebar-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-link.active { background: var(--accent); color: #14243f; }
.sidebar-foot { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user .role-pill { background: rgba(255,255,255,.16); color: var(--accent-soft); }
.gestion-topbar .lang-switcher .nav-link { color: var(--ink) !important; }

/* ---------- Bloc de validation du calendrier (Flatpickr) ---------- */
.fp-confirm { padding: 8px 10px 10px; text-align: center; border-top: 1px solid var(--line); }
.fp-hint { display: block; color: var(--muted); margin-bottom: 6px; font-size: .78rem; }

/* ---------- Divers ---------- */
.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty-state i { font-size: 2rem; opacity: .4; display: block; margin-bottom: .5rem; }
dl.detail-list dt { color: var(--muted); font-weight: 500; }
dl.detail-list dd { font-weight: 500; }

/* ---------- Adaptations mobile / tablette ---------- */
@media (max-width: 991.98px) {
  .gestion-content { padding: 1.1rem; }
  .gestion-topbar { padding: .55rem .9rem; }
}
@media (max-width: 575.98px) {
  .gestion-content { padding: .85rem; }
  .auth-body { padding: 1.5rem !important; }
  .page-title, h1.h3 { font-size: 1.35rem; }
  .stat-card { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.9rem; }
  .stat-card .stat-icon { font-size: 3.2rem; }
  .navbar-brand .brand-titles { font-size: .95rem; }
  .brand-logo { height: 38px; }
  .card-body { padding: 1.1rem; }
  .table { font-size: .9rem; }
  .btn { padding: .45rem .7rem; }
  /* Cibles tactiles plus confortables */
  .sidebar-link { padding: .8rem .9rem; }
  .dropdown-item { padding-top: .55rem; padding-bottom: .55rem; }
}
/* Le tableau ne force jamais un debordement horizontal de la page */
.table-card, .table-responsive { max-width: 100%; }
