/* ICS Chatbot v2.4 - advisor-style chat widget */
.ics-chat, .ics-chat * { box-sizing: border-box; }
.ics-chat {
  --ics-navy: #1e2a69;
  --ics-navy-2: #2f3f95;
  --ics-orange: #ef7d22;
  --ics-bg: #f4f6fb;
  --ics-text: #1f2433;
  --ics-muted: #6b7285;
  --ics-line: #e3e7f0;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ics-text);
}

/* ---------- Launcher ---------- */
#ai-chat-bubble {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483646;
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; border: 3px solid #fff;
  background: var(--ics-navy) center/cover no-repeat;
  box-shadow: 0 8px 24px rgba(30, 42, 105, .35);
  transition: transform .2s ease;
}
#ai-chat-bubble:hover { transform: scale(1.06); }
#ai-chat-bubble::before { /* soft pulse */
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(239, 125, 34, .55); animation: ics-pulse 2.4s ease-out infinite;
}
#ai-chat-bubble .ics-dot {
  position: absolute; right: 1px; bottom: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: #22c55e; border: 2px solid #fff;
}
#ai-chat-bubble .ics-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--ics-orange); color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}
@keyframes ics-pulse { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }

/* Teaser card next to the launcher */
#ai-chat-teaser {
  position: fixed; right: 24px; bottom: 100px; z-index: 2147483646;
  max-width: 260px; background: #fff; border-radius: 14px 14px 4px 14px;
  padding: 12px 34px 12px 14px; font-size: 13.5px; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(20, 28, 70, .18); cursor: pointer;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#ai-chat-teaser.show { opacity: 1; transform: none; pointer-events: auto; }
#ai-chat-teaser b { color: var(--ics-navy); }
#ai-chat-teaser .ics-x {
  position: absolute; top: 6px; right: 8px; border: 0; background: none; color: #9aa1b2;
  font-size: 16px; line-height: 1; cursor: pointer; padding: 2px;
}

/* ---------- Window ---------- */
#ai-chat-window {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483647;
  width: 370px; height: 580px; max-height: calc(100vh - 48px);
  background: var(--ics-bg); border-radius: 18px; overflow: hidden;
  display: none; flex-direction: column;
  box-shadow: 0 18px 50px rgba(20, 28, 70, .28);
  animation: ics-up .25s ease;
}
@keyframes ics-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.ics-head {
  background: linear-gradient(135deg, var(--ics-navy) 0%, var(--ics-navy-2) 100%);
  color: #fff; padding: 14px 14px 14px 16px; display: flex; align-items: center; gap: 12px;
}
.ics-head .ics-av { position: relative; flex: 0 0 46px; }
.ics-head .ics-av img { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); object-fit: cover; display: block; }
.ics-head .ics-av .ics-dot { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid var(--ics-navy); }
.ics-head .ics-who { flex: 1; min-width: 0; }
.ics-head .ics-name { font-size: 15.5px; font-weight: 600; line-height: 1.25; }
.ics-head .ics-role { font-size: 12px; opacity: .85; margin-top: 2px; }
#close-chat {
  border: 0; background: rgba(255,255,255,.14); color: #fff; width: 32px; height: 32px; border-radius: 50%;
  font-size: 20px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#close-chat:hover { background: rgba(255,255,255,.26); }

.ics-trust {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px; background: #fff;
  border-bottom: 1px solid var(--ics-line); font-size: 11.5px; color: var(--ics-muted);
}
.ics-trust span { background: #f1f3f9; border-radius: 20px; padding: 3px 9px; }

#ai-chat-log {
  flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}
