/* Gestion Super Admin : utilisateurs, commerciaux et liaisons */
.sa-accounts-page{
  --sa-teal:#2f7d8c;
  --sa-teal-dark:#1f6170;
  --sa-border:#cbd5df;
  --sa-head:#dce7f1;
  --sa-soft:#f6f9fb;
  --sa-danger:#b42318;
  --sa-success:#157347;
  --sa-warning:#9a6700;
  padding-bottom:28px;
}
.sa-accounts-page *{box-sizing:border-box}
.sa-accounts-title{
  background:#fff;
  border:1px solid #d7dde4;
  border-radius:16px;
  box-shadow:0 3px 10px rgba(15,23,42,.08);
  font-size:22px;
  font-weight:900;
  text-align:center;
  padding:18px;
  margin-bottom:14px;
  text-transform:uppercase;
}
.sa-accounts-message{
  display:none;
  margin:0 0 12px;
  border:1px solid transparent;
  border-radius:9px;
  padding:10px 12px;
  font-weight:700;
}
.sa-accounts-message.is-visible{display:block}
.sa-accounts-message.success{background:#eaf7ef;border-color:#9fd3b2;color:#0d5c35}
.sa-accounts-message.error{background:#fff0f0;border-color:#efb1b1;color:#9d1c1c}
.sa-accounts-message.info{background:#edf6fa;border-color:#acd2df;color:#175666}
.sa-stats{
  display:grid;
  grid-template-columns:repeat(5,minmax(130px,1fr));
  gap:10px;
  margin-bottom:14px;
}
.sa-stat{
  background:#fff;
  border:1px solid var(--sa-border);
  border-radius:12px;
  padding:13px 14px;
  text-align:center;
  min-height:82px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}
.sa-stat strong{font-size:24px;line-height:1;color:#0f4f5c}
.sa-stat span{font-size:12px;font-weight:800;margin-top:7px;color:#475569;text-transform:uppercase}
.sa-tabs{
  display:flex;
  gap:8px;
  background:#fff;
  border:1px solid var(--sa-border);
  border-radius:12px;
  padding:10px;
  margin-bottom:12px;
}
.sa-tab{
  border:1px solid #9db6c2;
  background:#fff;
  color:#174b57;
  border-radius:8px;
  padding:10px 18px;
  font-weight:900;
  cursor:pointer;
}
.sa-tab.active{background:var(--sa-teal);border-color:var(--sa-teal);color:#fff}
.sa-panel{display:none}
.sa-panel.active{display:block}
.sa-card{
  background:#fff;
  border:1px solid var(--sa-border);
  border-radius:12px;
  box-shadow:0 2px 8px rgba(15,23,42,.06);
  overflow:hidden;
}
.sa-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:end;
  gap:10px;
  padding:13px;
  border-bottom:1px solid var(--sa-border);
  background:var(--sa-soft);
}
.sa-field{display:flex;flex-direction:column;gap:5px;min-width:150px}
.sa-field.grow{flex:1 1 260px}
.sa-field label{font-size:12px;font-weight:900;color:#334155}
.sa-field input,.sa-field select{
  height:40px;
  width:100%;
  border:1px solid #aebdca;
  border-radius:7px;
  background:#fff;
  padding:7px 10px;
  font-size:14px;
}
.sa-btn{
  min-height:40px;
  border:1px solid #94a9b5;
  border-radius:8px;
  padding:8px 14px;
  background:#fff;
  color:#173f48;
  font-weight:900;
  cursor:pointer;
  white-space:nowrap;
}
.sa-btn:hover{filter:brightness(.98)}
.sa-btn.primary{background:var(--sa-teal);border-color:var(--sa-teal);color:#fff}
.sa-btn.primary:hover{background:var(--sa-teal-dark)}
.sa-btn.danger{border-color:#d97878;color:#a61b1b;background:#fff7f7}
.sa-btn.delete{border-color:#b42318;color:#fff;background:#b42318}
.sa-btn.delete:hover{background:#8f1c13;border-color:#8f1c13}
.sa-btn.delete:disabled{background:#e4e7eb;border-color:#c8ced6;color:#7a838d;opacity:1;cursor:not-allowed}
.sa-btn.small{min-height:32px;padding:5px 9px;font-size:12px}
.sa-btn:disabled{cursor:not-allowed;opacity:.55}
.sa-table-wrap{
  max-height:58vh;
  overflow:auto;
  scrollbar-gutter:stable both-edges;
}
.sa-table{
  width:100%;
  min-width:1080px;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
}
.sa-table th,.sa-table td{
  border-right:1px solid #9faeba;
  border-bottom:1px solid #9faeba;
  padding:8px 9px;
  text-align:center;
  vertical-align:middle;
  background:#fff;
}
.sa-table th:first-child,.sa-table td:first-child{border-left:1px solid #9faeba}
.sa-table thead th{
  position:sticky;
  top:0;
  z-index:4;
  background:var(--sa-head);
  font-weight:900;
  color:#0f172a;
  border-top:1px solid #9faeba;
}
.sa-table td.sa-left{text-align:left}
.sa-table .sa-actions{display:flex;justify-content:center;gap:6px;flex-wrap:wrap}
.sa-empty{padding:22px!important;color:#64748b;font-style:italic;text-align:center!important}
.sa-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  padding:4px 9px;
  font-size:11px;
  font-weight:900;
  white-space:nowrap;
}
.sa-badge.active{background:#e5f6ea;color:#11633b;border:1px solid #99d0ad}
.sa-badge.inactive{background:#f1f3f5;color:#5f6873;border:1px solid #cbd0d6}
.sa-badge.linked{background:#e9f4ff;color:#185b8d;border:1px solid #afd0eb}
.sa-badge.unlinked{background:#fff5df;color:#8a5b00;border:1px solid #efd08d}
.sa-role-list{display:flex;gap:4px;flex-wrap:wrap;justify-content:center}
.sa-role-chip{font-size:10px;font-weight:800;background:#eef3f7;border:1px solid #c4d0d9;border-radius:5px;padding:3px 5px}
.sa-modal{
  position:fixed;
  inset:0;
  z-index:100500;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(15,23,42,.58);
}
.sa-modal.open{display:flex}
.sa-modal-dialog{
  width:min(940px,96vw);
  max-height:92vh;
  overflow:auto;
  background:#fff;
  border-radius:14px;
  border:1px solid #9eb0bd;
  box-shadow:0 20px 60px rgba(0,0,0,.28);
}
.sa-modal-dialog.small{width:min(560px,96vw)}
.sa-modal-head{
  position:sticky;
  top:0;
  z-index:3;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  background:#dce7f1;
  border-bottom:1px solid #aebdca;
  padding:13px 16px;
}
.sa-modal-head h3{margin:0;font-size:18px}
.sa-close{border:0;background:transparent;font-size:25px;line-height:1;cursor:pointer;color:#334155}
.sa-modal-body{padding:16px}
.sa-form-grid{display:grid;grid-template-columns:repeat(2,minmax(220px,1fr));gap:12px}
.sa-form-grid .full{grid-column:1/-1}
.sa-check-line{display:flex;align-items:center;gap:9px;font-weight:800;min-height:40px}
.sa-check-line input{width:18px;height:18px}
.sa-role-box{
  border:1px solid #b9c6d0;
  border-radius:8px;
  padding:10px;
  display:grid;
  grid-template-columns:repeat(3,minmax(150px,1fr));
  gap:7px 10px;
  background:#fbfcfd;
  max-height:240px;
  overflow:auto;
}
.sa-role-option{display:flex;align-items:center;gap:7px;font-size:13px;font-weight:700}
.sa-role-option input{width:16px;height:16px}
.sa-hint{font-size:12px;color:#64748b;margin-top:5px;line-height:1.35}
.sa-hint.warning{color:#8a5b00;font-weight:800}
.sa-modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:9px;
  flex-wrap:wrap;
  padding:13px 16px;
  border-top:1px solid #d5dde4;
  background:#f8fafc;
}
.sa-password-box{
  border:2px dashed #2f7d8c;
  background:#f1fbfd;
  border-radius:10px;
  padding:16px;
  text-align:center;
}
.sa-password-value{
  display:block;
  margin:10px auto;
  font-family:Consolas,monospace;
  font-size:23px;
  font-weight:900;
  letter-spacing:1px;
  word-break:break-all;
}
.sa-loading{opacity:.65;pointer-events:none}
@media(max-width:1100px){.sa-stats{grid-template-columns:repeat(3,1fr)}.sa-role-box{grid-template-columns:repeat(2,1fr)}}
@media(max-width:720px){
  .sa-stats{grid-template-columns:repeat(2,1fr)}
  .sa-form-grid{grid-template-columns:1fr}
  .sa-form-grid .full{grid-column:auto}
  .sa-role-box{grid-template-columns:1fr}
  .sa-tabs{flex-direction:column}
  .sa-tab{width:100%}
}

/* =========================================================
   CORRECTION DÉFINITIVE — MÊME DÉFILEMENT QUE « RÉCAP UTILISATION WHATSAPP »
   - La barre supérieure et la barre latérale restent dans leur zone.
   - Seul le contenu actif de la zone principale défile verticalement.
   - Aucun ascenseur vertical interne n'est créé dans les tableaux.
   - La navigation horizontale du tableau est conservée.
   ========================================================= */
body.gebat-super-ui{
  height:100vh !important;
  overflow:hidden !important;
}
body.gebat-super-ui .layout#mainContent{
  height:100vh !important;
  min-height:100vh !important;
  overflow:hidden !important;
}
body.gebat-super-ui .layout#mainContent > .sidebar{
  flex:0 0 var(--sidebar-width,260px) !important;
  height:100vh !important;
  overflow-y:auto !important;
}
body.gebat-super-ui .layout#mainContent > .main,
body.gebat-super-ui .main{
  display:flex !important;
  flex-direction:column !important;
  height:100vh !important;
  min-height:0 !important;
  overflow:hidden !important;
}
body.gebat-super-ui .main > .header,
body.gebat-super-ui .header{
  flex:0 0 auto !important;
  position:relative !important;
  top:auto !important;
  z-index:80 !important;
}
body.gebat-super-ui .page-workspace,
body.gebat-super-ui #pageWorkspace,
body.gebat-super-ui .main > div:not(.header){
  flex:1 1 auto !important;
  min-height:0 !important;
}

#superadmin_accounts.sa-accounts-page{
  width:100% !important;
  max-width:100% !important;
  height:100% !important;
  min-height:0 !important;
  max-height:none !important;
  margin:0 !important;
  padding:14px 18px 28px !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  overscroll-behavior-y:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-gutter:stable;
  position:relative !important;
  inset:auto !important;
  transform:none !important;
  background:#f8fafc;
}

/* La page cachée ne doit jamais réserver une hauteur dans le workspace. */
#superadmin_accounts.sa-accounts-page:not(.active){
  display:none !important;
}
#superadmin_accounts.sa-accounts-page.active{
  display:block !important;
}

#superadmin_accounts.sa-accounts-page::-webkit-scrollbar{
  width:14px;
  height:14px;
}
#superadmin_accounts.sa-accounts-page::-webkit-scrollbar-track{
  background:#e7edf3;
  border-left:1px solid #d4dde6;
}
#superadmin_accounts.sa-accounts-page::-webkit-scrollbar-thumb{
  min-height:54px;
  background:#7d8996;
  border:3px solid #e7edf3;
  border-radius:999px;
}
#superadmin_accounts.sa-accounts-page::-webkit-scrollbar-thumb:hover{
  background:#5f6c79;
}

/* Hauteur naturelle : toutes les lignes alimentent l'ascenseur de la page. */
#superadmin_accounts .sa-panel.active,
#superadmin_accounts .sa-card{
  height:auto !important;
  min-height:0 !important;
  max-height:none !important;
}
#superadmin_accounts .sa-table-wrap{
  position:relative;
  width:100%;
  height:auto !important;
  min-height:0 !important;
  max-height:none !important;
  overflow-x:auto !important;
  overflow-y:visible !important;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-gutter:auto;
}
#superadmin_accounts .sa-table-wrap::-webkit-scrollbar{
  width:0;
  height:12px;
}
#superadmin_accounts .sa-table-wrap::-webkit-scrollbar-track{
  background:#e7edf3;
}
#superadmin_accounts .sa-table-wrap::-webkit-scrollbar-thumb{
  background:#7d8996;
  border:3px solid #e7edf3;
  border-radius:999px;
}

/* Évite qu'un ancien calcul JS ou une ancienne classe de navigation persiste. */
body.sa-accounts-scroll-mode #superadmin_accounts,
body.sa-accounts-scroll-mode #superadmin_accounts .sa-table-wrap{
  --sa-table-available-height:auto !important;
}

@media(max-width:720px){
  #superadmin_accounts.sa-accounts-page{padding:10px 10px 22px !important}
}


/* Suppression définitive sécurisée des comptes utilisateurs */
.sa-modal-head-danger{
  background:#fee4e2;
  border-bottom-color:#f4a7a2;
  color:#7a1712;
}
.sa-delete-warning{
  border:1px solid #ef9a94;
  border-left:5px solid #b42318;
  border-radius:9px;
  background:#fff1f0;
  color:#7a1712;
  padding:12px 14px;
  margin-bottom:14px;
  line-height:1.45;
}
.sa-delete-warning strong{
  display:block;
  font-size:15px;
  margin-bottom:4px;
}
.sa-delete-warning p{margin:0}
.sa-delete-summary{
  margin:0 0 14px;
  border:1px solid #d5dde4;
  border-radius:9px;
  overflow:hidden;
}
.sa-delete-summary > div{
  display:grid;
  grid-template-columns:130px minmax(0,1fr);
  border-bottom:1px solid #e3e8ed;
}
.sa-delete-summary > div:last-child{border-bottom:0}
.sa-delete-summary dt,
.sa-delete-summary dd{
  margin:0;
  padding:9px 11px;
}
.sa-delete-summary dt{
  background:#f4f7f9;
  font-weight:900;
  color:#334155;
}
.sa-delete-summary dd{
  background:#fff;
  font-weight:700;
  overflow-wrap:anywhere;
}
#saDeleteUsernameConfirm{
  border-color:#d97878;
}
#saDeleteUsernameConfirm:focus{
  outline:2px solid rgba(180,35,24,.18);
  border-color:#b42318;
}
@media(max-width:560px){
  .sa-delete-summary > div{grid-template-columns:1fr}
  .sa-delete-summary dt{border-bottom:1px solid #e3e8ed}
}
