/* ═══════════════════════════════════════
   LIFELINE CHAT WIDGET — chat.css
═══════════════════════════════════════ */

/* ─── FLOATING BUTTON ─── */
.chat-float-btn {
  position: fixed;
  bottom: 32px;
  right: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10000;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  filter: drop-shadow(0 6px 20px rgba(13,47,110,0.35));
}
.chat-float-btn:hover { transform: scale(1.1); }
.chat-float-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 18px rgba(13,47,110,0.25);
  background: #e8f4fd;
  display: block;
}

/* pulse ring */
.chat-float-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2.5px solid rgba(30,139,195,0.5);
  animation: chat-ring 2.2s ease-in-out infinite;
}
.chat-float-btn::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(30,139,195,0.2);
  animation: chat-ring 2.2s ease-in-out infinite 0.6s;
}
@keyframes chat-ring {
  0%   { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* online dot */
.chat-online-dot {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #25d366;
  border-radius: 50%;
  border: 2.5px solid #fff;
  z-index: 1;
}

/* tooltip */
.chat-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary, #0d2f6e);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  font-family: 'Hind', sans-serif;
}
.chat-tooltip::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--primary, #0d2f6e);
}
.chat-float-btn:hover .chat-tooltip { opacity: 1; }

/* ─── CHAT WINDOW ─── */
.chat-window {
  position: fixed;
  bottom: 116px;
  right: 24px;
  width: 370px;
  height: 560px;
  /* never overflow behind sticky header (topbar ~44px + nav ~84px = ~128px clearance) */
  max-height: calc(100dvh - 260px);
  min-height: 300px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(13,47,110,0.22), 0 4px 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 10001;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  border: 1px solid rgba(13,47,110,0.08);
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── HEADER ─── */
.chat-header {
  background: linear-gradient(135deg, #0d2f6e 0%, #1a4fa0 100%);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
.chat-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4);
  object-fit: cover;
  background: #e8f4fd;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: 'Hind', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  background: #25d366;
  border-radius: 50%;
  animation: blink-dot 2s ease-in-out infinite;
}
@keyframes blink-dot {
  0%,100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.chat-status-text {
  color: rgba(255,255,255,0.75);
  font-size: 0.72rem;
  font-family: 'Hind', sans-serif;
}
.chat-close-btn {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }
.chat-header-tag {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: #f4a61d;
  color: #0d2f6e;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 12px;
  border-radius: 8px 8px 0 0;
  letter-spacing: 0.5px;
  font-family: 'Hind', sans-serif;
}

/* ─── MESSAGES AREA ─── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f5f8ff;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #c0d4f0; border-radius: 4px; }

/* date chip */
.chat-date-chip {
  text-align: center;
  font-size: 0.68rem;
  color: #94a3b8;
  background: #e2e8f0;
  border-radius: 20px;
  padding: 3px 12px;
  margin: 4px auto;
  width: fit-content;
  font-family: 'Hind', sans-serif;
}

/* message bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
  animation: msg-in 0.3s ease;
}
@keyframes msg-in {
  from { opacity:0; transform: translateY(10px); }
  to   { opacity:1; transform: translateY(0); }
}
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #d0e3f7;
  background: #e8f4fd;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.86rem;
  line-height: 1.6;
  font-family: 'Hind', sans-serif;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: #fff;
  color: #1a1a2e;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 2px 8px rgba(13,47,110,0.08);
  border: 1px solid #e8f0fb;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #0d2f6e, #1a4fa0);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 10px rgba(13,47,110,0.25);
}

.chat-msg-time {
  font-size: 0.62rem;
  color: #94a3b8;
  margin-top: 4px;
  display: block;
  font-family: 'Hind', sans-serif;
}
.chat-msg.user .chat-msg-time { text-align: right; }

/* typing / loading */
.chat-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  align-self: flex-start;
}
.chat-typing-bubble {
  background: #fff;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(13,47,110,0.08);
  border: 1px solid #e8f0fb;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: #1e8bc3;
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* quick replies */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
  padding-left: 38px;
}
.quick-reply-btn {
  background: #fff;
  border: 1.5px solid #1e8bc3;
  color: #1e8bc3;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Hind', sans-serif;
  transition: all 0.2s;
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: #1e8bc3;
  color: #fff;
}

/* ─── INPUT AREA ─── */
.chat-input-area {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e8f0fb;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #d0e3f7;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.87rem;
  font-family: 'Hind', sans-serif;
  color: #1a1a2e;
  resize: none;
  outline: none;
  background: #f5f8ff;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow-y: auto;
}
.chat-input:focus {
  border-color: #1e8bc3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(30,139,195,0.1);
}
.chat-input::placeholder { color: #94a3b8; }
/* ─── MIC BUTTON ─── */
.chat-mic-btn {
  width: 42px;
  height: 42px;
  background: #f0f4fa;
  border: 1.5px solid #d0e3f7;
  border-radius: 50%;
  color: #5a6a7e;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chat-mic-btn:hover {
  background: #e8f0fb;
  color: #1e8bc3;
  border-color: #1e8bc3;
  transform: scale(1.06);
}
.chat-mic-btn.recording {
  background: linear-gradient(135deg, #e63946, #c0392b);
  border-color: transparent;
  color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(230,57,70,0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(230,57,70,0); }
  100% { box-shadow: 0 0 0 0 rgba(230,57,70,0); }
}
.chat-mic-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-send-btn {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0d2f6e, #1a4fa0);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(13,47,110,0.3);
}
.chat-send-btn:hover { transform: scale(1.08); box-shadow: 0 5px 16px rgba(13,47,110,0.4); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── BRANDING FOOTER ─── */
.chat-footer {
  flex-shrink: 0;
  background: #f0f4fa;
  border-top: 1px solid #e2ecf8;
  padding: 7px 14px;
  text-align: center;
}
.chat-footer-text {
  font-size: 0.65rem;
  color: #7a90b0;
  font-family: 'Hind', sans-serif;
  line-height: 1.5;
}
.chat-footer-text strong {
  color: #0d2f6e;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.chat-footer-text a {
  color: #1e8bc3;
  text-decoration: none;
  font-weight: 600;
}
.chat-footer-text a:hover { text-decoration: underline; }

/* ─── ERROR MESSAGE ─── */
.chat-bubble.error {
  background: #fff0f0;
  color: #c0392b;
  border: 1px solid #f5b3b7;
}

/* ─── RESPONSIVE ─── */

/* Tablet: narrower window */
@media (max-width: 768px) {
  .chat-window {
    width: 340px;
    right: 16px;
  }
}

/* Small tablet / large mobile */
@media (max-width: 600px) {
  .chat-window {
    width: 310px;
    right: 12px;
    max-height: calc(100dvh - 220px);
  }
}

/* Mobile full-width */
@media (max-width: 480px) {
  .chat-float-btn {
    right: 16px;
    bottom: 24px;
    width: 62px;
    height: 62px;
  }
  .chat-window {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 100px;
    /* on mobile header collapses to ~64px; bottom 100px → safe clearance */
    height: calc(100dvh - 172px);
    max-height: 500px;
    min-height: 280px;
    border-radius: 18px;
  }
}
