/* =========================================================
   Savvy Local Messenger v2.3 — Premium UI
   ========================================================= */

:root {
  --slm-bg: #f7f8fc;
  --slm-card: #ffffff;
  --slm-card-border: #e8ebf3;
  --slm-text: #0f172a;
  --slm-text-muted: #64748b;
  --slm-text-soft: #94a3b8;
  --slm-primary: #4f46e5;
  --slm-primary-soft: #eef2ff;
  --slm-primary-dark: #3730a3;
  --slm-accent: #7c3aed;
  --slm-success: #10b981;
  --slm-success-soft: #d1fae5;
  --slm-danger: #ef4444;
  --slm-danger-soft: #fee2e2;
  --slm-warning: #f59e0b;
  --slm-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --slm-shadow-md: 0 4px 24px rgba(15, 23, 42, .06), 0 2px 6px rgba(15, 23, 42, .04);
  --slm-shadow-lg: 0 24px 60px rgba(79, 70, 229, .14), 0 8px 24px rgba(15, 23, 42, .06);
  --slm-radius-sm: 8px;
  --slm-radius-md: 14px;
  --slm-radius-lg: 22px;
  --slm-radius-pill: 999px;
  --slm-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --slm-grad-soft: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --slm-bg: #0b1020;
    --slm-card: #131a2e;
    --slm-card-border: #1f2740;
    --slm-text: #f1f5f9;
    --slm-text-muted: #94a3b8;
    --slm-text-soft: #64748b;
    --slm-primary-soft: #1e1b4b;
    --slm-shadow-md: 0 4px 24px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .2);
    --slm-shadow-lg: 0 24px 60px rgba(0, 0, 0, .55), 0 8px 24px rgba(0, 0, 0, .3);
    --slm-grad-soft: linear-gradient(135deg, #1e1b4b 0%, #2a1656 100%);
  }
}

/* ── Reset léger sur le shell ── */
.slm-shell, .slm-shell *,
.slm-login-box, .slm-login-box * {
  box-sizing: border-box;
}

.slm-shell {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  color: var(--slm-text);
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Topbar ── */
.slm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.slm-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--slm-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--slm-radius-pill);
  background: var(--slm-card);
  border: 1px solid var(--slm-card-border);
  transition: all .2s ease;
}
.slm-back-link:hover {
  color: var(--slm-primary);
  border-color: var(--slm-primary);
  transform: translateX(-2px);
}
.slm-topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Pills (rôles, contexte, sécurité) ── */
.slm-role-pill, .slm-context-pill, .slm-secure-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--slm-radius-pill);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.slm-role-pill.slm-role-employer  { background: #fef3c7; color: #92400e; }
.slm-role-pill.slm-role-candidate { background: #dbeafe; color: #1e40af; }
.slm-role-pill.slm-role-admin     { background: #fce7f3; color: #9d174d; }

/* Pill utilisateur (topbar) — nom + petite initiale, pas de mention de rôle. */
.slm-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--slm-card);
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--slm-text);
  max-width: 220px;
}
.slm-user-pill .slm-avatar-wrap.slm-user-pill-avatar {
  width: 26px !important; height: 26px !important;
  font-size: 11px;
}
.slm-user-pill-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.slm-context-pill { background: var(--slm-primary-soft); color: var(--slm-primary-dark); text-transform: none; }
.slm-secure-pill {
  background: var(--slm-success-soft);
  color: #065f46;
  text-transform: none;
}

/* ── Header principal ── */
.slm-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--slm-radius-lg);
  background: var(--slm-grad-soft);
  border: 1px solid var(--slm-card-border);
  margin-bottom: 16px;
}
.slm-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slm-primary);
  margin-bottom: 4px;
}
.slm-header h2 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  background: var(--slm-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.slm-header p { color: var(--slm-text-muted); margin: 0; font-size: 14px; }
.slm-total-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--slm-card);
  padding: 10px 18px;
  border-radius: var(--slm-radius-md);
  border: 1px solid var(--slm-card-border);
  box-shadow: var(--slm-shadow-sm);
  min-width: 84px;
}
.slm-total-badge span {
  font-size: 24px;
  font-weight: 700;
  color: var(--slm-primary);
  line-height: 1;
}
.slm-total-badge small {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--slm-text-muted);
  margin-top: 4px;
}

