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

:root {
  --bleu-clair:  #29ABE2;
  --bleu-fonce:  #2B3990;
  --bleu-mid:    #1a7bbf;
  --gradient:    linear-gradient(135deg, #29ABE2 0%, #2B3990 100%);
  --gradient-r:  linear-gradient(135deg, #2B3990 0%, #29ABE2 100%);
  --bg:          #F0F4F8;
  --blanc:       #FFFFFF;
  --gris-leger:  #E8EDF2;
  --gris-texte:  #64748B;
  --texte:       #1E293B;
  --danger:      #EF4444;
  --succes:      #10B981;
  --warning:     #F59E0B;
  --shadow-sm:   0 1px 3px rgba(43,57,144,.08), 0 1px 2px rgba(43,57,144,.06);
  --shadow-md:   0 4px 16px rgba(43,57,144,.12), 0 2px 6px rgba(43,57,144,.08);
  --shadow-lg:   0 10px 40px rgba(43,57,144,.16), 0 4px 12px rgba(43,57,144,.10);
  --radius:      14px;
  --radius-sm:   8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Comfortaa', system-ui, sans-serif;
  background: var(--bg);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── AUTH PAGES ──────────────────────────────────────── */
.page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.page-auth::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -200px; right: -150px;
  pointer-events: none;
}
.page-auth::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  bottom: -120px; left: -100px;
  pointer-events: none;
}

.carte-auth {
  background: var(--blanc);
  border-radius: 24px;
  padding: 48px 44px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.carte-auth .logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 36px;
}

.carte-auth .logo-wrap img {
  height: 56px;
  object-fit: contain;
}

.carte-auth h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--bleu-fonce);
  text-align: center;
  margin-bottom: 6px;
}

.carte-auth .sous-titre {
  text-align: center;
  color: var(--gris-texte);
  font-size: .9rem;
  margin-bottom: 32px;
}

/* ── FORM ELEMENTS ───────────────────────────────────── */
.champ {
  margin-bottom: 18px;
}

.champ label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--bleu-fonce);
  margin-bottom: 7px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.champ input, .champ select {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--gris-leger);
  border-radius: var(--radius-sm);
  font-family: 'Comfortaa', sans-serif;
  font-size: .95rem;
  color: var(--texte);
  background: #FAFBFD;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.champ input:focus, .champ select:focus {
  border-color: var(--bleu-clair);
  box-shadow: 0 0 0 3px rgba(41,171,226,.15);
  background: var(--blanc);
}

.champ-double {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Comfortaa', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  letter-spacing: .02em;
  line-height: 1;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primaire {
  background: var(--gradient);
  color: white;
  width: 100%;
  padding: 15px;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(41,171,226,.35);
}

.btn-primaire:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(41,171,226,.45);
}

.btn-primaire:active { transform: translateY(0); }

