/* =============================================================================
   tools-menu.css : pastille « Outils » (barre globale) + modale des tools WebMCP
   -----------------------------------------------------------------------------
   La pastille vit dans la barre sombre (texte clair). La modale est un menu
   deroulant ancre en haut a droite : une entree par tool, (i) en infobulle,
   chevron > pour derouler les prompts de test. Reutilise les tokens du DS.
   ========================================================================== */

/* --- Pastille dans la barre globale --------------------------------------- */
.app-topbar__tools {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--rs-radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit; font-size: var(--rs-fs-sm); font-weight: 700;
  cursor: pointer;
  transition: background var(--rs-dur-fast) var(--rs-ease),
              border-color var(--rs-dur-fast) var(--rs-ease);
}
.app-topbar__tools:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.5); }
.app-topbar__tools:focus-visible { outline: 2px solid var(--rs-main); outline-offset: 2px; }
.app-topbar__tools .tm-pill__icon { width: 16px; height: 16px; flex-shrink: 0; }
.app-topbar__tools .tm-pill__count {
  min-width: 18px; padding: 0 5px;
  border-radius: var(--rs-radius-pill);
  background: var(--rs-main); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}

/* --- Overlay + panneau ----------------------------------------------------- */
.tm-overlay {
  position: fixed; inset: 0;
  z-index: 200; /* au-dessus des tooltips (120) */
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 64px 16px 16px;
  background: rgba(22, 34, 46, 0.42);
  backdrop-filter: blur(2px);
}
.tm-overlay[hidden] { display: none; }

/* Largeur calee sur le PIRE cas de nom d'outil (compare_total_cost_of_ownership,
   31 caracteres en JetBrains Mono) + ses deux badges + le compteur + le (i) :
   a 440px la colonne du nom tombait sous 120px et tous les noms longs
   s'affichaient tronques (« search_catal… »), ce que la modale est justement
   censee montrer. */
.tm-panel {
  display: flex; flex-direction: column;
  width: min(680px, 96vw);
  max-height: min(78vh, 760px);
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: var(--rs-radius-lg);
  box-shadow: var(--rs-shadow-lg);
  overflow: hidden;
  animation: tm-pop var(--rs-dur-fast, 0.16s) var(--rs-ease, ease) both;
}
@keyframes tm-pop { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }

/* --- En-tete --------------------------------------------------------------- */
/* Gouttiere horizontale de 20px, commune a l'en-tete, au filtre et aux titres de
   groupe de la liste (16px de .tm-list + 4px de .tm-group__label) : le titre et
   le sous-titre ne sont plus colles au bord et se calent sur la meme verticale
   que les rubriques en dessous. */
.tm-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rs-line);
}
.tm-head__titles { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.tm-head__title { font-size: var(--rs-fs-md, 1rem); font-weight: 800; color: var(--rs-secondary); }
.tm-head__sub { font-size: var(--rs-fs-xs); color: var(--rs-muted); line-height: 1.35; }
.tm-head__count {
  flex-shrink: 0; align-self: center;
  padding: 3px 9px; border-radius: var(--rs-radius-pill);
  background: var(--rs-surface-2); color: var(--rs-ink-soft, #5b6b78);
  font-size: var(--rs-fs-xs); font-weight: 700; white-space: nowrap;
}
.tm-close {
  flex-shrink: 0;
  border: none; background: transparent; cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--rs-radius-pill);
  color: var(--rs-muted); font-size: 15px; line-height: 1;
  transition: background var(--rs-dur-fast) var(--rs-ease), color var(--rs-dur-fast) var(--rs-ease);
}
.tm-close:hover { background: var(--rs-surface-2); color: var(--rs-ink); }

/* --- Filtre ---------------------------------------------------------------- */
.tm-filter { padding: 10px 20px; border-bottom: 1px solid var(--rs-line); }
.tm-filter__input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--rs-line); border-radius: var(--rs-radius-pill);
  background: var(--rs-surface-2);
  font-family: inherit; font-size: var(--rs-fs-sm); color: var(--rs-ink);
}
.tm-filter__input:focus { outline: none; border-color: var(--rs-main); box-shadow: 0 0 0 3px var(--rs-main-100); }

/* --- Liste scrollable ------------------------------------------------------ */
.tm-list { overflow-y: auto; padding: 10px 16px 14px; }
.tm-empty { padding: var(--rs-sp-3); text-align: center; color: var(--rs-muted); font-style: italic; font-size: var(--rs-fs-sm); }

