/* SendgateHero — console animée du hero (porté du composant React en vanilla).
   Tokens scopés sur .sg-console ; piloté par assets/sg-hero.js (boucle rAF). */

.sg-console {
  --sg-navy: #263B6A;
  --sg-navy-dark: #1B2C52;
  --sg-blue-gray: #6984A9;
  --sg-green: #A0D585;
  --sg-green-dark: #82BD63;
  --sg-lime: #EEFABD;
  --sg-ink: #22293B;
  --sg-muted: #6E7790;
  --sg-line: #E7E9F0;
  --sg-bg: #FCFCF8;
  --sg-section: #F4F6EC;
  --sg-card: #FFFFFF;
  --sg-success: var(--sg-green-dark);
  --sg-seg-1: #6984A9;
  --sg-seg-2: #82BD63;
  --sg-seg-3: #C58B5C;
  --sg-seg-4: #8B7AB8;
  --sg-serif: var(--sg-heading, 'Lexend Deca', Georgia, sans-serif);
  --sg-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  font-family: var(--sg-sans);
  color: var(--sg-ink);
  background: var(--sg-card);
  border-radius: 14px;
  border: 1px solid var(--sg-line);
  box-shadow: 0 24px 60px rgba(38,59,106,0.16), 0 4px 12px rgba(38,59,106,0.08);
  overflow: hidden;
}

/* Boutons (réutilisés par les boutons de la console) */
.sg-btn {
  font-family: var(--sg-sans);
  font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; border: none; cursor: pointer;
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.sg-btn-primary { background: var(--sg-navy); color: #fff; box-shadow: 0 4px 14px rgba(38,59,106,0.22); }
.sg-btn-primary:hover { background: var(--sg-navy-dark); transform: translateY(-1px); }
.sg-btn.is-disabled { background: var(--sg-line); color: var(--sg-muted); box-shadow: none; cursor: default; }

/* Top bar */
.sg-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--sg-line); background: var(--sg-card);
}
.sg-dots { display: flex; gap: 6px; }
.sg-dots span { width: 11px; height: 11px; border-radius: 50%; background: var(--sg-line); }
.sg-app-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--sg-navy); }
.sg-app-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--sg-navy); color: var(--sg-lime);
  font-family: var(--sg-serif); font-weight: 600; font-size: 14px;
}
.sg-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 20px;
  transition: background .4s ease, color .4s ease;
}
.sg-pill-dot { width: 7px; height: 7px; border-radius: 50%; transition: background .4s ease; }
.sg-pill-idle { background: var(--sg-line); color: var(--sg-muted); }
.sg-pill-idle .sg-pill-dot { background: var(--sg-muted); }
.sg-pill-connecting { background: #FFF4E0; color: #B8842A; }
.sg-pill-connecting .sg-pill-dot { background: #E0A030; animation: sg-blink 1s infinite; }
.sg-pill-connected { background: rgba(160,213,133,0.22); color: var(--sg-green-dark); }
.sg-pill-connected .sg-pill-dot { background: var(--sg-green-dark); }
/* logo de la source connectée dans le pill (affiché une fois connecté) */
.sg-pill-logo { display: none; width: 14px; height: 14px; border-radius: 3px; object-fit: contain; }
.sg-pill-connected .sg-pill-logo { display: inline-block; }

/* Sélecteur de source (scène 1) : deux ESP cliquables */
.sg-source-picker { display: flex; gap: 10px; margin-bottom: 18px; }
.sg-source-opt {
  flex: 1; display: flex; align-items: center; gap: 9px; padding: 11px 13px;
  background: var(--sg-bg); border: 1.5px solid var(--sg-line); border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--sg-ink);
  transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
}
.sg-source-opt img { width: 22px; height: 22px; object-fit: contain; border-radius: 5px; flex-shrink: 0; }
.sg-source-opt.is-selected { border-color: var(--sg-navy); background: var(--sg-card); box-shadow: 0 0 0 3px rgba(38,59,106,0.1); font-weight: 600; color: var(--sg-navy); }
.sg-source-check { margin-left: auto; color: var(--sg-green-dark); display: none; }
.sg-source-opt.is-selected .sg-source-check { display: inline-flex; }
/* libellés d'état du pill (selon la classe d'état du parent) */
.sg-pill .t-idle, .sg-pill .t-connecting, .sg-pill .t-connected { display: none; }
.sg-pill-idle .t-idle { display: inline; }
.sg-pill-connecting .t-connecting { display: inline; }
.sg-pill-connected .t-connected { display: inline; }

.sg-body { display: flex; min-height: 388px; }

/* Nav latérale */
.sg-nav {
  width: 130px; flex-shrink: 0; padding: 16px 9px;
  border-right: 1px solid var(--sg-line); background: var(--sg-bg);
  display: flex; flex-direction: column; gap: 4px;
}
.sg-nav-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--sg-muted);
  transition: background .35s ease, color .35s ease;
}
.sg-nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; color: var(--sg-line); transition: color .35s ease; }
.sg-nav-item.is-active { background: var(--sg-section); color: var(--sg-navy); font-weight: 600; }
.sg-nav-item.is-active .sg-nav-icon { color: var(--sg-navy); }
.sg-nav-item.is-done { color: var(--sg-green-dark); }
.sg-nav-item.is-done .sg-nav-icon { color: var(--sg-green); }
/* swap point ↔ check selon l'état */
.sg-nav-item .ic-check { display: none; }
.sg-nav-item.is-done .ic-check { display: inline-flex; }
.sg-nav-item.is-done .ic-dot { display: none; }

