/* ── Dante AI Widget, widget.css ────────────────────────────────────────── */
/* All visual styling for the embed. No agent-specific colors here,          */
/* those come from --dante-brand injected by embed.js at runtime.             */

/* ── Reset ───────────────────────────────────────────────────────────────── */
.dante-launcher,
.dante-panel-wrap,
.dante-panel-iframe,
.dante-skeleton,
.dante-skeleton * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

/* ── Launcher button ─────────────────────────────────────────────────────── */
.dante-launcher {
  --dante-brand: #1a1a1a;
  /* Inline CSS on the button overrides this once the config loads, the
   * fallback keeps the inline SVGs visible on a dark circle before first
   * paint / while config is still loading. */
  --dante-icon: #ffffff;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--dante-brand);
  border: none;
  cursor: pointer;
  z-index: 2147483646;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  transition: background 0.4s ease, transform 0.2s ease, box-shadow 0.2s ease,
    opacity 0.2s ease;
  color: var(--dante-icon);
  padding: 0;
  outline: none;
}

.dante-launcher:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.dante-launcher:active {
  transform: scale(0.96);
}

/* Loading state: stay invisible until applyConfig() paints the real colors
 * and icon. Without this the launcher flashes the #1a1a1a fallback and the
 * generic chat SVG for ~100ms-1s, which reads as a bug to end users. The
 * --loading class is set on create and removed once the config fetch
 * resolves (success or failure). */
.dante-launcher--loading {
  opacity: 0;
  pointer-events: none;
  box-shadow: none;
  transition: none;
}

/* Open state: rotate icon */
.dante-launcher--open .dante-launcher__chat-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}
.dante-launcher--open .dante-launcher__close-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.dante-launcher__chat-icon,
.dante-launcher__close-icon {
  position: absolute;
  transition: opacity 0.2s ease, transform 0.25s ease;
  /* inherit from the button's `color` so inline SVGs stroked with
   * `currentColor` (and mask-based preset icons) tint to match. */
  color: inherit;
}
.dante-launcher__close-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

/* ── Launcher unread-count badge ─────────────────────────────────────────── */
/* Small count pill pinned to the launcher's top-right corner. Drives a
 * little extra attention to the suggested prompts when they appear; it
 * shows how many prompts are waiting and is removed the moment the panel
 * opens or the prompts are dismissed. Purely a count - no avatar, no name. */
.dante-launcher__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ef4444;
  color: #ffffff;
  border: 2px solid #ffffff;
  font:
    700 11px/1 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.dante-launcher__badge--in {
  opacity: 1;
  transform: scale(1);
}

@media (prefers-color-scheme: dark) {
  .dante-launcher__badge {
    border-color: #1a1a1a;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dante-launcher__badge {
    transition: opacity 0.15s ease !important;
    transform: none !important;
  }
}

/* ── Panel wrapper ───────────────────────────────────────────────────────── */
.dante-panel-wrap {
  position: fixed;
  bottom: 98px;
  right: 24px;
  /* QA fix 2026-05-11 #13: cap the panel width to the viewport so it
   * never overflows on narrow CSS viewports. Browser page-zoom shrinks
   * the CSS viewport (e.g., 1024px screen at 125% zoom presents ~820px
   * to CSS), and on tablets / split-screen / narrow windows the fixed
   * 400px panel previously hugged the right edge with no breathing
   * room or even spilled past the launcher. The min() drops the panel
   * to whatever fits when viewport - 48px gutter is less than 400px.
   * Mobile (<=480px) overrides this further with a near-full-width
   * layout, see the bottom of this file. */
  width: min(400px, calc(100vw - 48px));
  /* 2026-05-05: 15% reduction off the previous 874px default + responsive
   * shrink so the panel never overflows short viewports. The min() ceiling
   * keeps the desktop default at 743px on tall screens; the calc() floor
   * peels off as the viewport gets shorter than 853px (743 + 110 = 853).
   * min-height keeps it usable on tiny viewports. */
  height: min(743px, calc(100vh - 110px));
  min-height: 420px;
  max-height: 743px;
  z-index: 2147483645;
  /* start invisible + shifted down */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.dante-panel-wrap--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dante-panel-wrap--closing {
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
}

/* ── Panel iframe ────────────────────────────────────────────────────────── */
.dante-panel-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 28px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  /* Cream fallback so the brief moment between iframe insertion and the
   * panel route's React hydration doesn't show through as the host page
   * (or the OS dark theme) underneath. Matches the panel skeleton bg. */
  background: #f3f0e8;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.dante-panel-iframe--ready {
  opacity: 1;
}

