/* <Widget> — page-embeddable canvas widget.
   Mirrors the canvas WidgetChrome selection outline + drag/select handle,
   minus the action menu. */

.widget {
  display: inline-block;
  position: relative;
  max-width: 100%;
}

.chromeContainer {
  position: relative;
}

.draggable {
  user-select: none;
}

/* Widget slot — selection outline targets this. */
.widgetSlot {
  position: relative;
  border-radius: 4px;
}

.widgetSlotSelected {
  outline: 4px solid var(--color-background-accent-emphasis, #2f81f7);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Toolbar — absolutely positioned below the widget so it never affects the
   widget's box dimensions. */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 28px;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
}

/* Invisible hit-area bridging the 10px gap so hover survives the pointer
   crossing the padding between the widget and its handle. */
.toolbar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 10px;
  pointer-events: auto;
}

/* Trigger dot — visible at rest, hidden once the handle is revealed. */
.triggerDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border-muted, #d0d7de);
  opacity: 0.5;
  margin-left: auto;
  transition: opacity 120ms;
}

:global([data-sb-canvas-theme^='dark']) .triggerDot {
  background: var(--color-border-muted, #373e47);
  opacity: 0.6;
}

.triggerDotHidden {
  opacity: 0;
  pointer-events: none;
}

/* Toolbar content — holds the select handle. */
.toolbarContent {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms;
}

.toolbarContentVisible {
  opacity: 1;
  pointer-events: auto;
}

/* Select handle — rounded rect. Click selects; drag (when draggable) moves. */
.selectHandle {
  all: unset;
  cursor: pointer;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.6px solid var(--color-border-muted, #d0d7de);
  background: var(--color-background, #ffffff);
  transition: background 100ms, border-color 100ms;
  flex-shrink: 0;
}

.selectHandleDraggable {
  cursor: grab;
}

.selectHandleDraggable:active {
  cursor: grabbing;
}

:global([data-sb-canvas-theme^='dark']) .selectHandle {
  background: var(--color-background-muted, #161b22);
  border-color: var(--color-border-muted, #373e47);
}

.selectHandle:hover {
  border-color: var(--color-background-accent-emphasis, #2f81f7);
}

.selectHandleActive,
:global([data-sb-canvas-theme^='dark']) .selectHandleActive {
  background: var(--color-background-accent-emphasis, #2f81f7);
  border-color: var(--color-background-accent-emphasis, #2f81f7);
}

.selectHandleActive:hover,
:global([data-sb-canvas-theme^='dark']) .selectHandleActive:hover {
  background: var(--color-background-accent-emphasis, #388bfd);
  border-color: var(--color-background-accent-emphasis, #388bfd);
}
