/**
 * Chrome commun PrestaIA — identité utilisateur (haut de page).
 * Style Kommandia : avatar + nom + rôle ; clic → modal déco.
 * Le bascule clair/sombre reste dans delta-theme.css (.delta-theme-toggle).
 */

/* Header mobile unifié : ← | logo brique | société | initiales | clair/sombre */
.m-top__back {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 0.55rem;
  background: rgba(148, 163, 184, 0.12);
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  text-decoration: none;
}
.m-top__back:hover {
  text-decoration: none;
  background: rgba(148, 163, 184, 0.22);
}
html[data-theme="light"] .m-top__back {
  background: #e8eef6;
  color: #122033;
}
html[data-theme="light"] .m-top__back:hover {
  background: #dbe4f0;
  color: #0f172a;
}
.m-top__brand {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  text-decoration: none;
}
.m-top__brand img,
.m-top-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.m-top__brand-txt {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.m-top__slot {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.m-top .delta-soc-filter,
.m-top .talentia-soc-filter {
  margin-left: 0.15rem;
  margin-right: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
}
.m-top .delta-who,
.m-top .m-top__who,
.m-top .who-block {
  margin-left: 0;
  flex: 0 0 auto;
}

.delta-who {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--muted, #8b9bb4);
}

/* Clair/sombre toujours à droite du nom (avatar, nom, bouton). */
.delta-who > .delta-theme-toggle,
.delta-who > .theme-toggle,
.delta-session > .delta-theme-toggle,
header.top .top-right > .delta-theme-toggle {
  order: 3;
  align-self: center;
  margin-left: 0.15rem;
}

/* Headers mobiles : uniquement les 2 cercles (initiales + jour/nuit) */
.m-top .delta-who__meta,
header.m-top .delta-who__meta {
  display: none !important;
}
.m-top .delta-who--btn,
.m-top button.delta-who--btn,
.m-top .m-who-btn {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.m-top .delta-who__avatar {
  width: 44px;
  height: 44px;
  font-size: 0.85rem;
}
.m-top .delta-who > .delta-theme-toggle,
.m-top .delta-theme-toggle--inline {
  width: 44px;
  height: 44px;
}
.delta-who--compact {
  gap: 0.4rem;
}

button.delta-who--btn,
.delta-who .who-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  margin: 0;
  padding: 0.15rem 0.35rem 0.15rem 0.15rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 0;
  text-align: left;
}

button.delta-who--btn:hover,
.delta-who .who-btn:hover {
  background: rgba(56, 189, 248, 0.1);
}

button.delta-who--btn:focus-visible,
.delta-who .who-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.45);
}

.delta-who__avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #f4fbff;
  background: radial-gradient(circle at 35% 30%, #16324a, #0a1424 70%);
  border: 2px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.12);
}

.delta-who__meta,
.who.delta-who__meta,
.who__meta.delta-who__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.12rem;
  line-height: 1.15;
  min-width: 0;
  text-align: left;
}

.delta-who__name,
.who-name.delta-who__name,
.who__name.delta-who__name {
  /* Ne pas dépendre de --ink/--text (souvent définis pour le thème clair) :
     en sombre sans variable → texte clair ; en clair → override ci-dessous. */
  color: #e8eef8;
  font-weight: 600;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  text-align: left;
  align-self: flex-start;
  margin-left: 0;
  margin-right: auto;
}
html[data-theme="dark"] .delta-who__name,
html:not([data-theme]) .delta-who__name {
  color: #e8eef8;
}

.delta-who__role,
.who-mail.delta-who__role,
.who__role.delta-who__role {
  font-size: 0.62rem;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  text-transform: lowercase;
  text-align: left;
  align-self: flex-start;
  margin-left: 0;
  margin-right: auto;
}

.delta-who__logout-form {
  display: contents;
  margin: 0;
}

/* Plus de bouton « porte » : déconnexion via modal (clic sur le user) */
.delta-who__out {
  display: none !important;
}

/* Le libellé « Déconnexion » reste pour les lecteurs d’écran, pas dans le cercle */
.delta-who__out > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  font-size: 0.8rem;
}