/* Panneau principal */
.sg-panel { position: relative; flex: 1; padding: 22px 24px; min-height: 388px; }
.sg-scene {
  position: absolute; inset: 22px 24px; opacity: 0; transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease; pointer-events: none;
}
.sg-scene.is-active { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sg-scene-head { font-family: var(--sg-serif); font-size: 19px; font-weight: 500; color: var(--sg-navy); margin-bottom: 18px; }

/* Champs */
.sg-field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--sg-muted); margin-bottom: 7px; }
.sg-input { background: var(--sg-bg); border: 1.5px solid var(--sg-line); border-radius: 9px; padding: 11px 14px; font-size: 14px; min-height: 20px; display: flex; align-items: center; }
.sg-input-key { gap: 10px; }
.sg-input-lock { color: var(--sg-muted); flex-shrink: 0; }
.sg-input-eye { color: var(--sg-muted); opacity: 0.55; margin-left: auto; flex-shrink: 0; }
.sg-input-text { font-family: 'SF Mono', ui-monospace, monospace; color: var(--sg-ink); }
.sg-input-masked { letter-spacing: 0.12em; font-size: 13px; }
.sg-placeholder { color: var(--sg-muted); opacity: 0.6; letter-spacing: normal; }
.sg-caret { display: inline-block; width: 2px; height: 15px; background: var(--sg-navy); margin-left: 1px; vertical-align: middle; animation: sg-blink .9s steps(2) infinite; }
/* flash « collé » sur le champ clé API (collage instantané) */
@keyframes sg-paste-flash {
  0% { box-shadow: 0 0 0 0 rgba(160,213,133,0); border-color: var(--sg-line); }
  25% { box-shadow: 0 0 0 4px rgba(160,213,133,.4); border-color: var(--sg-green); }
  100% { box-shadow: 0 0 0 0 rgba(160,213,133,0); border-color: var(--sg-line); }
}
.sg-input-key.is-pasted { animation: sg-paste-flash .45s ease; }
.sg-connect { margin-top: 16px; min-width: 130px; justify-content: center; }
.sg-connect.is-done { background: var(--sg-success); }
/* libellés d'état des boutons connect / invite */
.sg-connect .st, .sg-invite-btn .st { display: none; align-items: center; gap: 7px; }
.sg-connect .st-idle, .sg-invite-btn .st-idle { display: inline-flex; }
.sg-connect.is-loading .st-idle, .sg-connect.is-done .st-idle,
.sg-invite-btn.is-loading .st-idle, .sg-invite-btn.is-done .st-idle { display: none; }
.sg-connect.is-loading .st-loading, .sg-invite-btn.is-loading .st-loading { display: inline-flex; }
.sg-connect.is-done .st-done, .sg-invite-btn.is-done .st-done { display: inline-flex; }

/* Label de synchronisation (étape 2) */
.sg-sync-label { display: none; align-items: center; gap: 6px; margin-left: 12px; font-family: var(--sg-sans); font-size: 12px; font-weight: 500; color: var(--sg-blue-gray); vertical-align: middle; }
.sg-scene.is-loading .sg-sync-label { display: inline-flex; }
.sg-sync-label .sg-ico { width: 12px; height: 12px; }

