/* =========================================================
   HAMAD CLINIC — AI CHATBOT WIDGET
   Design: Navy (#0D1B3E) + Teal (#00B5CC)
   Matches revamp.css design system
   ========================================================= */

/* ─── Scoped Variables ───────────────────────────────────── */
#hc-chatbot {
  --hc-navy:       #0D1B3E;
  --hc-navy-mid:   #162448;
  --hc-teal:       #00B5CC;
  --hc-teal-dark:  #0097AD;
  --hc-white:      #FFFFFF;
  --hc-bg-msg:     #F0F5FB;
  --hc-text:       #1A2236;
  --hc-muted:      #6B7A99;
  --hc-border:     #E2EAF8;
  --hc-shadow:     0 24px 64px rgba(13, 27, 62, 0.22);
  --hc-radius-lg:  20px;
  --hc-font:       'Inter', 'Outfit', system-ui, sans-serif;
  font-family: var(--hc-font);
  box-sizing: border-box;
}

#hc-chatbot *, #hc-chatbot *::before, #hc-chatbot *::after {
  box-sizing: border-box;
}

/* ─── Utility ────────────────────────────────────────────── */
#hc-chatbot .hc-hidden { display: none !important; }

/* ─── Floating Trigger Button ────────────────────────────── */
.hc-chat-btn {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #0D1B3E 0%, #1a4a7a 50%, #00B5CC 100%);
  box-shadow: 0 6px 24px rgba(0, 181, 204, 0.45), 0 2px 8px rgba(13, 27, 62, 0.3);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  outline: none;
}

.hc-chat-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 36px rgba(0, 181, 204, 0.6), 0 4px 12px rgba(13, 27, 62, 0.35);
}