.ics-day { align-self: center; font-size: 11px; color: var(--ics-muted); background: #e9ecf5; border-radius: 10px; padding: 2px 10px; margin: 2px 0 8px; }

.ics-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.ics-row.bot { align-self: flex-start; }
.ics-row.user { align-self: flex-end; flex-direction: row-reverse; }
.ics-row .ics-mini { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: 0 0 28px; visibility: hidden; }
.ics-row.last-in-group .ics-mini { visibility: visible; }
.ics-row + .ics-row.user, .ics-row.user + .ics-row.bot { margin-top: 8px; }

.ics-msg {
  max-width: 255px; padding: 9px 12px 6px; font-size: 14px; line-height: 1.5; border-radius: 16px;
  word-wrap: break-word; overflow-wrap: anywhere; animation: ics-in .2s ease;
}
.bot .ics-msg { background: #fff; color: var(--ics-text); border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(20,28,70,.06); }
.user .ics-msg { background: var(--ics-navy); color: #fff; border-bottom-right-radius: 5px; }
.ics-msg p { margin: 0 0 6px; }
.ics-msg p:last-of-type { margin-bottom: 0; }
.ics-msg ul { margin: 2px 0 6px; padding-left: 18px; }
.ics-msg li { margin: 2px 0; }
.ics-msg a { color: inherit; text-decoration: underline; }
.ics-time { display: block; text-align: right; font-size: 10.5px; opacity: .6; margin-top: 3px; }
@keyframes ics-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ics-typing { display: inline-flex; gap: 4px; padding: 12px 14px; background: #fff; border-radius: 16px; border-bottom-left-radius: 5px; }
.ics-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a3a9ba; animation: ics-blink 1.2s infinite; }
.ics-typing i:nth-child(2) { animation-delay: .2s; }
.ics-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ics-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ics-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 4px 36px; }
.ics-chip {
  border: 1.5px solid var(--ics-navy); color: var(--ics-navy); background: #fff; border-radius: 18px;
  padding: 6px 12px; font-size: 13px; font-family: inherit; cursor: pointer; line-height: 1.3;
  transition: background .15s ease, color .15s ease;
}
.ics-chip:hover { background: var(--ics-navy); color: #fff; }

/* ---------- Footer ---------- */
#ai-chat-footer { background: #fff; border-top: 1px solid var(--ics-line); padding: 10px 12px 8px; }
.ics-inputrow { display: flex; align-items: center; gap: 8px; }
#ai-chat-input {
  flex: 1; min-width: 0; border: 1.5px solid var(--ics-line); border-radius: 22px; padding: 11px 16px;
  font-size: 16px; font-family: inherit; outline: none; background: #f8f9fc; color: var(--ics-text);
}
#ai-chat-input:focus { border-color: var(--ics-navy-2); background: #fff; }
#ai-chat-send {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ics-orange); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, opacity .15s ease;
}
#ai-chat-send:hover { transform: scale(1.06); }
#ai-chat-send:disabled { opacity: .5; cursor: default; transform: none; }
.ics-note { font-size: 10.5px; color: #98a0b3; text-align: center; margin-top: 6px; }

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  #ai-chat-bubble { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  #ai-chat-teaser { right: 16px; bottom: 84px; max-width: calc(100vw - 32px); }
  #ai-chat-window { left: 8px; right: 8px; bottom: 8px; width: auto; height: 78vh; height: 78dvh; max-height: calc(100dvh - 16px); border-radius: 16px; }
  .ics-msg { max-width: 78vw; }
}
@media (prefers-reduced-motion: reduce) {
  #ai-chat-bubble::before, .ics-msg, #ai-chat-window, .ics-typing i { animation: none; }
}

/* ---------- v2.5 live chat ---------- */
.ics-sys { align-self: center; max-width: 90%; text-align: center; font-size: 12px; color: #4b5470; background: #e6eaf6; border-radius: 12px; padding: 5px 12px; margin: 8px 0; }
.ics-ini { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #ef7d22; color: #fff; font-weight: 600; }
span.ics-mini.ics-ini { width: 28px; height: 28px; font-size: 11px; }
.ics-ini-lg { width: 46px; height: 46px; font-size: 16px; border: 2px solid rgba(255,255,255,.85); }
.ics-row.agent .ics-msg { border-left: 3px solid #ef7d22; }
.ics-by { display: block; font-size: 11px; font-weight: 600; color: #ef7d22; margin-bottom: 2px; }
