/* SoftwareSelects AI Assistant — chat widget
   Same colours as the site header: navy, blue, amber. System fonts, no external requests. */

#swai-trigger, #swai-chat {
  --sw-ink: #1E1B4B;
  --sw-ink2: #4B4F72;
  --sw-blue: #4338CA;
  --sw-deep: #3730A3;
  --sw-amber: #FACC15;
  --sw-line: #E0E0F3;
  --sw-mist: #F5F5FE;
  --sw-muted: #6E7098;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
#swai-chat *, #swai-chat *::before, #swai-chat *::after { box-sizing: border-box; }

/* ── Floating trigger ── */
#swai-trigger {
  position: fixed; bottom: 20px; right: 20px; z-index: 9990;
  display: inline-flex !important; align-items: center !important; gap: 10px;
  height: 54px !important; min-height: 54px !important; padding: 0 20px 0 16px !important; margin: 0 !important;
  background: var(--sw-ink) !important; background-image: none !important; color: #fff !important;
  border: 2px solid var(--sw-amber) !important; border-radius: 999px !important;
  font-size: 15px !important; font-weight: 700 !important; line-height: 1 !important; letter-spacing: 0 !important; text-transform: none !important;
  cursor: pointer; -webkit-appearance: none !important; appearance: none !important;
  box-shadow: 0 8px 24px -8px rgba(30, 27, 75, .6), 0 2px 6px rgba(30, 27, 75, .2);
  transition: transform .18s ease, box-shadow .18s ease;
  animation: swai-pop .35s cubic-bezier(.34, 1.4, .64, 1) both;
}
#swai-trigger.left { right: auto; left: 20px; }
#swai-trigger:hover { transform: translateY(-2px); background: var(--sw-ink) !important; color: #fff !important; box-shadow: 0 12px 28px -8px rgba(30, 27, 75, .7), 0 2px 8px rgba(30, 27, 75, .25); }
#swai-trigger:focus-visible { outline: 3px solid var(--sw-blue); outline-offset: 3px; }
#swai-trigger svg { width: 24px !important; height: 24px !important; fill: var(--sw-amber) !important; display: block !important; flex: none; pointer-events: none; }
#swai-trigger.hide { display: none !important; }
#swai-trigger { position: fixed; }
#swai-trigger .swai-online { position: absolute; left: 32px; top: 9px; }
.swai-online { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #22C55E; box-shadow: 0 0 0 2px var(--sw-ink, #1E1B4B); flex: none; }
.swai-online::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid #22C55E; animation: swai-pulse 2s ease-out infinite; }
.swai-online { position: relative; }
@keyframes swai-pulse { 0% { transform: scale(.8); opacity: .9; } 70% { transform: scale(2.1); opacity: 0; } 100% { opacity: 0; } }
#swai-chat .swai-status { display: flex !important; align-items: center; gap: 6px; }
#swai-chat .swai-status .swai-online { width: 8px; height: 8px; box-shadow: none; }
#swai-chat .swai-avatar { position: relative; }
#swai-chat .swai-online--av { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; box-shadow: 0 0 0 2px #1E1B4B; }
#swai-chat .swai-online--av::after { display: none; }
@keyframes swai-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Chat window ── */
#swai-chat {
  position: fixed; bottom: 20px; right: 20px; z-index: 9991;
  width: 380px; height: min(600px, calc(100vh - 40px));
  display: none; flex-direction: column; overflow: hidden;
  background: var(--sw-mist); color: var(--sw-ink);
  border: 1px solid var(--sw-line); border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(30, 27, 75, .55), 0 4px 14px rgba(30, 27, 75, .12);
  font-size: 15px; line-height: 1.5; text-align: left;
  transform-origin: bottom right;
  animation: swai-open .2s ease both;
}
#swai-chat.left { right: auto; left: 20px; transform-origin: bottom left; }
#swai-chat.open { display: flex; }
#swai-chat.inline { position: relative; bottom: auto; right: auto; left: auto; width: 100%; max-width: 520px; height: 600px; margin: 0 auto; animation: none; box-shadow: 0 10px 30px -18px rgba(30, 27, 75, .5); }
@keyframes swai-open { from { transform: scale(.94) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 500px) {
  #swai-trigger { bottom: 14px; right: 14px; width: 54px !important; padding: 0 !important; justify-content: center !important; }
  #swai-trigger.left { left: 14px; }
  #swai-trigger .swai-trigger-label { display: none; }
  #swai-trigger .swai-online { left: auto; right: 8px; top: 8px; }
  #swai-chat:not(.inline) {
    bottom: 0 !important; right: 0 !important; left: 0 !important;
    width: 100% !important; height: 72vh !important; max-height: 72vh !important;
    border-radius: 16px 16px 0 0 !important; border-bottom: 0;
  }
}