/* ── Notices ── */
.slm-notice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border-radius: var(--slm-radius-md);
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
  animation: slm-fade-in .25s ease;
}
.slm-notice strong { font-weight: 600; }
.slm-notice-success { background: var(--slm-success-soft); color: #065f46; border-color: #a7f3d0; }
.slm-notice-error   { background: var(--slm-danger-soft);  color: #991b1b; border-color: #fecaca; }

/* ── Carte principale ── */
.slm-card {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); /* minmax(0,1fr) = autorise les enfants à rétrécir */
  gap: 0;
  background: var(--slm-card);
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-lg);
  box-shadow: var(--slm-shadow-lg);
  overflow: hidden;
  min-height: 600px;
}
.slm-panel { min-width: 0; }
.slm-messages { min-width: 0; }
.slm-thread-header { min-width: 0; }
.slm-thread-info { min-width: 0; }

/* ── Sidebar ── */
.slm-sidebar {
  border-right: 1px solid var(--slm-card-border);
  background: linear-gradient(180deg, var(--slm-card) 0%, rgba(247, 248, 252, .6) 100%);
  display: flex;
  flex-direction: column;
  max-height: 720px;
  overflow: hidden;
}
.slm-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--slm-card-border);
  flex-shrink: 0;
}
.slm-sidebar-title { display: flex; align-items: center; gap: 8px; }
.slm-sidebar-title strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--slm-text);
}
.slm-sidebar-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--slm-primary-soft);
  color: var(--slm-primary-dark);
  padding: 2px 8px;
  border-radius: var(--slm-radius-pill);
}

.slm-new-conv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slm-grad);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--slm-radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
  transition: all .2s ease;
}
.slm-new-conv-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, .4);
}
.slm-new-conv-btn:active { transform: translateY(0); }

/* ── Recherche utilisateurs ── */
.slm-new-conv-panel {
  padding: 14px 18px;
  border-bottom: 1px solid var(--slm-card-border);
  background: var(--slm-grad-soft);
  animation: slm-slide-down .25s ease;
}
.slm-new-conv-panel[hidden] { display: none; }
.slm-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.slm-search-icon {
  position: absolute;
  left: 12px;
  color: var(--slm-text-muted);
  pointer-events: none;
}
#slmUserSearch {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-md);
  background: var(--slm-card);
  font-size: 14px;
  color: var(--slm-text);
  transition: all .2s ease;
  outline: none;
}
#slmUserSearch:focus {
  border-color: var(--slm-primary);
  box-shadow: 0 0 0 3px var(--slm-primary-soft);
}
.slm-search-results {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.slm-search-results:empty { display: none; }
.slm-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--slm-radius-md);
  background: var(--slm-card);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}
.slm-search-result:hover, .slm-search-result:focus-visible {
  border-color: var(--slm-primary);
  background: var(--slm-primary-soft);
  outline: none;
  transform: translateY(-1px);
}
.slm-search-result .slm-avatar {
  width: 34px; height: 34px;
  font-size: 13px;
  flex-shrink: 0;
}
.slm-search-result-info {
  flex: 1;
  min-width: 0;
}
.slm-search-result-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slm-search-result-info small {
  display: block;
  font-size: 11px;
  color: var(--slm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slm-search-status {
  font-size: 12px;
  color: var(--slm-text-muted);
  padding: 8px 4px;
  text-align: center;
  font-style: italic;
}
.slm-search-help {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--slm-text-muted);
  text-align: center;
}

/* ── Liste de conversations ── */
.slm-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--slm-card-border) transparent;
}
.slm-conv-list::-webkit-scrollbar { width: 6px; }
.slm-conv-list::-webkit-scrollbar-track { background: transparent; }
.slm-conv-list::-webkit-scrollbar-thumb { background: var(--slm-card-border); border-radius: 3px; }

