/* AI assistant widget — floating button + chat panel (all live salons). */

.aiw {
  --aiw-radius: 22px;
  position: fixed;
  right: clamp(0.9rem, 3vw, 1.75rem);
  bottom: clamp(0.9rem, 3vw, 1.75rem);
  /* Above the sticky header (100) and its open dropdown (220): the panel is
     a modal surface, so an open menu can never cover or clip it. */
  z-index: 300;
  font-family: var(--font-body, system-ui, sans-serif);
  color: var(--color-text, #070b24);
}

/* ── Launcher ─────────────────────────────────────────────────────── */

.aiw-launch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.1rem 0.7rem 0.8rem;
  border: 0;
  border-radius: var(--radius-pill, 999px);
  background: linear-gradient(135deg, var(--color-primary, #1230ff), var(--color-secondary, #0a1a8f));
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(18, 48, 255, 0.32), 0 2px 6px rgba(7, 11, 36, 0.16);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.aiw-launch:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(18, 48, 255, 0.38), 0 2px 6px rgba(7, 11, 36, 0.2);
}

.aiw-launch:focus-visible,
.aiw-close:focus-visible,
.aiw-send:focus-visible,
.aiw-input:focus-visible,
.aiw-call:focus-visible {
  outline: 3px solid var(--color-warning, #b7a6ff);
  outline-offset: 2px;
}

.aiw-launch-icon {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.aiw-launch-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: left;
}

.aiw-launch-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.82;
}

.aiw-launch-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.aiw.is-open .aiw-launch {
  transform: scale(0.92);
  opacity: 0;
  pointer-events: none;
}

/* ── Panel ────────────────────────────────────────────────────────── */

.aiw-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(25rem, calc(100vw - 1.5rem));
  /* Sits above the header/menu, so it may use nearly the whole viewport: the
     answer log needs real room, not whatever is left under the menu. */
  height: min(44rem, calc(100dvh - 5rem));
  border: 1px solid var(--color-border, #dfe4f3);
  border-radius: var(--aiw-radius);
  background: var(--color-surface, #fff);
  box-shadow: 0 24px 60px rgba(7, 11, 36, 0.18), 0 4px 14px rgba(7, 11, 36, 0.08);
  overflow: hidden;
  animation: aiw-in 0.22s ease both;
}

.aiw-panel[hidden] {
  display: none;
}

@keyframes aiw-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.aiw-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  background: linear-gradient(135deg, var(--color-primary, #1230ff), var(--color-secondary, #0a1a8f));
  color: #fff;
}

.aiw-avatar {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
}

.aiw-head-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.aiw-title {
  font-family: var(--font-display, inherit);
  font-weight: 600;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aiw-sub {
  font-size: 0.75rem;
  opacity: 0.85;
}

.aiw-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.aiw-close:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* ── Log ──────────────────────────────────────────────────────────── */

.aiw-log {
  flex: 1 1 auto;
  min-height: 9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem;
  overflow-y: auto;
  background: var(--color-bg, #f2f5fc);
  overscroll-behavior: contain;
}

.aiw-msg {
  max-width: 88%;
  padding: 0.62rem 0.8rem;
  border-radius: 16px;
  font-size: 0.925rem;
  line-height: 1.45;
}

.aiw-msg p {
  margin: 0;
}

.aiw-msg p + p {
  margin-top: 0.45rem;
}

/* Link inside an answer (e.g. the salon's booking link). */
.aiw-msg .aiw-link {
  color: var(--color-primary, #1230ff);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.aiw-msg-bot {
  align-self: flex-start;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #dfe4f3);
  border-bottom-left-radius: 6px;
  color: var(--color-text, #070b24);
}

.aiw-msg-user {
  align-self: flex-end;
  background: var(--color-primary, #1230ff);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.aiw-msg-error {
  border-color: var(--color-error, #d1435b);
}

.aiw-msg-action {
  margin-top: 0.5rem;
}

.aiw-call {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-pill, 999px);
  background: var(--color-primary, #1230ff);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}

.aiw-call:hover {
  background: var(--color-secondary, #0a1a8f);
}

/* The booking pill carries both classes (aiw-link aiw-call), and the answer
   link colour above is more specific than .aiw-call — without this the label
   would be painted primary-on-primary and read as an empty blue pill. */
.aiw-msg .aiw-call,
.aiw-msg .aiw-call:hover,
.aiw-msg .aiw-call:focus-visible {
  color: #fff;
  text-decoration: none;
}

/* Typing indicator */
.aiw-typing {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
}

.aiw-typing span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--color-text-secondary, #566091);
  opacity: 0.5;
  animation: aiw-blink 1.1s infinite ease-in-out;
}

.aiw-typing span:nth-child(2) { animation-delay: 0.15s; }
.aiw-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiw-blink {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ── Ready questions + autocomplete ───────────────────────────────── */

.aiw-composer {
  position: relative;
  border-top: 1px solid var(--color-border, #dfe4f3);
  background: var(--color-surface, #fff);
}

/* Panel order: labels (topics), questions, conversation, input. The block is
   capped and scrolls on its own so the answers keep at least half the panel. */
.aiw-suggest {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.7rem 0.45rem;
  background: var(--color-surface, #fff);
  border-bottom: 1px solid var(--color-border, #dfe4f3);
  max-height: 12rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.aiw-suggest .aiw-cats,
.aiw-suggest .aiw-chips {
  padding: 0;
  background: transparent;
}



/* Question pills wrap: a question is read, not scanned, so it keeps its full
   text and breaks onto the next line instead of scrolling out of view. */
.aiw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem 0.3rem;
}

.aiw-chips[hidden] {
  display: none;
}

/* Topic buckets: the first screen's category row. Labels, not questions.
   One line that scrolls sideways (touch and wheel) instead of wrapping, so
   the labels keep room to breathe and the panel height stays predictable. */
.aiw-cats {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem 0.3rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  cursor: grab;
}

.aiw-cats:active {
  cursor: grabbing;
}

/* No scrollbar chrome: the arrows on both ends are the visible affordance. */
.aiw-cats::-webkit-scrollbar {
  display: none;
}

/* "‹ row ›": the arrows sit outside the scroll area, so they never scroll. */
.aiw-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
  padding: 0 0.25rem;
}

.aiw-row > .aiw-cats {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.4rem 0.15rem 0.3rem;
}

/* Related questions after an answer: one group inside the conversation,
   right under the bubble it belongs to (wrapping, never another section). */
.aiw-follow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.1rem 0 0.45rem;
}

.aiw-follow .aiw-chip {
  background: var(--color-surface, #fff);
}

.aiw-nav {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--color-border, #dfe4f3);
  border-radius: var(--radius-pill, 999px);
  background: var(--color-surface, #fff);
  color: var(--color-muted, #5a6288);
  cursor: pointer;
  box-shadow: 0 2px 6px -4px rgba(7, 11, 36, 0.45);
}

.aiw-nav:hover:not(:disabled),
.aiw-nav:focus-visible {
  color: var(--color-primary, #1230ff);
  border-color: currentColor;
}

.aiw-nav:disabled {
  opacity: 0.32;
  cursor: default;
}

/* Empty or non-overflowing row: no arrows at all. */
.aiw-nav[hidden] {
  display: none;
}

.aiw-cats[hidden] {
  display: none;
}

.aiw-cat {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.3rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  color: var(--color-muted, #5a6288);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.aiw-cat:hover,
.aiw-cat:focus-visible {
  color: var(--color-primary, #1230ff);
  border-color: currentColor;
}

.aiw-chip {
  flex: 0 0 auto;
  max-width: 85%;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--color-border, #dfe4f3);
  border-radius: var(--radius-pill, 999px);
  background: var(--color-bg, #f2f5fc);
  color: var(--color-text, #070b24);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.aiw-chip:hover,
.aiw-chip:focus-visible {
  border-color: var(--color-primary, #1230ff);
  color: var(--color-primary, #1230ff);
}

.aiw-ac {
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 100%;
  z-index: 5;
  margin: 0 0 0.4rem;
  padding: 0.25rem;
  list-style: none;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #dfe4f3);
  border-radius: var(--radius-control, 12px);
  box-shadow: 0 -8px 24px rgba(7, 11, 36, 0.12);
  max-height: 11rem;
  overflow-y: auto;
}

.aiw-ac[hidden] {
  display: none;
}

.aiw-ac li {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.aiw-ac li[aria-selected="true"],
.aiw-ac li:hover {
  background: var(--color-bg, #f2f5fc);
}

/* ── Composer ─────────────────────────────────────────────────────── */

.aiw-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 0.7rem;
  background: var(--color-surface, #fff);
}

.aiw-input {
  flex: 1 1 auto;
  min-height: 2.5rem;
  max-height: 6.5rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--color-border, #dfe4f3);
  border-radius: var(--radius-control, 12px);
  background: var(--color-bg, #f2f5fc);
  color: inherit;
  font: inherit;
  font-size: 0.925rem;
  line-height: 1.4;
  resize: none;
}

.aiw-send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary, #1230ff);
  color: #fff;
  cursor: pointer;
}

.aiw-send:disabled {
  opacity: 0.55;
  cursor: progress;
}

.aiw-note {
  margin: 0;
  padding: 0 0.85rem 0.75rem;
  background: var(--color-surface, #fff);
  color: var(--color-text-secondary, #566091);
  font-size: 0.72rem;
  line-height: 1.35;
}

.aiw-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Short screens: give the answers room first, the suggestions second. */
@media (max-height: 620px) {
  .aiw-suggest {
    max-height: 8rem;
  }

  .aiw-log {
    min-height: 5rem;
  }
}

/* ── Mobile ───────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .aiw-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: 88dvh;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
  }

  .aiw-launch-text {
    display: none;
  }

  .aiw-launch {
    padding: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aiw-panel,
  .aiw-launch,
  .aiw-typing span {
    animation: none;
    transition: none;
  }
}
