/* ── Tool Settings Panel ────────────────────────────────── */

.tools-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.tools-modal {
  background: rgba(15, 15, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.tools-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.tools-modal-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.tools-modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
}
.tools-modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tools-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 1rem 1.5rem 1.5rem;
}

/* Server status bar */
.tools-server-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  margin-bottom: 1.25rem;
}

.tools-server-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  cursor: default;
  border: 1px solid transparent;
}

.tools-server-chip.connected {
  background: rgba(52, 199, 89, 0.12);
  border-color: rgba(52, 199, 89, 0.3);
  color: #34c759;
}

.tools-server-chip.disconnected {
  background: rgba(255, 59, 48, 0.1);
  border-color: rgba(255, 59, 48, 0.25);
  color: rgba(255, 100, 90, 0.9);
}

.tools-server-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.connected .tools-server-dot { background: #34c759; }
.disconnected .tools-server-dot { background: #ff3b30; }

/* Mini rows */
.tools-mini-row {
  margin-bottom: 1.25rem;
}

.tools-mini-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

.tools-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.tools-mini-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.tools-mini-role {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
}

.tools-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-left: 2.375rem;
}

.tools-chip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.625rem;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  transition: background 0.15s, border-color 0.15s;
}

.tools-chip.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  color: rgba(160, 163, 255, 0.95);
}

.tools-chip-remove {
  background: none;
  border: none;
  color: rgba(255, 100, 90, 0.7);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-left: 0.125rem;
  transition: color 0.15s;
}
.tools-chip-remove:hover { color: #ff3b30; }

/* Setup required badge */
.tools-chip.setup-required {
  background: rgba(255, 149, 0, 0.1);
  border-color: rgba(255, 149, 0, 0.3);
  color: rgba(255, 180, 60, 0.9);
}

/* Add tool button */
.tools-add-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.625rem;
  border-radius: 100px;
  background: none;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.15s;
}
.tools-add-btn:hover {
  border-color: rgba(99, 102, 241, 0.5);
  color: rgba(160, 163, 255, 0.9);
  background: rgba(99, 102, 241, 0.1);
}

/* Add tool dropdown */
.tools-add-dropdown {
  position: relative;
  display: inline-flex;
}

.tools-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: rgba(20, 20, 40, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  min-width: 200px;
  z-index: 400;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: none;
}
.tools-add-menu.open { display: block; }

.tools-add-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}
.tools-add-menu-item:hover { background: rgba(99, 102, 241, 0.15); color: #fff; }
.tools-add-menu-item.disabled { opacity: 0.4; cursor: default; pointer-events: none; }

.tools-add-menu-item-icon { font-size: 0.9rem; }
.tools-add-menu-item-name { flex: 1; font-weight: 500; }
.tools-add-menu-item-status {
  font-size: 0.65rem;
  color: rgba(255, 180, 60, 0.8);
  font-weight: 500;
}

.tools-mini-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin: 1rem 0;
}

.tools-empty-mini {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
  padding-left: 2.375rem;
}

/* Loading / error states */
.tools-loading {
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

/* ── MiniCard tool chips strip ──────────────────────────── */

.mini-card-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 8px;
  padding: 4px 2px;
  transition: background 0.15s;
}

.mini-card-tools:hover {
  background: rgba(255, 255, 255, 0.04);
}

.mini-card-tools-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.mini-card-tool-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 100px;
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.20);
  color: rgba(160, 163, 255, 0.85);
  white-space: nowrap;
}

/* ── MiniSelector inline tool section ───────────────────── */

.ms-tools-section {
  flex-basis: 100%;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  /* indent past accent + gap + avatar + gap */
  padding: 10px 14px 12px 79px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
}

.ms-tools-section.visible {
  display: flex;
  animation: tools-reveal 0.25s ease both;
}

@keyframes tools-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ms-tools-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.ms-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.ms-tool-chip:hover {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.ms-tool-chip:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

.ms-tool-chip.active {
  background: rgba(108, 59, 238, 0.18);
  border-color: rgba(108, 59, 238, 0.45);
  color: rgba(180, 160, 255, 0.95);
}

.ms-tool-chip.active:hover {
  background: rgba(220, 50, 50, 0.15);
  border-color: rgba(220, 50, 50, 0.4);
  color: rgba(255, 120, 120, 0.9);
}

.ms-tool-chip.unconfigured {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
  border-style: dashed;
}

@media (prefers-reduced-motion: reduce) {
  .ms-tools-section.visible {
    animation: none;
  }
  .ms-tool-chip {
    transition: none;
  }
}