.hc-chat-btn:focus-visible { outline: 3px solid #00B5CC; outline-offset: 4px; }
.hc-chat-btn.hc-active { background: linear-gradient(135deg, #0a1228 0%, #0097AD 100%); }

.hc-chat-icon, .hc-close-icon {
  width: 28px; height: 28px;
  position: absolute;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.hc-close-icon { transform: rotate(-90deg); }
.hc-chat-btn.hc-active .hc-close-icon { transform: rotate(0deg); }

.hc-btn-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: #00B5CC; opacity: 0;
  animation: hcPulseRing 3.5s ease-out infinite;
  pointer-events: none;
}

@keyframes hcPulseRing {
  0%   { transform: scale(1);   opacity: 0.55; }
  65%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

.hc-notif-badge {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: #EF4444; color: #fff;
  border-radius: 50%; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: hcBadgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hcBadgePop { from { transform: scale(0); } to { transform: scale(1); } }

/* ─── Chat Window ────────────────────────────────────────── */
.hc-chat-window {
  position: fixed; bottom: 176px; right: 28px;
  width: 368px; height: 530px;
  background: #FFFFFF; border-radius: 20px;
  box-shadow: 0 24px 64px rgba(13, 27, 62, 0.22);
  z-index: 99998;
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(0.94);
  pointer-events: none; transform-origin: bottom right;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hc-chat-window.hc-open {
  opacity: 1; transform: translateY(0) scale(1); pointer-events: all;
}

/* ─── Header ─────────────────────────────────────────────── */
.hc-chat-header {
  background: linear-gradient(135deg, #0D1B3E 0%, #163060 100%);
  padding: 15px 18px; display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; position: relative;
}

.hc-header-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #00B5CC 0%, #0097AD 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-weight: 700;
  font-size: 19px; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 181, 204, 0.5); position: relative; z-index: 1;
}

.hc-header-info { flex: 1; min-width: 0; position: relative; z-index: 1; }

.hc-header-name {
  font-weight: 600; font-size: 15px; color: #fff;
  font-family: 'Outfit', sans-serif; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hc-header-sub {
  font-size: 11.5px; color: rgba(255,255,255,0.65);
  margin-top: 3px; display: flex; align-items: center; gap: 5px;
}

.hc-online-dot {
  width: 7px; height: 7px; background: #22C55E;
  border-radius: 50%; display: inline-block;
  animation: hcOnlinePulse 2s ease-in-out infinite; flex-shrink: 0;
}

@keyframes hcOnlinePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.hc-close-btn {
  background: rgba(255,255,255,0.12); border: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0; position: relative; z-index: 1; outline: none;
}
.hc-close-btn:hover { background: rgba(255,255,255,0.22); }
.hc-close-btn svg { width: 16px; height: 16px; }

/* ─── Messages Area ──────────────────────────────────────── */
.hc-messages {
  flex: 1; overflow-y: auto; padding: 18px 14px 8px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth; overscroll-behavior: contain;
}
.hc-messages::-webkit-scrollbar { width: 4px; }
.hc-messages::-webkit-scrollbar-track { background: transparent; }
.hc-messages::-webkit-scrollbar-thumb { background: #C8D8F0; border-radius: 4px; }

/* ─── Message Rows ───────────────────────────────────────── */
.hc-msg {
  display: flex; align-items: flex-end; gap: 8px;
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.hc-msg.hc-visible { opacity: 1; transform: translateY(0); }
.hc-msg-user { flex-direction: row-reverse; }

.hc-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #00B5CC, #0097AD);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
  font-family: 'Outfit', sans-serif;
  box-shadow: 0 2px 6px rgba(0,181,204,0.35);
}

.hc-bubble {
  max-width: 82%; padding: 11px 15px;
  font-size: 13.5px; line-height: 1.6; word-break: break-word;
}

.hc-msg-bot .hc-bubble {
  background: #F0F5FB; color: #1A2236;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 2px 8px rgba(13,27,62,0.07);
}

.hc-msg-user .hc-bubble {
  background: linear-gradient(135deg, #00B5CC 0%, #0097AD 100%);
  color: #fff; border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(0,181,204,0.35);
}

.hc-bubble strong { font-weight: 600; color: #0D1B3E; }
.hc-msg-user .hc-bubble strong { color: #fff; }

/* ─── Typing Indicator ───────────────────────────────────── */
.hc-typing-bubble {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 18px !important; min-width: 64px;
}
.hc-typing-bubble span {
  width: 7px; height: 7px; background: #6B7A99; border-radius: 50%;
  display: inline-block; animation: hcTypeBounce 1.3s ease-in-out infinite; flex-shrink: 0;
}
.hc-typing-bubble span:nth-child(2) { animation-delay: 0.18s; }
.hc-typing-bubble span:nth-child(3) { animation-delay: 0.36s; }

@keyframes hcTypeBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

.hc-msg.hc-fade-out {
  opacity: 0 !important; transform: translateY(4px) !important;
  transition: opacity 0.28s ease, transform 0.28s ease !important;
}

/* ─── Quick Replies ──────────────────────────────────────── */
.hc-quick-replies {
  padding: 6px 14px 8px; display: flex; gap: 7px;
  overflow-x: auto; flex-shrink: 0; scrollbar-width: none;
  transition: opacity 0.3s ease, max-height 0.35s ease, padding 0.3s ease;
  max-height: 56px;
}
.hc-quick-replies::-webkit-scrollbar { display: none; }
.hc-quick-replies.hc-qr-hide {
  opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; pointer-events: none;
}

.hc-chip {
  background: transparent; border: 1.5px solid #00B5CC; color: #0D1B3E;
  border-radius: 20px; padding: 6px 13px; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: all 0.22s ease; font-family: 'Inter', sans-serif; outline: none;
}
.hc-chip:hover, .hc-chip:focus-visible {
  background: #00B5CC; color: #fff; border-color: #00B5CC; transform: translateY(-1px);
}

/* ─── Input Area ─────────────────────────────────────────── */
.hc-input-area {
  padding: 11px 14px 13px; display: flex; gap: 10px; align-items: center;
  border-top: 1px solid #E2EAF8; background: #FAFCFF; flex-shrink: 0;
}

.hc-text-input {
  flex: 1; border: 1.5px solid #D0DCF4; border-radius: 24px;
  padding: 10px 18px; font-size: 13.5px; font-family: 'Inter', sans-serif;
  color: #1A2236; background: #fff; outline: none; min-width: 0;
  transition: border-color 0.22s, box-shadow 0.22s;
}
.hc-text-input:focus {
  border-color: #00B5CC; box-shadow: 0 0 0 3px rgba(0,181,204,0.14);
}
.hc-text-input::placeholder { color: #A8B8D8; }

.hc-send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #0D1B3E, #0097AD);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 14px rgba(0,181,204,0.4); outline: none;
}
.hc-send-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(0,181,204,0.55); }
.hc-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.hc-send-btn svg { width: 19px; height: 19px; }

/* ─── Powered-by footer ──────────────────────────────────── */
.hc-powered {
  text-align: center; font-size: 10px; color: #B0BED8;
  padding: 5px 0 9px; background: #FAFCFF;
  border-top: 1px solid #E2EAF8; flex-shrink: 0; letter-spacing: 0.02em;
  font-family: 'Inter', sans-serif;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 500px) {
  .hc-chat-window {
    bottom: 0; right: 0; left: 0; width: 100%; height: 88vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%) scale(1); transform-origin: bottom center;
  }
  .hc-chat-window.hc-open { transform: translateY(0) scale(1); }
  .hc-chat-btn { bottom: 84px; right: 20px; }
}
@media (max-width: 360px) {
  .hc-bubble  { font-size: 13px; }
  .hc-chip    { font-size: 11.5px; padding: 5px 11px; }
}