.slm-empty-small {
  padding: 32px 16px;
  text-align: center;
  color: var(--slm-text-muted);
}
.slm-empty-small p { margin: 8px 0 4px; font-size: 14px; font-weight: 500; }
.slm-empty-small small { font-size: 12px; }
.slm-empty-illu {
  font-size: 36px;
  opacity: .8;
  margin-bottom: 8px;
}

.slm-conversation {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--slm-radius-md);
  text-decoration: none;
  color: inherit;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all .15s ease;
  position: relative;
}
.slm-conversation:hover {
  background: var(--slm-primary-soft);
  border-color: rgba(79, 70, 229, .15);
}
.slm-conversation.is-active {
  background: var(--slm-grad-soft);
  border-color: rgba(79, 70, 229, .3);
  box-shadow: 0 2px 8px rgba(79, 70, 229, .1);
}
.slm-conversation.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translate(-3px, -50%);
  width: 4px; height: 60%;
  background: var(--slm-grad);
  border-radius: 0 4px 4px 0;
}

/* Avatars (peuvent contenir img + initiale fallback) */
.slm-avatar,
.slm-avatar-wrap {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: var(--slm-grad);
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .25);
  position: relative;
  overflow: hidden;
}
.slm-avatar-large { width: 48px !important; height: 48px !important; font-size: 18px; }
.slm-avatar.slm-avatar-employer,  .slm-avatar-wrap.slm-avatar-employer  { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 2px 6px rgba(245, 158, 11, .3); }
.slm-avatar.slm-avatar-candidate, .slm-avatar-wrap.slm-avatar-candidate { background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 2px 6px rgba(59, 130, 246, .3); }
.slm-avatar.slm-avatar-admin,     .slm-avatar-wrap.slm-avatar-admin     { background: linear-gradient(135deg, #ec4899, #be185d); box-shadow: 0 2px 6px rgba(236, 72, 153, .3); }
/* L'image masque la couleur si elle se charge ; sinon l'initiale reste visible derrière. */
.slm-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  z-index: 1;
}
.slm-avatar-initial {
  position: relative;
  z-index: 0;
}

.slm-conversation-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.slm-conv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.slm-conversation-main strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--slm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slm-conv-time {
  font-size: 11px;
  color: var(--slm-text-muted);
  flex-shrink: 0;
  font-weight: 500;
}
.slm-conv-role {
  font-size: 11px;
  color: var(--slm-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.slm-conversation-context {
  display: block;
  font-size: 11px;
  color: var(--slm-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.slm-conv-preview {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--slm-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.slm-conv-status {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--slm-radius-pill);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.slm-conv-status.is-sent     { background: #fef3c7; color: #92400e; }
.slm-conv-status.is-read     { background: var(--slm-success-soft); color: #065f46; }
.slm-conv-status.is-received { background: #dbeafe; color: #1e40af; }
.slm-conv-badge {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--slm-grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  padding: 2px 8px;
  border-radius: var(--slm-radius-pill);
  min-width: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .35);
  animation: slm-pulse 2s ease-in-out infinite;
}

/* ── Panneau principal ── */
.slm-panel {
  display: flex;
  flex-direction: column;
  background: var(--slm-card);
  min-height: 600px;
  max-height: 720px;
  position: relative;
}
.slm-thread-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--slm-card-border);
  background: var(--slm-card);
  flex-shrink: 0;
}
.slm-thread-info { flex: 1; min-width: 0; }
.slm-thread-info h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--slm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slm-thread-info p {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Messages ── */
.slm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background:
    radial-gradient(circle at 20% 0%, rgba(79, 70, 229, .04), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(124, 58, 237, .04), transparent 40%);
  scrollbar-width: thin;
  scrollbar-color: var(--slm-card-border) transparent;
}
.slm-messages::-webkit-scrollbar { width: 6px; }
.slm-messages::-webkit-scrollbar-thumb { background: var(--slm-card-border); border-radius: 3px; }

.slm-day-sep {
  text-align: center;
  margin: 12px 0 6px;
  position: relative;
}
.slm-day-sep::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--slm-card-border);
  z-index: 0;
}
.slm-day-sep span {
  position: relative;
  z-index: 1;
  display: inline-block;
  background: var(--slm-card);
  padding: 2px 12px;
  font-size: 11px;
  text-transform: capitalize;
  color: var(--slm-text-muted);
  font-weight: 500;
  border-radius: var(--slm-radius-pill);
  border: 1px solid var(--slm-card-border);
}

.slm-message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  margin-bottom: 6px;
  animation: slm-bubble-in .3s ease;
}
.slm-message.is-me    { align-self: flex-end; align-items: flex-end; }
.slm-message.is-other { align-self: flex-start; align-items: flex-start; }
.slm-message.is-fresh { animation: slm-bubble-pop .35s cubic-bezier(.34, 1.56, .64, 1); }

.slm-message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: var(--slm-shadow-sm);
  position: relative;
}
.slm-message.is-me .slm-message-bubble {
  background: var(--slm-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.slm-message.is-other .slm-message-bubble {
  background: var(--slm-card);
  color: var(--slm-text);
  border: 1px solid var(--slm-card-border);
  border-bottom-left-radius: 6px;
}
.slm-message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 6px 0;
  font-size: 11px;
  color: var(--slm-text-muted);
}
.slm-message-status {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.slm-message-status.is-sent     { color: var(--slm-warning); }
.slm-message-status.is-read     { color: var(--slm-success); }
.slm-message-status.is-received { color: var(--slm-primary); }

.slm-empty-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  color: var(--slm-text-muted);
}
.slm-empty-thread h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--slm-text);
  margin: 12px 0 8px;
}
.slm-empty-thread p { margin: 4px 0; font-size: 14px; max-width: 380px; }
.slm-empty-rule {
  margin-top: 16px !important;
  padding: 8px 14px;
  background: var(--slm-success-soft);
  color: #065f46;
  border-radius: var(--slm-radius-pill);
  font-size: 12px !important;
  font-weight: 600;
}
.slm-empty-thread .slm-empty-illu { font-size: 56px; }

/* ── Composer ── */
.slm-composer {
  border-top: 1px solid var(--slm-card-border);
  padding: 14px 18px;
  background: var(--slm-card);
  flex-shrink: 0;
}
.slm-composer-fields {
  position: relative !important;
  display: block !important;
  background: var(--slm-bg);
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-lg);
  padding: 8px 120px 8px 14px !important; /* 120px réservés à droite pour le bouton, blindé contre les CSS du thème */
  transition: all .2s ease;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
}
.slm-composer-fields:focus-within {
  border-color: var(--slm-primary);
  box-shadow: 0 0 0 3px var(--slm-primary-soft);
  background: var(--slm-card);
}
.slm-composer textarea {
  display: block;
  width: 100%;
  min-width: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--slm-text);
  padding: 0;
  max-height: 160px;
  min-height: 26px;
  font-family: inherit;
  box-sizing: border-box;
}
.slm-composer { min-width: 0; box-sizing: border-box; max-width: 100%; }

