/* ── Chatbot widget ─────────────────────────────────────────────────────────
   Floating chat assistant, bottom-right corner.
   Relies on css/main.css for :root tokens.
   ──────────────────────────────────────────────────────────────────────── */

/* ── Notification bubble ────────────────────────────────────────────────── */
.cb-notif {
  position: fixed;
  right: 88px; /* 54px button + 10px gap + 24px right */
  bottom: 33px; /* vertically centred with the 54px toggle */
  z-index: 9001;
  background: #fff;
  border-radius: 12px;
  padding: 9px 15px 9px 12px;
  box-shadow: 0 4px 22px rgba(20,22,26,.16);
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  white-space: nowrap;
  /* slide-in from right */
  animation: cb-notif-in .38s cubic-bezier(.22,.68,0,1.2) forwards;
  transform-origin: right center;
}

/* small speech-bubble tail pointing right */
.cb-notif::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-left-color: #fff;
  border-right-width: 0;
  filter: drop-shadow(2px 0 2px rgba(20,22,26,.06));
}

.cb-notif-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent, #d61f26);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  line-height: 1;
}

.cb-notif-text {
  flex: 1;
  min-width: 0;
}

.cb-notif-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted, #5b6472);
  text-transform: uppercase;
  letter-spacing: .07em;
  line-height: 1;
  margin-bottom: 2px;
}

.cb-notif-msg {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #14161a);
  line-height: 1.3;
}

.cb-notif-arrow {
  flex-shrink: 0;
  color: var(--accent, #d61f26);
  font-size: 14px;
  font-weight: 700;
  transition: transform .18s ease;
}

.cb-notif:hover .cb-notif-arrow {
  transform: translateX(3px);
}

/* dismiss button */
.cb-notif-close {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5b6472;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9px;
  line-height: 1;
  padding: 0;
}

.cb-notif-close:hover { background: #14161a; }

@keyframes cb-notif-in {
  from { opacity: 0; transform: translateX(14px) scale(.9); }
  to   { opacity: 1; transform: translateX(0)    scale(1);  }
}

@keyframes cb-notif-out {
  from { opacity: 1; transform: translateX(0)    scale(1);  }
  to   { opacity: 0; transform: translateX(14px) scale(.9); }
}

.cb-notif.is-hiding {
  animation: cb-notif-out .28s ease forwards;
  pointer-events: none;
}

/* pulse ring on toggle when notif is visible */
.cb-toggle.has-notif::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(214,31,38,.55);
  animation: cb-pulse 1.8s ease-out infinite;
}

@keyframes cb-pulse {
  0%   { transform: scale(1);    opacity: .7; }
  70%  { transform: scale(1.35); opacity: 0;  }
  100% { transform: scale(1.35); opacity: 0;  }
}

/* ── Toggle button ─────────────────────────────────────────────────────── */
.cb-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9000;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent, #d61f26);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(214,31,38,.40);
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.cb-toggle:hover {
  background: #b71b21;
  box-shadow: 0 6px 28px rgba(214,31,38,.52);
  transform: scale(1.06);
}

/* Swap chat icon <-> close icon */
.cb-toggle .cb-icon-chat  { display: block; }
.cb-toggle .cb-icon-close { display: none;  }
.cb-toggle[aria-expanded="true"] .cb-icon-chat  { display: none;  }
.cb-toggle[aria-expanded="true"] .cb-icon-close { display: block; }

/* ── Panel ──────────────────────────────────────────────────────────────── */
.cb-panel {
  position: fixed;
  right: 24px;
  bottom: 90px;
  z-index: 8999;
  width: min(370px, calc(100vw - 32px));
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(20,22,26,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* slide-up animation */
  transform: translateY(16px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .24s ease, opacity .24s ease;
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */
.cb-header {
  background: #1d3557;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.cb-header-info { flex: 1; min-width: 0; }

.cb-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

.cb-header-status {
  font-size: 11.5px;
  color: rgba(255,255,255,.68);
}

.cb-header-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4cd964;
  margin-right: 5px;
  vertical-align: middle;
}

/* ── Message area ───────────────────────────────────────────────────────── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  scroll-behavior: smooth;
}

.cb-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
}

/* Bot = left */
.cb-msg.bot {
  align-self: flex-start;
}

.cb-msg.bot .cb-bubble {
  background: #f0f2f7;
  color: #14161a;
  border-radius: 4px 14px 14px 14px;
}

/* User = right */
.cb-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-msg.user .cb-bubble {
  background: var(--accent, #d61f26);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.cb-bubble {
  font-size: 13.5px;
  line-height: 1.6;
  padding: 9px 13px;
  word-break: break-word;
}

.cb-bubble a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cb-bubble a:hover { opacity: .82; }

/* ── Typing indicator ───────────────────────────────────────────────────── */
.cb-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #f0f2f7;
  border-radius: 4px 14px 14px 14px;
}

.cb-typing span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa5b4;
  animation: cb-bounce .9s ease-in-out infinite;
}

.cb-typing span:nth-child(2) { animation-delay: .15s; }
.cb-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0);    }
  30%            { transform: translateY(-5px); }
}

/* ── Quick replies ──────────────────────────────────────────────────────── */
.cb-quick-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  flex-shrink: 0;
}

.cb-quick {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #d61f26);
  background: rgba(214,31,38,.07);
  border: 1px solid rgba(214,31,38,.22);
  border-radius: 20px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  line-height: 1;
}

.cb-quick:hover {
  background: var(--accent, #d61f26);
  color: #fff;
}

/* ── Input row ──────────────────────────────────────────────────────────── */
.cb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #edf0f6;
  flex-shrink: 0;
}

.cb-input {
  flex: 1;
  font-size: 13.5px;
  font-family: inherit;
  color: #14161a;
  background: #f4f6fb;
  border: 1px solid #e2e6ef;
  border-radius: 20px;
  padding: 8px 14px;
  outline: none;
  transition: border-color .16s ease;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
  overflow: hidden; /* hide browser scroll arrows; JS handles height */
  /* suppress native textarea appearance */
  -webkit-appearance: none;
  appearance: none;
  /* hide scrollbar in all browsers */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.cb-input::-webkit-scrollbar { display: none; }

.cb-input::placeholder { color: #9aa5b4; }
.cb-input:focus { border-color: var(--accent, #d61f26); }

.cb-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent, #d61f26);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background .15s ease, transform .15s ease;
}

.cb-send:hover {
  background: #b71b21;
  transform: scale(1.08);
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .cb-toggle { right: 16px; bottom: 16px; }
  .cb-panel  { right: 16px; bottom: 82px; }
  .cb-messages { max-height: 260px; }
  /* on small screens: notif goes above the button instead of to the left */
  .cb-notif {
    right: 16px;
    bottom: 82px;
    white-space: normal;
    max-width: calc(100vw - 32px);
  }
  .cb-notif::after {
    /* tail points down instead of right */
    right: 19px;
    top: auto;
    bottom: -7px;
    transform: none;
    border-left-color: transparent;
    border-top-color: #fff;
    border-bottom-width: 0;
  }
}