/* ── Skeleton (State 2, embed.js rendered, no React) ────────────────────── */
.dante-skeleton {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  overflow: hidden;
  background: #f3f0e8;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.dante-skeleton--done {
  opacity: 0;
  pointer-events: none;
}

/* Shimmer base */
.dante-sk {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 25%,
    rgba(0, 0, 0, 0.12) 50%,
    rgba(0, 0, 0, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: dante-shimmer 1.6s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes dante-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton header */
.dante-skeleton__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-shrink: 0;
}

.dante-sk--avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes dante-shimmer-dark {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.dante-skeleton__header-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.dante-sk--line {
  height: 10px;
}

.dante-sk--line-name  { width: 80px; border-radius: 5px; }
.dante-sk--line-status { width: 52px; height: 8px; border-radius: 4px; animation-delay: 0.15s; }

/* Skeleton messages */
.dante-skeleton__messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 16px 16px;
}

.dante-sk--bubble {
  border-radius: 14px;
  height: 48px;
  flex-shrink: 0;
}

.dante-sk--bubble-agent  { align-self: flex-start; }
.dante-sk--bubble-user   { align-self: flex-end;   border-radius: 14px 14px 4px 14px; }

.dante-sk--bubble-lg { width: 72%; animation-delay: 0s;   }
.dante-sk--bubble-md { width: 52%; animation-delay: 0.2s; height: 40px; }
.dante-sk--bubble-sm { width: 60%; animation-delay: 0.1s; height: 56px; }

/* Skeleton pills */
.dante-skeleton__pills {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  flex-shrink: 0;
}

.dante-sk--pill {
  height: 30px;
  border-radius: 999px;
  flex-shrink: 0;
}

.dante-sk--pill-a { width: 110px; animation-delay: 0s;   }
.dante-sk--pill-b { width: 90px;  animation-delay: 0.1s; }
.dante-sk--pill-c { width: 78px;  animation-delay: 0.2s; }

/* Skeleton input */
.dante-skeleton__input {
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.dante-sk--input {
  height: 40px;
  border-radius: 999px;
  width: 100%;
}

/* ── Launcher tooltips ───────────────────────────────────────────────────── */
/* Floating pills anchored just above the launcher on the host page.
 * The wrapper is non-interactive so empty space between pills never
 * blocks clicks on the host site below; individual pills and the shared
 * close button re-enable pointer events. Z-index sits between launcher
 * and panel. A single dismiss-all (x) badge floats at the top-right of
 * the stack and nukes every pill at once. */
.dante-tooltips {
  --dante-brand: #1a1a1a;
  position: fixed;
  /* Anchored to the launcher column (bottom-right). The center-bottom
   * variant from PR #696 detached the pills visually from the launcher
   * and made them appear to float mid-page on tall hero layouts; Jem
   * 2026-05-07 walk-back. Right-edge matches launcher's right gutter
   * so the stack reads as belonging to the launcher; pills grow to the
   * LEFT, capped at viewport-minus-gutter. */
  right: 24px;
  bottom: 96px;
  z-index: 2147483644;
  max-width: calc(100vw - 48px);
  pointer-events: none;
  isolation: isolate;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dante-tooltips--visible {
  opacity: 1;
}

.dante-tooltips--hidden,
.dante-tooltips--leaving {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.dante-tooltips__list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.dante-tooltips__close-all {
  position: absolute;
  /* Pinned to the right edge of the stack, sitting above the topmost pill. */
  top: -28px;
  right: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  pointer-events: auto;
  z-index: 1;
}

.dante-tooltips__close-all:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.08);
}

.dante-tooltips__close-all svg {
  display: block;
}

/* Suggested-prompt pill. These are tappable questions the visitor can
 * pick - styled to look inviting and clearly clickable: generous radius,
 * a tasteful layered shadow, a left accent strip in the agent's brand
 * colour, and a small chevron affordance on the right. NOT a faux-human
 * chat message - no avatar, no sender name, no timestamp. */
.dante-tooltip {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: flex-end;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 13px 16px 13px 18px;
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.05);
  /* Left accent strip tints the pill edge with the agent brand colour so
   * the prompts read as "from this widget" without impersonating a sender. */
  border-left: 3px solid var(--dante-brand, #1a1a1a);
  border-radius: 16px;
  font:
    500 14px/1.4 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Apple Color Emoji",
    "Segoe UI Emoji",
    "Noto Color Emoji",
    sans-serif;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  /* Layered shadow gives the prompts real lift off the host page so they
   * catch the eye - the stacked deck reads as a tidy set of cards. */
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.06);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition:
    opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.15s ease,
    box-shadow 0.15s ease;
}

/* Chevron affordance - makes each pill read as clearly tappable. */
.dante-tooltip__chevron {
  flex-shrink: 0;
  color: var(--dante-brand, #1a1a1a);
  opacity: 0.65;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* Per-pill reveal class. embed.js appends pills to the stack one at a
 * time and toggles `--in` on each, so each pill fades in on arrival
 * (rather than the whole stack appearing at once). */
.dante-tooltip--in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dante-tooltip:hover {
  background: #fafafa;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.14),
    0 3px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px) scale(1);
}

.dante-tooltip:hover .dante-tooltip__chevron {
  opacity: 1;
  transform: translateX(2px);
}

.dante-tooltip:active {
  transform: translateY(0) scale(0.98);
}

/* Dark host pages: the prompts sit on the visitor's site, so they track
 * the OS colour scheme rather than the operator's panel theme. */
@media (prefers-color-scheme: dark) {
  .dante-tooltip {
    background: #2a2a2e;
    color: #f4f4f5;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
      0 6px 22px rgba(0, 0, 0, 0.5),
      0 2px 6px rgba(0, 0, 0, 0.4);
  }

  /* The dark pill flips background + text to light, but the chevron kept the
     dark brand color, leaving the arrow invisible on the dark pill. Override
     it to light so it reads on every dark-mode visitor's launcher. */
  .dante-tooltip__chevron {
    color: #f4f4f5;
    opacity: 0.75;
  }

  .dante-tooltip:hover {
    background: #34343a;
    box-shadow:
      0 10px 30px rgba(0, 0, 0, 0.6),
      0 3px 8px rgba(0, 0, 0, 0.5);
  }

  .dante-tooltips__close-all {
    background: rgba(255, 255, 255, 0.22);
    color: #1a1a1a;
  }

  .dante-tooltips__close-all:hover {
    background: rgba(255, 255, 255, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dante-tooltips,
  .dante-tooltip,
  .dante-tooltip__chevron,
  .dante-tooltips__close-all {
    transition: opacity 0.15s ease !important;
    transform: none !important;
  }
}

/* ── Responsive: mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dante-panel-wrap {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 84px;
    height: calc(100vh - 100px);
    max-height: 680px;
  }

  .dante-launcher {
    bottom: 16px;
    right: 16px;
  }

  .dante-tooltips {
    /* Mobile shifts to match the mobile launcher gutter (16px) and
     * tightens the bottom gap so the stack stays anchored to the
     * launcher even on small viewports. */
    right: 16px;
    bottom: 84px;
    max-width: calc(100vw - 32px);
  }
}