/* Bouton Envoyer : ancré en absolu, CENTRÉ verticalement avec la zone texte. */
.slm-composer .slm-send-btn,
.slm-shell .slm-send-btn {
  position: absolute !important;
  right: 6px !important;
  top: 50% !important;
  bottom: auto !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  z-index: 5 !important;
  margin: 0 !important;
  width: auto !important;
  max-width: 110px !important;
}
@media (max-width: 480px) {
  .slm-composer-fields { padding-right: 60px !important; }
  .slm-send-btn span { display: none; }
  .slm-shell .slm-send-btn { padding: 9px 12px !important; max-width: 52px !important; }
}
.slm-composer textarea::placeholder { color: var(--slm-text-soft); }
.slm-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slm-grad);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--slm-radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
  transition: all .15s ease;
}
.slm-send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 70, 229, .4); }
.slm-send-btn:active { transform: translateY(0); }
.slm-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.slm-composer-help {
  display: block;
  font-size: 11px;
  color: var(--slm-text-soft);
  margin-top: 8px;
  padding: 0 4px;
}

/* ── Boutons "Contacter" / liens partout ailleurs ── */
.slm-contact-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--slm-grad);
  color: #fff !important;
  text-decoration: none !important;
  padding: 10px 22px;
  border-radius: var(--slm-radius-pill);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .3);
  transition: all .2s ease;
}
.slm-contact-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(79, 70, 229, .4);
}
.slm-contact-icon { font-size: 16px; line-height: 1; }
.slm-contact-badge {
  background: #fff;
  color: var(--slm-primary);
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  padding: 2px 8px;
  border-radius: var(--slm-radius-pill);
  margin-left: 4px;
}
.slm-auto-contact-wrap {
  margin: 24px 0;
  display: flex;
  justify-content: center;
}