/* Listes segments — skeleton vs lignes (pilotées par .is-loading) */
.sg-seg-skel-list { display: none; flex-direction: column; gap: 8px; }
.sg-scene.is-loading .sg-seg-skel-list { display: flex; }
.sg-scene.is-loading .sg-seg-list { display: none; }
.sg-seg-skeleton { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--sg-bg); border: 1px solid var(--sg-line); border-radius: 9px; }
.sg-seg-skeleton .sk-dot, .sg-seg-skeleton .sk-bar, .sg-seg-skeleton .sk-count {
  background: linear-gradient(90deg, var(--sg-line) 25%, #EEF0F6 50%, var(--sg-line) 75%);
  background-size: 200% 100%; animation: sg-shimmer 1.3s ease-in-out infinite; animation-delay: calc(0.1s * var(--i)); border-radius: 4px;
}
.sg-seg-skeleton .sk-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sg-seg-skeleton .sk-bar { height: 11px; width: 42%; }
.sg-seg-skeleton .sk-count { height: 11px; width: 44px; margin-left: auto; }

.sg-seg-list { display: flex; flex-direction: column; gap: 8px; }
.sg-seg-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--sg-bg); border: 1px solid var(--sg-line); border-radius: 9px; opacity: 0; transform: translateX(-8px); }
.sg-scene.is-active:not(.is-loading) .sg-seg-row { animation: sg-row-in .4s ease forwards; animation-delay: calc(0.12s * var(--i)); }
.sg-seg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sg-seg-name { font-size: 14px; font-weight: 500; color: var(--sg-ink); }
.sg-seg-count { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--sg-muted); font-variant-numeric: tabular-nums; }