.delta-who__out svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.delta-who__out:hover,
.delta-who__out:focus-visible {
  color: #041018;
  background: linear-gradient(145deg, #ff8aa3, #ef4444);
  border-color: #ffd0da;
  transform: translateY(-1px);
  text-decoration: none;
}

html[data-theme="light"] .delta-who {
  color: #5b6b82;
}

html[data-theme="light"] .delta-who__avatar {
  color: #0f172a;
  background: radial-gradient(circle at 35% 30%, #e0f2fe, #f8fafc 70%);
  border-color: rgba(14, 116, 144, 0.45);
  box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.1);
}

html[data-theme="light"] .delta-who__name {
  color: #122033;
}

html[data-theme="light"] .delta-who__role {
  background: rgba(14, 116, 144, 0.1);
  color: #0e7490;
}

html[data-theme="light"] .delta-who__out {
  color: #0e7490;
  border-color: rgba(14, 116, 144, 0.35);
  background: rgba(255, 255, 255, 0.9);
}

/* Alias : les apps existantes peuvent garder leur markup en ajoutant .delta-who */
.top-user.delta-who,
.who.delta-who,
.who-block.delta-who {
  /* hérite de .delta-who */
}

/* Modal déconnexion (commun) */
.delta-impersonate-bar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.8rem;
  background: #1d4ed8;
  color: #fff;
  font: 600 13px/1.3 system-ui, sans-serif;
}
.delta-impersonate-bar a {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  text-decoration: none;
}
.delta-who-dialog,
.delta-who-dialog * {
  box-sizing: border-box;
}
.delta-who-dialog {
  width: min(24rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: #e2e8f0;
}
.delta-who-dialog[open] {
  animation: delta-who-dialog-pop 0.18s ease-out;
}
@keyframes delta-who-dialog-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .delta-who-dialog[open] {
    animation: none;
  }
}
.delta-who-dialog::backdrop {
  background: rgba(7, 11, 20, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.delta-who-dialog__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 1.6rem 1.5rem 1.4rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 20px;
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.delta-who-dialog__icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.9rem;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
}
.delta-who-dialog__icon svg {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
}
.delta-who-dialog__box h2 {
  margin: 0 0 0.45rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.delta-who-dialog__box p {
  margin: 0;
  max-width: 19rem;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.55;
}
.delta-who-dialog__name {
  color: #e2e8f0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.delta-who-dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.35rem;
}
.delta-who-dialog__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.1);
  color: #e2e8f0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.delta-who-dialog__btn:hover {
  background: rgba(148, 163, 184, 0.2);
  text-decoration: none;
}
.delta-who-dialog__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.45);
}
.delta-who-dialog__btn--danger {
  background: linear-gradient(180deg, #e85d4f, #c93a2c);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 8px 20px rgba(201, 58, 44, 0.32);
}
.delta-who-dialog__btn--danger:hover {
  background: linear-gradient(180deg, #f06a5b, #d44435);
  transform: translateY(-1px);
}
.delta-who-dialog__btn--danger:focus-visible {
  box-shadow: 0 8px 20px rgba(201, 58, 44, 0.32), 0 0 0 3px rgba(248, 113, 113, 0.5);
}
@media (max-width: 26rem) {
  .delta-who-dialog__box {
    padding: 1.35rem 1.1rem 1.15rem;
  }
  /* Boutons pleine largeur : aucun libellé rogné, aucune barre de défilement */
  .delta-who-dialog__actions {
    grid-template-columns: 1fr;
  }
  .delta-who-dialog__btn--danger {
    order: -1;
  }
}
html[data-theme="light"] .delta-who-dialog {
  color: #0f172a;
}
html[data-theme="light"] .delta-who-dialog__box {
  background: #fff;
  color: #0f172a;
  border-color: #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}
html[data-theme="light"] .delta-who-dialog__icon {
  background: #fee2e2;
  color: #dc2626;
}
html[data-theme="light"] .delta-who-dialog__box p {
  color: #64748b;
}
html[data-theme="light"] .delta-who-dialog__name {
  color: #0f172a;
}
html[data-theme="light"] .delta-who-dialog__btn {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #e2e8f0;
}
html[data-theme="light"] .delta-who-dialog__btn:hover {
  background: #e2e8f0;
}
html[data-theme="light"] .delta-who-dialog__btn--danger {
  background: linear-gradient(180deg, #e85d4f, #c93a2c);
  border-color: rgba(127, 29, 29, 0.15);
  color: #fff;
}
html[data-theme="light"] .delta-who-dialog__btn--danger:hover {
  background: linear-gradient(180deg, #f06a5b, #d44435);
}

/* FlotIA : who injecté dans le header sticky */
.delta-who--injected {
  margin-left: 0.75rem;
}

@media (max-width: 720px) {
  .delta-who__meta {
    display: none;
  }
  /* AdminIA et barres desktop : le nom reste à côté de l’avatar */
  .topbar .delta-who__meta {
    display: flex !important;
  }
}

/* Sélecteur société (briques vertes) — à côté du titre / app-kicker */
.delta-soc-filter,
.talentia-soc-filter:not(.hidden),
label.delta-soc-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.35rem;
  min-width: 0;
  flex: 0 1 auto;
}

.delta-soc-filter[hidden],
.delta-soc-filter.hidden,
.talentia-soc-filter.hidden {
  display: none !important;
}

.delta-soc-filter__lbl {
  font-size: 0.62rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  white-space: nowrap;
}

.delta-soc-select,
.talentia-soc-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 11rem;
  min-width: 7.5rem;
  padding: 0.35rem 1.75rem 0.35rem 0.6rem;
  border-radius: 0.45rem;
  border: 1px solid #e2e8f0;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
  color: #0f172a;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
}

.delta-soc-select:hover,
.talentia-soc-select:hover {
  border-color: #cbd5e1;
}

.delta-soc-select:focus,
.talentia-soc-select:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.delta-soc-select:disabled,
.talentia-soc-select:disabled {
  opacity: 0.85;
  cursor: default;
  background-color: #f8fafc;
}

@media (min-width: 640px) {
  .delta-soc-select,
  .talentia-soc-select {
    max-width: 14rem;
  }
}

@media (max-width: 640px) {
  .delta-soc-filter__lbl {
    display: none;
  }
}

html[data-theme="dark"] .delta-soc-select,
html[data-theme="dark"] .talentia-soc-select {
  background-color: #0f172a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E");
  border-color: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  color-scheme: dark;
}

.delta-soc-select option,
.talentia-soc-select option {
  background: #fff;
  color: #0f172a;
}

html[data-theme="dark"] .delta-soc-select:disabled,
html[data-theme="dark"] .talentia-soc-select:disabled {
  background-color: #1e293b;
}

html[data-theme="dark"] .delta-soc-filter__lbl {
  color: #64748b;
}

/*
 * AdminIA topbar : le nom ne doit jamais disparaître ni se fondre dans la barre.
 * Ces règles sont en fin de feuille (chargée après app.css) et en !important
 * pour battre .delta-who__meta { display:none } sous 720px et color:#0f172a.
 */
.topbar .delta-who__meta {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start !important;
  justify-content: center;
  flex-shrink: 0;
  min-width: max-content;
  overflow: visible;
  visibility: visible !important;
  opacity: 1 !important;
  text-align: left !important;
}
.topbar .delta-who__name {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto;
  min-width: 0;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  text-align: left !important;
  align-self: flex-start !important;
  margin-left: 0 !important;
  margin-right: auto !important;
  font-size: 0.78rem !important;
  font-weight: 650;
  line-height: 1.2;
  -webkit-text-fill-color: currentColor;
  background: none;
}
.topbar .delta-who__role {
  align-self: flex-start !important;
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}
.topbar .delta-who__avatar {
  font-size: 0.72rem !important;
  line-height: 1;
  -webkit-text-fill-color: currentColor;
}
/* Sombre (défaut AdminIA) : texte clair sur barre #0c1e38 */
html[data-theme="dark"] .topbar .delta-who__name,
html.theme-dark .topbar .delta-who__name,
html:not([data-theme="light"]) .topbar .delta-who__name {
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc !important;
}
html[data-theme="dark"] .topbar .delta-who__avatar,
html.theme-dark .topbar .delta-who__avatar,
html:not([data-theme="light"]) .topbar .delta-who__avatar {
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc !important;
  background: radial-gradient(circle at 35% 30%, #1e4970, #0a1424 70%) !important;
  border-color: rgba(125, 211, 252, 0.85) !important;
}
/* Clair : texte sombre sur barre blanche */
html[data-theme="light"] .topbar .delta-who__name {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}
html[data-theme="light"] .topbar .delta-who__avatar {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  background: radial-gradient(circle at 35% 30%, #e0f2fe, #f8fafc 70%) !important;
  border-color: rgba(14, 116, 144, 0.55) !important;
}