.tm-group + .tm-group { margin-top: 10px; }
.tm-group__label {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 4px 6px;
  font-size: var(--rs-fs-xs); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--rs-muted);
}
.tm-group__icon { font-size: 14px; line-height: 1; filter: saturate(0.9); }

/* --- Une entree de tool ---------------------------------------------------- */
.tm-tool { border-radius: var(--rs-radius); }
.tm-tool.is-open { background: var(--rs-surface-2); }

.tm-tool__head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px;
  border: none; background: transparent;
  text-align: left; cursor: pointer;
  border-radius: var(--rs-radius);
  transition: background var(--rs-dur-fast) var(--rs-ease);
}
.tm-tool__head:hover { background: var(--rs-main-100); }
.tm-tool__chevron {
  flex-shrink: 0; width: 14px;
  color: var(--rs-muted); font-weight: 800;
  transition: transform var(--rs-dur-fast) var(--rs-ease);
}
.tm-tool.is-open .tm-tool__chevron { transform: rotate(90deg); color: var(--rs-main); }
/* Le nom du tool est l'information principale de la ligne : il ne se comprime
   pas et ne se tronque pas (plus d'ellipsis). Ce sont les badges qui cedent la
   place si l'ecran est etroit. */
.tm-tool__name {
  flex: 0 0 auto;
  font-family: var(--rs-font-mono, 'JetBrains Mono', monospace);
  font-size: var(--rs-fs-sm); font-weight: 700; color: var(--rs-secondary);
  white-space: nowrap;
}
.tm-tool__badges { display: inline-flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.tm-tool__nb {
  flex-shrink: 0;
  min-width: 18px; padding: 0 5px;
  border-radius: var(--rs-radius-pill);
  background: var(--rs-secondary); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}

/* Badges (lecture/ecriture, statut de source) */
.tm-badge {
  padding: 1px 7px; border-radius: var(--rs-radius-pill);
  font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
  text-transform: uppercase; white-space: nowrap;
}
.tm-badge--read  { background: var(--rs-surface-2); color: var(--rs-muted); }
.tm-badge--write { background: #fbe6da; color: #b14a1f; }
.tm-badge--sensitive { background: #fdecea; color: #8f1d17; }
.tm-badge--mode  { color: #fff; }
.tm-mode--live   { background: var(--rs-main); }
.tm-mode--cached { background: #4b78b8; }
.tm-mode--rag    { background: #7a5cc0; }
.tm-mode--internal { background: #3a8f6e; }
.tm-mode--mock   { background: #9aa6b2; }

/* (i) infobulle */
.tm-info {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: var(--rs-radius-pill);
  border: 1px solid var(--rs-line);
  color: var(--rs-muted); background: var(--rs-surface);
  font-size: 11px; font-weight: 800; font-style: normal; cursor: help;
}
.tm-info:hover, .tm-info:focus-visible { color: var(--rs-main); border-color: var(--rs-main); outline: none; }

/* --- Tiroir des prompts de test ------------------------------------------- */
.tm-prompts { padding: 2px 8px 8px 30px; }
.tm-prompts__label {
  padding: 4px 4px 6px;
  font-size: var(--rs-fs-xs); font-weight: 700; color: var(--rs-muted);
}
.tm-prompts__none { padding: 4px 4px 8px; font-size: var(--rs-fs-xs); color: var(--rs-muted); font-style: italic; }

/* Les prompts sont des EXEMPLES a lire, pas des commandes : ni curseur main, ni
   survol, ni barre « deja vu ». Cliquer dessus lancait un scenario en dehors du
   rail, ce qui sortait l'utilisateur de son parcours sans prevenir. */
.tm-prompt {
  display: flex; align-items: flex-start; gap: 7px; width: 100%;
  padding: 7px 9px;
  border-radius: var(--rs-radius-sm);
  background: var(--rs-surface);
  text-align: left;
  font-family: inherit; font-size: var(--rs-fs-sm); color: var(--rs-ink);
}
.tm-prompt + .tm-prompt { margin-top: 2px; }
.tm-prompt__dot { flex-shrink: 0; color: var(--rs-main); font-size: 11px; line-height: 1.5; }
.tm-prompt__text { line-height: 1.35; }

@media (max-width: 720px) {
  .tm-overlay { padding: 56px 8px 8px; justify-content: center; }
  .tm-panel { width: 100%; max-height: 84vh; }
}