.btn-secondaire {
  background: var(--gris-leger);
  color: var(--texte);
}
.btn-secondaire:hover { background: #d8e0ea; }

.btn-danger {
  background: #FEE2E2;
  color: var(--danger);
}
.btn-danger:hover { background: #FCA5A5; color: white; }

.btn-succes {
  background: #D1FAE5;
  color: #065F46;
}
.btn-succes:hover { background: var(--succes); color: white; }

.btn-sm { padding: 8px 14px; font-size: .82rem; }

.lien-auth {
  text-align: center;
  margin-top: 24px;
  font-size: .88rem;
  color: var(--gris-texte);
}
.lien-auth a {
  color: var(--bleu-clair);
  font-weight: 600;
  text-decoration: none;
}
.lien-auth a:hover { color: var(--bleu-fonce); }

/* ── ALERTES ─────────────────────────────────────────── */
.alerte {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}

.alerte svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.alerte-erreur  { background: #FEE2E2; color: #991B1B; border-left: 3px solid var(--danger); }
.alerte-succes  { background: #D1FAE5; color: #065F46; border-left: 3px solid var(--succes); }
.alerte-info    { background: #EFF6FF; color: #1E40AF; border-left: 3px solid var(--bleu-clair); }
.alerte-warning { background: #FEF3C7; color: #92400E; border-left: 3px solid var(--warning); }

/* ── LAYOUT INTRANET ─────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background: var(--gradient);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(43,57,144,.15);
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo img { height: 44px; object-fit: contain; filter: brightness(0) invert(1); }

.sidebar-user {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
}

.sidebar-user-info .nom {
  font-size: .92rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}
.sidebar-user-info .role {
  font-size: .75rem;
  color: rgba(255,255,255,.7);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.badge-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-admin      { background: rgba(255,215,0,.2);  color: #FFD700; }
.badge-utilisateur{ background: rgba(255,255,255,.15); color: rgba(255,255,255,.9); }
.badge-invite     { background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); }

.sidebar-nav {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
}

.nav-section {
  font-size: .7rem;
  font-weight: 700;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 8px;
  margin: 16px 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all .18s;
  margin-bottom: 3px;
}
.nav-item:hover { background: rgba(255,255,255,.12); color: white; }
.nav-item.actif { background: rgba(255,255,255,.2); color: white; font-weight: 700; }
.nav-item svg   { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.12);
}

/* MAIN CONTENT */
.contenu {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--blanc);
  border-bottom: 1px solid var(--gris-leger);
  padding: 20px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-titre h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--bleu-fonce);
}
.topbar-titre p {
  font-size: .82rem;
  color: var(--gris-texte);
  margin-top: 2px;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.main {
  padding: 36px;
  flex: 1;
}

/* ── CARTES APP ──────────────────────────────────────── */
.grille-apps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.carte-app {
  background: var(--blanc);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all .25s;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(43,57,144,.06);
  cursor: pointer;
}

.carte-app:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(41,171,226,.2);
}

.carte-app-header {
  padding: 28px 24px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.icone-app {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icone-app svg { width: 24px; height: 24px; color: white; }

.carte-app-info .nom-app {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bleu-fonce);
  margin-bottom: 4px;
  line-height: 1.3;
}
.carte-app-info .desc-app {
  font-size: .82rem;
  color: var(--gris-texte);
  line-height: 1.5;
}

.carte-app-footer {
  padding: 16px 24px 20px;
  margin-top: auto;
}

.btn-ouvrir {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Comfortaa', sans-serif;
  font-size: .85rem;
  font-weight: 700;
  color: white;
  border: none;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.btn-ouvrir:hover { filter: brightness(1.1); transform: translateX(2px); }
.btn-ouvrir svg { width: 14px; height: 14px; }

/* ── SECTION TITRE ───────────────────────────────────── */
.section-header {
  margin-bottom: 28px;
}
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bleu-fonce);
  margin-bottom: 4px;
}
.section-header p { font-size: .85rem; color: var(--gris-texte); }

/* ── STATS CARDS ─────────────────────────────────────── */
.stats-grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 36px;
}

.stat-carte {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(43,57,144,.06);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icone {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icone svg { width: 22px; height: 22px; color: white; }

.stat-valeur { font-size: 1.8rem; font-weight: 700; color: var(--bleu-fonce); line-height: 1; }
.stat-label  { font-size: .78rem; color: var(--gris-texte); margin-top: 3px; }

/* ── TABLEAU ─────────────────────────────────────────── */
.carte-tableau {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(43,57,144,.06);
  overflow: hidden;
}

.carte-tableau-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gris-leger);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.carte-tableau-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bleu-fonce);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  color: var(--gris-texte);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #FAFBFD;
  border-bottom: 1px solid var(--gris-leger);
}

tbody td {
  padding: 14px 16px;
  font-size: .88rem;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F8FAFC; }

/* ── BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-actif      { background: #D1FAE5; color: #065F46; }
.badge-inactif    { background: #FEE2E2; color: #991B1B; }
.badge-en-attente { background: #FEF3C7; color: #92400E; }
.badge-admin-t    { background: #EDE9FE; color: #5B21B6; }
.badge-utilisateur-t { background: #DBEAFE; color: #1E40AF; }
.badge-invite-t   { background: var(--gris-leger); color: var(--gris-texte); }

/* ── MODALE ──────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,41,59,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all .2s;
}
.overlay.ouvert { opacity: 1; visibility: visible; }

.modale {
  background: var(--blanc);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.98);
  transition: all .2s;
}
.overlay.ouvert .modale { transform: translateY(0) scale(1); }

.modale-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modale-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--bleu-fonce); }

.btn-fermer {
  width: 32px; height: 32px;
  border: none;
  background: var(--gris-leger);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gris-texte);
  transition: background .15s;
}
.btn-fermer:hover { background: #CBD5E1; }
.btn-fermer svg { width: 16px; height: 16px; }

/* ── RECHERCHE ───────────────────────────────────────── */
.input-recherche {
  padding: 10px 14px 10px 38px;
  border: 2px solid var(--gris-leger);
  border-radius: var(--radius-sm);
  font-family: 'Comfortaa', sans-serif;
  font-size: .88rem;
  color: var(--texte);
  background: #FAFBFD;
  outline: none;
  transition: border-color .2s;
  width: 260px;
}
.input-recherche:focus { border-color: var(--bleu-clair); }

.champ-recherche {
  position: relative;
  display: inline-block;
}
.champ-recherche svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--gris-texte);
  pointer-events: none;
}