/* ── Header ── */
#swai-chat .swai-header { display: flex; align-items: center; gap: 10px; flex: none; padding: 12px 12px 12px 14px; background: var(--sw-ink); color: #fff; border-bottom: 3px solid var(--sw-amber); }
#swai-chat .swai-avatar { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--sw-blue); display: grid; place-items: center; }
#swai-chat .swai-avatar svg { width: 30px; height: 30px; display: block; }
#swai-chat .swai-header-info { flex: 1; min-width: 0; }
#swai-chat .swai-header-info strong { display: block; font-size: 15.5px; font-weight: 700; line-height: 1.2; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#swai-chat .swai-header-info span { display: block; margin-top: 2px; font-size: 12.5px; color: #CBCCEA; }
#swai-chat .swai-header-actions { display: flex; gap: 4px; flex: none; }
#swai-chat .swai-header-btn {
  width: 36px !important; height: 36px !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important;
  display: grid !important; place-items: center !important;
  background: transparent !important; background-image: none !important; color: #E0E0F3 !important;
  border: 0 !important; border-radius: 9px !important; box-shadow: none !important; cursor: pointer;
  -webkit-appearance: none !important; appearance: none !important; transition: background-color .15s ease;
}
#swai-chat .swai-header-btn:hover { background: rgba(255, 255, 255, .14) !important; color: #fff !important; }
#swai-chat .swai-header-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
#swai-chat .swai-header-btn svg { width: 20px; height: 20px; fill: currentColor; display: block; pointer-events: none; }

/* ── Messages ── */
#swai-chat .swai-msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 8px; background: var(--sw-mist); }
#swai-chat .swai-msgs::-webkit-scrollbar { width: 6px; }
#swai-chat .swai-msgs::-webkit-scrollbar-thumb { background: #CACBE7; border-radius: 3px; }
#swai-chat .swai-row { display: flex; animation: swai-msg .18s ease both; }
#swai-chat .swai-row.bot { justify-content: flex-start; }
#swai-chat .swai-row.user { justify-content: flex-end; }
@keyframes swai-msg { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

#swai-chat .swai-bub { max-width: 84%; padding: 9px 12px 7px; border-radius: 14px; font-size: 14.5px; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; }
#swai-chat .swai-row.bot .swai-bub { background: #fff; color: var(--sw-ink); border: 1px solid var(--sw-line); border-bottom-left-radius: 4px; }
#swai-chat .swai-row.user .swai-bub { background: var(--sw-blue); color: #fff; border-bottom-right-radius: 4px; }
#swai-chat .swai-bub strong { font-weight: 700; color: inherit; }
#swai-chat .swai-time { display: block; margin-top: 3px; font-size: 10.5px; line-height: 1; text-align: right; color: var(--sw-muted); }
#swai-chat .swai-row.user .swai-time { color: rgba(255, 255, 255, .75); }

#swai-chat .swai-link { color: var(--sw-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; box-shadow: none; }
#swai-chat .swai-link:hover { color: var(--sw-ink); }
#swai-chat .swai-link--aff { padding: 2px 7px; background: var(--sw-amber); color: var(--sw-ink); border-radius: 6px; font-weight: 700; text-decoration: none; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
#swai-chat .swai-link--aff::after { content: " ↗"; }
#swai-chat .swai-link--aff:hover { background: #EAB308; color: var(--sw-ink); }
#swai-chat .swai-affnote { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--sw-line); font-size: 11.5px; line-height: 1.4; color: var(--sw-muted); }
#swai-chat .swai-affnote a { color: var(--sw-deep); text-decoration: underline; }

#swai-chat .swai-typing-bub { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; background: #fff; border: 1px solid var(--sw-line); border-radius: 14px; border-bottom-left-radius: 4px; }
#swai-chat .swai-typing-bub span { width: 7px; height: 7px; background: #A4A6CE; border-radius: 50%; animation: swai-dot 1.2s infinite; }
#swai-chat .swai-typing-bub span:nth-child(2) { animation-delay: .2s; }
#swai-chat .swai-typing-bub span:nth-child(3) { animation-delay: .4s; }
@keyframes swai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── Quick replies ── */
#swai-chat .swai-chips { flex: none; flex-wrap: wrap; gap: 6px; padding: 4px 12px 8px; background: var(--sw-mist); }
#swai-chat .swai-chip {
  padding: 7px 12px !important; margin: 0 !important; min-height: 0 !important;
  background: #fff !important; background-image: none !important; color: var(--sw-deep) !important;
  border: 1.5px solid var(--sw-blue) !important; border-radius: 999px !important; box-shadow: none !important;
  font-family: inherit !important; font-size: 13px !important; font-weight: 600 !important; line-height: 1.2 !important; text-transform: none !important; letter-spacing: 0 !important;
  cursor: pointer; -webkit-appearance: none !important; appearance: none !important; transition: background-color .15s ease, color .15s ease;
}
#swai-chat .swai-chip:hover, #swai-chat .swai-chip:focus-visible { background: var(--sw-blue) !important; color: #fff !important; outline: none; }