.slm-message-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--slm-text);
  padding: 6px 12px;
  border-radius: var(--slm-radius-pill);
  transition: all .15s ease;
  position: relative;
}
.slm-message-link:hover { background: var(--slm-primary-soft); color: var(--slm-primary); }
.slm-link-icon { font-size: 16px; }
.slm-link-badge {
  background: var(--slm-grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--slm-radius-pill);
  min-width: 20px;
  text-align: center;
}
.slm-link-badge.is-zero { background: var(--slm-card-border); color: var(--slm-text-muted); }

.slm-nav-badge {
  display: inline-block;
  background: var(--slm-grad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--slm-radius-pill);
  margin-left: 6px;
  vertical-align: middle;
}
.slm-nav-badge:empty,
.slm-nav-badge.is-zero { display: none; }

/* ── Icône enveloppe + pastille (shortcode [savvy_messenger_icon]) ── */
.slm-icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  text-decoration: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transition: background .15s ease, color .15s ease;
}
.slm-icon-link:hover { background: var(--slm-primary-soft); color: var(--slm-primary); }
.slm-icon-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--slm-grad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .4);
  line-height: 1.2;
  pointer-events: none;
  animation: slm-pulse 2s ease-in-out infinite;
}
.slm-icon-badge:empty,
.slm-icon-badge.is-zero { display: none; }

/* ── Toast notification temps réel (in-page) ── */
.slm-incoming-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 12px;
  background: var(--slm-card);
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-md);
  box-shadow: var(--slm-shadow-lg);
  text-decoration: none !important;
  color: var(--slm-text);
  max-width: 360px;
  min-width: 280px;
  animation: slm-toast-in .35s cubic-bezier(.34, 1.56, .64, 1);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.slm-incoming-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 28px 70px rgba(79, 70, 229, .22), 0 10px 28px rgba(15, 23, 42, .08);
}
.slm-incoming-toast.is-leaving {
  animation: slm-toast-out .28s ease forwards;
}
.slm-incoming-avatar {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--slm-grad);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
}
.slm-incoming-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.slm-incoming-body strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--slm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slm-incoming-body small {
  font-size: 12px;
  color: var(--slm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.slm-incoming-close {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--slm-text-soft);
  font-size: 18px;
  cursor: pointer;
  transition: all .15s ease;
}
.slm-incoming-close:hover {
  background: var(--slm-card-border);
  color: var(--slm-text);
}
@keyframes slm-toast-in {
  from { opacity: 0; transform: translateY(20px) scale(.92); }
  to   { opacity: 1; transform: none; }
}
@keyframes slm-toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(20px) scale(.92); }
}
@media (max-width: 480px) {
  .slm-incoming-toast {
    left: 12px; right: 12px; bottom: 12px;
    max-width: none;
  }
}