/* ── EMPTY STATE ─────────────────────────────────────── */
.etat-vide {
  text-align: center;
  padding: 64px 24px;
  color: var(--gris-texte);
}
.etat-vide svg {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  opacity: .3;
  display: block;
}
.etat-vide p { font-size: .95rem; }

/* ── ONGLETS ─────────────────────────────────────────── */
.onglets {
  display: flex;
  gap: 4px;
  background: var(--gris-leger);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
  margin-bottom: 24px;
}
.onglet {
  padding: 9px 18px;
  border-radius: 6px;
  font-family: 'Comfortaa', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--gris-texte);
  transition: all .2s;
}
.onglet.actif {
  background: var(--blanc);
  color: var(--bleu-fonce);
  box-shadow: var(--shadow-sm);
}

/* ── TOGGLE SWITCH ───────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #CBD5E1;
  border-radius: 24px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--bleu-clair); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── PERMISSIONS GRID ────────────────────────────────── */
.grille-permissions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ligne-permission {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #FAFBFD;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gris-leger);
}
.ligne-permission .app-info { font-size: .88rem; font-weight: 600; color: var(--texte); }
.ligne-permission .app-desc { font-size: .78rem; color: var(--gris-texte); margin-top: 2px; }

/* ── NOTIFICATION TOP ────────────────────────────────── */
.notif-flottante {
  position: fixed;
  top: 24px; right: 24px;
  background: var(--blanc);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 9999;
  transform: translateX(110%);
  transition: transform .3s;
  max-width: 340px;
  border-left: 4px solid var(--succes);
}
.notif-flottante.succes { border-left-color: var(--succes); color: #065F46; }
.notif-flottante.erreur { border-left-color: var(--danger); color: #991B1B; }
.notif-flottante.visible { transform: translateX(0); }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.ouverte { transform: translateX(0); }
  .contenu { margin-left: 0; }
  .main { padding: 20px; }
  .topbar { padding: 16px 20px; }
  .champ-double { grid-template-columns: 1fr; }
  .grille-apps { grid-template-columns: 1fr; }
  .carte-auth { padding: 32px 24px; }
}

/* ── DIVIDER ─────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gris-leger);
  margin: 20px 0;
}

/* ── FORMULAIRE INLINE ───────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.form-row .champ { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ── SCROLL ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
