/* Inspector styles — qi-* prefix */

/* Toggle button */
.qi-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: var(--control-lg);
  height: var(--control-md);
  border-radius: var(--radius-md);
  /* The old fallbacks (#333, #888) never applied — the variables are always
     defined — and the real values fail AA: #737373 on --surface is 3.89:1
     and a #262626 border is 1.22:1, so the control read as plain text. */
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  padding: 0 var(--space-2);
  font-size: var(--font-sm);
  font-family: inherit;
  white-space: nowrap;
}
.qi-btn__label { display: inline; }
.qi-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.qi-btn--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft-2);
  box-shadow: 0 0 8px var(--accent-soft-2);
}
.qi-btn--has-selection {
  background: var(--accent-soft-2);
}

/* Overlay — positioned inside .ws-preview */
.qi-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 100;
  display: none;
  will-change: transform;
  box-sizing: border-box;
}
.qi-overlay--hover {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-xs);
}
.qi-overlay--selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 2px var(--ring-light), 0 0 12px var(--accent-glow);
  background: var(--accent-soft);
  border-radius: var(--radius-xs);
}
.qi-overlay__tag {
  position: absolute;
  top: -24px;
  left: 0;
  background: var(--accent);
  /* White on --accent is 2.54:1. This label sits over the client's own page,
     which is light, so it is the one piece of inspector chrome that is always
     on a bright background. Dark ink on the same green gives ~9:1. */
  color: var(--on-accent-dark);
  font-size: var(--font-sm);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
  line-height: 1.4;
}

/* Selected element — a card inside the composer frame, not a floating pill.
   A pill reads as a filter; this is an attachment to the request, and its
   quick actions belong to it, so they live inside it. */
.qi-card-area {
  padding: var(--space-2) var(--space-3) 0;
}
.qi-card-area[hidden] { display: none; }
.qi-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-2);
  border-radius: var(--radius-md);   /* one step inside the field's --radius-lg */
  background: var(--bg);             /* same surface as the textarea */
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-md);
}

/* The snapshot is the thing a non-technical owner actually recognises, so it
   gets real size — 32x24 was decoration. Space is reserved up front to stop
   the card jumping when the async capture lands. */
.qi-card__snap {
  flex-shrink: 0;
  width: 64px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.qi-card__snap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.qi-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qi-card__name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qi-card__where {
  color: var(--text-dim);
  font-size: var(--font-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qi-card__where:empty { display: none; }

.qi-card__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  min-width: 24px;
  min-height: 24px;
  font-size: var(--font-base);
  line-height: 1;
  flex-shrink: 0;
}
.qi-card__close:hover { color: var(--text); }

/* Already sent: the element stays attached so a follow-up like "now make it
   bigger" still lands on it, but it steps back visually. */
.qi-card--sent {
  border-left-color: var(--text-dim);
  opacity: 0.75;
}
.qi-card--sent .qi-card__hint { display: block; }

/* The element was removed or rebuilt while it was still attached. */
.qi-card--stale {
  border-left-color: var(--warning);
  opacity: 0.75;
}
.qi-card--stale .qi-card__hint { display: block; color: var(--warning-text, var(--warning)); }
/* The selected element is on another page than the one in the preview. */
.qi-card__other { font-size: var(--font-sm); color: var(--text-dim); margin-top: 2px; }
.qi-card__other button { border: none; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.qi-card__hint {
  display: none;
  color: var(--text-dim);
  font-size: var(--font-sm);
}

/* Once the client starts typing the actions have done their job; collapsing
   them hands the height back to the conversation. */
.qi-card--compact .qi-actions,
.qi-card--compact .qi-card__where { display: none; }
.qi-card--compact .qi-card__snap { width: 40px; height: 30px; }

/* Quick Actions — inside the card */
.qi-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qi-actions__item {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-sm);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  /* Same dead-fallback problem as .qi-btn: #737373 text on --bg is 4.18:1
     and a #262626 border is 1.31:1, so these read as labels, not buttons. */
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-size: var(--font-md);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.1s ease, border-color 0.1s ease, background 0.1s ease;
  white-space: nowrap;
}
.qi-actions__item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.qi-actions__item:active {
  background: var(--accent-soft-2);
}
/* Deleting was styled exactly like renaming, sat in the same row and carried
   a finished command, so one tap plus Enter removed a section for good. */
.qi-actions__item--danger {
  margin-left: auto;
  color: var(--error-text, var(--error-text));
  border-color: transparent;
}
.qi-actions__item--danger:hover,
.qi-actions__item--danger:active {
  color: var(--error-text, var(--error-text));
  border-color: var(--error);
  background: var(--error-bg, var(--error-soft));
}

/* Mobile: hide button label, keep icon */
@media (max-width: 600px) {
  .qi-btn { padding: 0; min-width: var(--control-md); width: var(--control-md); }
  .qi-btn__label { display: none; }
  .qi-overlay__tag {
    font-size: var(--font-xs);
    max-width: 140px;
  }
  .qi-card { font-size: var(--font-md); }
  .qi-card__close { min-width: var(--control-lg); min-height: var(--control-lg); }
  .qi-card__snap { width: 56px; height: 42px; }

  /* Wrapping put a second row under the first — often holding nothing but the
     destructive action — and every extra row pushes the input toward the
     keyboard. One scrollable row keeps the height fixed and the targets big. */
  .qi-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
  }
  .qi-actions::-webkit-scrollbar { display: none; }
  .qi-actions__item {
    min-height: var(--control-lg);
    scroll-snap-align: start;
    flex-shrink: 0;
  }
  .qi-onboarding {
    white-space: normal;
    max-width: 200px;
    text-align: center;
    left: auto;
    right: 0;
    transform: none;
  }
  .qi-onboarding::before {
    left: auto;
    right: 12px;
    transform: none;
  }
}

/* Inspector pick mode: floating cancel button on mobile */
.qi-pick-fab {
  display: none; position: fixed; left: 50%; transform: translateX(-50%);
  /* Cleared the tab bar by 24px: at bottom:24px it sat on top of it, and on a
     handset with a home indicator it covered the Site/Chat labels outright. */
  bottom: calc(24px + 43px + var(--sab));
  z-index: 1001; padding: 10px 24px; border-radius: var(--radius-full);
  border: 1px solid var(--accent); background: var(--bg-translucent); color: var(--accent);
  font-size: var(--font-base); font-weight: 500; cursor: pointer; font-family: inherit;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.qi-pick-fab.visible { display: block; }

/* Onboarding tooltip */
.qi-onboarding {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--on-accent-dark); /* white on --accent is 2.54:1 */
  font-size: var(--font-md);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  z-index: 200;
  animation: qiTipIn 0.3s ease-out;
  pointer-events: none;
  box-shadow: 0 4px 12px var(--accent-soft-2);
  font-family: inherit;
}
.qi-onboarding::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--accent);
  border-top: 0;
}
@keyframes qiTipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .qi-btn,
  .qi-overlay,
  .qi-actions__item,
  .qi-onboarding {
    transition: none;
    animation: none;
  }
}