/* ── Input ── */
#swai-chat .swai-input-wrap { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 8px; background: #fff; border-top: 1px solid var(--sw-line); }
#swai-chat .swai-textarea {
  flex: 1; min-height: 44px; max-height: 100px; margin: 0; padding: 11px 14px; resize: none;
  background: var(--sw-mist) !important; color: var(--sw-ink) !important; -webkit-text-fill-color: var(--sw-ink) !important;
  border: 1.5px solid var(--sw-line) !important; border-radius: 14px !important; outline: none; box-shadow: none !important;
  font-family: inherit; font-size: 16px; line-height: 1.35;
  transition: border-color .15s ease;
}
#swai-chat .swai-textarea::placeholder { color: #9496BA; -webkit-text-fill-color: #9496BA; }
#swai-chat .swai-textarea:focus { border-color: var(--sw-blue) !important; }
#swai-chat .swai-send-btn {
  width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 0 !important; flex: 0 0 44px !important; padding: 0 !important; margin: 0 !important;
  display: grid !important; place-items: center !important;
  background: var(--sw-amber) !important; background-image: none !important; color: var(--sw-ink) !important;
  border: 0 !important; border-radius: 12px !important; box-shadow: none !important; cursor: pointer; line-height: 0 !important;
  -webkit-appearance: none !important; appearance: none !important; transition: background-color .15s ease, transform .15s ease;
}
#swai-chat .swai-send-btn:hover { background: #EAB308 !important; }
#swai-chat .swai-send-btn:active { transform: translateY(1px); }
#swai-chat .swai-send-btn:focus-visible { outline: 2px solid var(--sw-blue); outline-offset: 2px; }
#swai-chat .swai-send-btn:disabled { opacity: .5; cursor: not-allowed; }
#swai-chat .swai-send-btn svg { width: 22px !important; height: 22px !important; fill: var(--sw-ink) !important; display: block !important; margin-left: 2px; pointer-events: none; }

#swai-chat .swai-foot { flex: none; margin: 0; padding: 0 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: #fff; font-size: 11px; line-height: 1.4; color: var(--sw-muted); text-align: center; }
#swai-chat .swai-foot a { color: var(--sw-deep); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .swai-online::after { animation: none !important; }
  #swai-trigger, #swai-chat, #swai-chat .swai-row, #swai-chat .swai-typing-bub span { animation: none !important; transition: none !important; }
}