/* ── Masque les icônes du thème dans les boutons Contact qui ouvrent une conversation
   (généralement WorkScout : <a href="?slm_to=...&slm_context_id=..."><svg>...</svg> Contact</a>).
   On ne touche QU'AUX liens qui pointent vers une conversation spécifique (deep-link slm_*),
   pour ne pas effacer les icônes ailleurs sur le site. */
a[href*="slm_to="] > svg:first-child,
a[href*="slm_to="] > i:first-child,
a[href*="slm_to="] > .icon:first-child,
a[href*="slm_to="] > [class*="icon"]:first-child,
a[href*="slm_context_id="] > svg:first-child,
a[href*="slm_context_id="] > i:first-child,
a[href*="slm_context_id="] > .icon:first-child,
a[href*="slm_context_id="] > [class*="icon"]:first-child,
a[href*="action=slm_start_conversation"] > svg:first-child,
a[href*="action=slm_start_conversation"] > i:first-child,
a[href*="action=slm_start_conversation"] > .icon:first-child,
a[href*="action=slm_start_conversation"] > [class*="icon"]:first-child {
  display: none !important;
}

/* Et la même chose dans nos propres boutons : on retire l'enveloppe ✉ par défaut,
   les utilisateurs trouveront le mot "Contact"/"Contacter" plus net sans icône. */
.slm-contact-button .slm-contact-icon { display: none !important; }
.slm-auto-contact-wrap .slm-contact-button { padding-left: 22px; padding-right: 22px; }

/* ── Auto-injection (header public, dashboard, dropdowns) ── */
.slm-auto-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--slm-grad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .4);
  line-height: 1.2;
  pointer-events: none;
  z-index: 5;
  animation: slm-pulse 2s ease-in-out infinite;
}
.slm-auto-badge:empty,
.slm-auto-badge.is-zero { display: none; }

/* ── Login box ── */
.slm-login-box {
  max-width: 440px;
  margin: 60px auto;
  padding: 32px;
  text-align: center;
  background: var(--slm-card);
  border: 1px solid var(--slm-card-border);
  border-radius: var(--slm-radius-lg);
  box-shadow: var(--slm-shadow-md);
}
.slm-login-box h3 { margin: 0 0 8px; font-size: 22px; }
.slm-login-box p  { margin: 0 0 20px; color: var(--slm-text-muted); }

/* ── Animations ── */
@keyframes slm-fade-in   { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes slm-slide-down { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 400px; } }
@keyframes slm-bubble-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slm-bubble-pop { 0% { opacity: 0; transform: scale(.5); } 60% { transform: scale(1.05); } 100% { opacity: 1; transform: scale(1); } }
@keyframes slm-pulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(79, 70, 229, .35); }
  50%      { box-shadow: 0 2px 12px rgba(79, 70, 229, .6); }
}

/* ── Responsive ── */
@media (max-width: 880px) {
  .slm-shell { padding: 12px 8px 40px; }
  .slm-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
  }
  .slm-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .slm-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--slm-card-border);
    max-height: 320px;
  }
  .slm-panel { max-height: none; min-height: 480px; }
  .slm-message { max-width: 88%; }
  .slm-thread-header { padding: 14px 16px; }
  .slm-messages { padding: 14px 14px; }
  .slm-composer { padding: 10px 14px; }
}

@media (max-width: 480px) {
  .slm-header h2 { font-size: 22px; }
  .slm-total-badge { display: none; }
  .slm-sidebar-head { padding: 12px 14px 10px; }
  .slm-conversation { padding: 10px; }
  .slm-avatar { width: 36px; height: 36px; font-size: 13px; }
  .slm-send-btn span { display: none; }
  .slm-send-btn { padding: 9px 12px; }
}

/* ── Dashboard direct link ── */
.slm-dashboard-direct-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── Utilitaires accessibilité ── */
.screen-reader-text {
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px; height: 1px;
  overflow: hidden;
}