/* Attribution par dropdown (étape 3) */
.sg-dropdown-list { display: flex; flex-direction: column; gap: 8px; }
.sg-drow { display: flex; align-items: center; gap: 11px; padding: 11px 12px; background: var(--sg-card); border: 1.5px solid var(--sg-line); border-radius: 10px; transition: border-color .25s ease, box-shadow .25s ease, background .25s ease; }
.sg-drow.is-open { border-color: var(--sg-blue-gray); box-shadow: 0 4px 16px rgba(38,59,106,0.1); position: relative; z-index: 5; }
.sg-drow.is-assigned { border-color: var(--sg-green); background: rgba(160,213,133,0.06); }
.sg-drow-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sg-select-name { font-weight: 600; color: var(--sg-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.sg-select-count { font-size: 11px; font-weight: 500; color: var(--sg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.3; }
.sg-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.sg-dd { position: relative; flex-shrink: 0; }
.sg-dd-trigger { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; min-width: 124px; background: var(--sg-bg); border: 1.5px solid var(--sg-line); border-radius: 8px; font-family: var(--sg-sans); font-size: 12.5px; font-weight: 500; color: var(--sg-ink); cursor: pointer; transition: border-color .2s ease, background .2s ease, box-shadow .2s ease; }
.sg-dd-trigger.is-active { border-color: var(--sg-navy); box-shadow: 0 0 0 3px rgba(38,59,106,0.1); background: var(--sg-card); }
.sg-dd-trigger.is-picked { border-color: var(--sg-green); background: var(--sg-card); color: var(--sg-navy); font-weight: 600; }
.sg-dd-placeholder { color: var(--sg-muted); }
.sg-dd-chevron { margin-left: auto; color: var(--sg-muted); transition: transform .25s ease; }
.sg-drow.is-open .sg-dd-chevron { transform: rotate(180deg); }
.sg-dd-team-avatar { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; background: var(--sg-navy); color: #fff; font-size: 10px; font-weight: 600; flex-shrink: 0; }
/* libellé du trigger : sélection vs placeholder */
.sg-dd-trigger .dd-pick { display: none; align-items: center; gap: 6px; }
.sg-dd-trigger.is-picked .dd-pick { display: inline-flex; }
.sg-dd-trigger.is-picked .dd-ph { display: none; }

.sg-dd-menu { display: none; position: absolute; top: calc(100% + 5px); right: 0; min-width: 100%; background: var(--sg-card); border: 1.5px solid var(--sg-line); border-radius: 9px; box-shadow: 0 12px 30px rgba(38,59,106,0.18); padding: 4px; z-index: 25; }
.sg-drow.is-open .sg-dd-menu { display: block; animation: sg-dd-in .18s ease; }
.sg-dd-option { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--sg-ink); white-space: nowrap; cursor: pointer; transition: background .15s ease; }
.sg-dd-option.is-hover { background: var(--sg-section); }

/* Invitation (étape 4) */
.sg-invite-form { background: var(--sg-card); border: 1.5px solid var(--sg-line); border-radius: 11px; padding: 14px; box-shadow: 0 4px 16px rgba(38,59,106,0.06); }
.sg-field-label-mt { margin-top: 11px; }
.sg-input-email { background: var(--sg-bg); }
.sg-group-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.sg-group-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 7px; background: var(--sg-bg); border: 1.5px solid var(--sg-line); border-radius: 9px; font-size: 12.5px; font-weight: 500; color: var(--sg-ink); cursor: pointer; transition: border-color .25s ease, background .25s ease, box-shadow .25s ease; }
.sg-group-chip.is-picked { border-color: var(--sg-navy); background: rgba(38,59,106,0.05); box-shadow: 0 0 0 3px rgba(38,59,106,0.1); }
.sg-group-avatar { display: inline-flex; align-items: center; justify-content: center; width: 21px; height: 21px; border-radius: 6px; background: var(--sg-navy); color: #fff; font-size: 10.5px; font-weight: 600; flex-shrink: 0; }
.sg-group-avatar-sm { width: 19px; height: 19px; font-size: 10px; border-radius: 5px; }
.sg-group-chip-check { display: none; color: var(--sg-green-dark); }
.sg-group-chip.is-picked .sg-group-chip-check { display: inline-flex; animation: sg-pop .3s cubic-bezier(.34,1.56,.64,1); }
.sg-group-chip-check .sg-ico { width: 13px; height: 13px; }
.sg-invite-btn { margin-top: 12px; width: 100%; justify-content: center; }
.sg-invite-btn.is-done { background: var(--sg-success); }

/* Toast */
.sg-toast { position: absolute; left: 0; right: 0; bottom: 0; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--sg-navy); color: #fff; font-size: 13px; font-weight: 500; border-radius: 9px; box-shadow: 0 8px 24px rgba(38,59,106,0.28); opacity: 0; transform: translateY(8px); transition: opacity .4s ease, transform .4s ease; z-index: 30; }
.sg-toast .sg-ico { color: var(--sg-green); }
.sg-toast.is-show { opacity: 1; transform: translateY(0); }

/* Icônes & spinner */
.sg-ico { flex-shrink: 0; }
.sg-spin { animation: sg-rotate .8s linear infinite; }

/* Keyframes */
@keyframes sg-blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@keyframes sg-rotate { to { transform: rotate(360deg); } }
@keyframes sg-row-in { to { opacity: 1; transform: translateX(0); } }
@keyframes sg-pop { 0% { opacity: 0; transform: scale(0.7); } 60% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes sg-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes sg-dd-in { 0% { opacity: 0; transform: translateY(-4px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }

/* Responsive */
@media (max-width: 900px) {
  .sg-body { min-height: 300px; }
  .sg-nav { width: 52px; padding: 12px 6px; }
  .sg-nav-item { justify-content: center; font-size: 0; gap: 0; padding: 10px; }
  .sg-nav-item .sg-nav-icon { font-size: initial; }
  .sg-dd-trigger { min-width: 108px; }
}
@media (max-width: 520px) {
  .sg-panel { padding: 18px 16px; }
  .sg-scene { inset: 18px 16px; }
  .sg-drow { flex-wrap: wrap; }
  .sg-dd { width: 100%; }
  .sg-dd-trigger { width: 100%; }
}

/* Reduced motion : la boucle est désactivée par le JS (état final figé) */
@media (prefers-reduced-motion: reduce) {
  .sg-seg-row { opacity: 1; transform: none; animation: none; }
  .sg-seg-skeleton .sk-dot, .sg-seg-skeleton .sk-bar, .sg-seg-skeleton .sk-count { animation: none; }
  .sg-caret, .sg-spin, .sg-pill-connecting .sg-pill-dot, .sg-input-key.is-pasted { animation: none; }
  .sg-scene { transition: none; }
  .sg-drow.is-open .sg-dd-menu { animation: none; }
  .sg-dd-chevron { transition: none; }
  .sg-group-chip.is-picked .sg-group-chip-check { animation: none; }
}
