/* ClickInns Assistant widget — all rules scoped under .cin-concierge.
 *
 * LiveChat-style conversation UI (operator-approved Prototype 1): brand-blue
 * gradient header with avatar + online status, avatar message bubbles, pill
 * quick-reply chips, a real composer (borderless field + circular send button
 * that lights up when there is text) and a "Powered by ClickInns" footer.
 *
 * The panel is FIXED-size (376x580), clamped to the viewport on small
 * screens; only the message log scrolls.
 *
 * Reads the theme's design tokens (tokens.css: --paper, --paper-2, --ink,
 * --line, --mute, --blue, --blue-deep, --blue-tint) with hardcoded light-mode
 * fallbacks so the widget still renders if the variables are absent. The
 * mount is relocated inside the theme's .cn wrapper by concierge.js so the
 * .cn.dark token overrides cascade in automatically.
 */

.cin-concierge {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: inherit;
}

/* ── launcher bubble ────────────────────────────────────────────────── */

.cin-concierge .cin-concierge__bubble {
  width: 56px;
  height: 56px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--blue, #1fa9e0);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(20, 39, 58, 0.28);
  transition: transform 0.15s ease;
}

.cin-concierge .cin-concierge__bubble:hover,
.cin-concierge .cin-concierge__bubble:focus-visible {
  transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
  .cin-concierge .cin-concierge__bubble {
    transition: none;
  }
}

/* ── panel: fixed 376x580, viewport-clamped ─────────────────────────── */

/* The explicit display:flex below would override the UA stylesheet's
 * [hidden] { display: none } — re-assert it so JS's panel.hidden toggle
 * actually hides the panel. */
.cin-concierge .cin-concierge__panel[hidden] {
  display: none;
}

.cin-concierge .cin-concierge__panel {
  width: min(376px, calc(100vw - 32px));
  height: min(580px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--paper, #ffffff);
  color: var(--ink, #1c2733);
  border-radius: 16px;
  box-shadow:
    0 18px 48px rgba(14, 42, 63, 0.3),
    0 2px 8px rgba(14, 42, 63, 0.12);
  overflow: hidden;
}

/* ── header ─────────────────────────────────────────────────────────── */

.cin-concierge .cin-concierge__header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--blue, #1fa9e0) 0%, var(--blue-deep, #0f6494) 100%);
  color: #fff;
  flex: 0 0 auto;
}

.cin-concierge .cin-concierge__header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: var(--blue-deep, #0f6494);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex: 0 0 auto;
}

.cin-concierge .cin-concierge__header-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.cin-concierge .cin-concierge__title {
  font-weight: 700;
  font-size: 15px;
}

.cin-concierge .cin-concierge__status {
  font-size: 12px;
  opacity: 0.92;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cin-concierge .cin-concierge__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ce3a6;
}

.cin-concierge .cin-concierge__close {
  border: none;
  background: transparent;
  color: #fff;
  opacity: 0.85;
  cursor: pointer;
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cin-concierge .cin-concierge__close:hover,
.cin-concierge .cin-concierge__close:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ── message log ────────────────────────────────────────────────────── */

.cin-concierge .cin-concierge__msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper, #ffffff);
}

.cin-concierge .cin-concierge__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.cin-concierge .cin-concierge__row--user {
  justify-content: flex-end;
}

.cin-concierge .cin-concierge__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue, #1fa9e0);
  color: #fff;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.cin-concierge .cin-concierge__bubble-msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.cin-concierge .cin-concierge__row--bot .cin-concierge__bubble-msg {
  background: var(--paper-2, #f1f4f6);
  color: var(--ink, #1c2733);
  border-bottom-left-radius: 4px;
}

.cin-concierge .cin-concierge__row--user .cin-concierge__bubble-msg {
  background: var(--blue, #1fa9e0);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* typing indicator */

.cin-concierge .cin-concierge__typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}

.cin-concierge .cin-concierge__typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mute, #9fb3bf);
  animation: cin-concierge-blink 1.2s infinite;
}

.cin-concierge .cin-concierge__typing i:nth-child(2) {
  animation-delay: 0.2s;
}

.cin-concierge .cin-concierge__typing i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes cin-concierge-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cin-concierge .cin-concierge__typing i {
    animation: none;
  }
}

/* ── quick-reply chips ──────────────────────────────────────────────── */

.cin-concierge .cin-concierge__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 4px 34px;
}

.cin-concierge .cin-concierge__chip {
  border: 1.5px solid var(--blue, #1fa9e0);
  color: var(--blue-deep, #0f6494);
  background: var(--paper, #ffffff);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.12s ease;
  box-sizing: border-box;
}

.cin-concierge .cin-concierge__chip:hover,
.cin-concierge .cin-concierge__chip:focus-visible {
  background: var(--blue-tint, #e7f6fd);
}

/* ── composer + powered footer ──────────────────────────────────────── */

.cin-concierge .cin-concierge__composer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--line, #e6eaed);
  background: var(--paper, #ffffff);
  flex: 0 0 auto;
}

.cin-concierge .cin-concierge__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  padding: 10px 4px;
  background: transparent;
  color: var(--ink, #1c2733);
  font-size: 14px;
  font-family: inherit;
}

.cin-concierge .cin-concierge__input::placeholder {
  color: var(--mute, #9fb3bf);
}

/* LiveChat-style borderless composer: the field carries no ring of its own
 * (the theme's global input:focus outline would otherwise draw a box around
 * the autofocused field every time the panel opens). The visible keyboard
 * focus indicator moves to the composer bar itself via :focus-within below —
 * required for a11y since the field's own outline is suppressed. */
.cin-concierge .cin-concierge__input:focus,
.cin-concierge .cin-concierge__input:focus-visible {
  outline: none;
  box-shadow: none;
  border: none;
}

.cin-concierge .cin-concierge__composer:focus-within {
  border-top-color: var(--blue, #1fa9e0);
  box-shadow: inset 0 1px 0 var(--blue, #1fa9e0);
}

.cin-concierge .cin-concierge__send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  border-radius: 50%;
  background: var(--paper-2, #e6eaed);
  color: var(--mute, #9fb3bf);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.cin-concierge .cin-concierge__send--ready {
  background: var(--blue, #1fa9e0);
  color: #fff;
}

.cin-concierge .cin-concierge__send:focus-visible {
  outline: 2px solid var(--blue-deep, #0f6494);
  outline-offset: 1px;
}

.cin-concierge .cin-concierge__powered {
  margin: 0;
  padding: 0 0 8px;
  text-align: center;
  font-size: 10px;
  color: var(--mute, #a8b8c2);
  background: var(--paper, #ffffff);
  flex: 0 0 auto;
}

.cin-concierge .cin-concierge__powered b {
  color: var(--blue-deep, #0f6494);
  font-weight: 600;
}

/* ── mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .cin-concierge .cin-concierge__panel {
    width: calc(100vw - 24px);
    height: min(580px, calc(100dvh - 110px));
  }
}
