/* =========================================================
   HamroCampus AI Chatbot Widget — v2 (redesign)
   Uses the theme's existing CSS variables (--color-primary,
   --color-secondary, etc.) so it auto-matches the dark theme.

   Design notes for this pass:
   - One primary FAB (launcher) instead of two competing floating
     buttons. The separate "notification bell" (rendered by
     HCUM_Messages) now docks ABOVE this button as a smaller
     secondary action instead of sharing the same corner — see the
     "Floating buttons" rules in style.css.
   - Removed the default browser yellow focus outline on the round
     buttons and replaced it with a visible, on-brand focus ring so
     keyboard users still get a clear indicator.
   - Greeting bubble now uses an opacity/transform transition driven
     by a class toggle instead of display:block, so it animates in
     and out instead of popping.
========================================= */

#hc-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: var(--hc-fab-right);
  z-index: 99999;
  width: var(--hc-fab-size);
  height: var(--hc-fab-size);
  animation: hc-fab-pulse 2.4s ease-in-out infinite;
  border-radius: 50%;
  background: var(--color-primary, #1D4ED8);
  color: var(--color-text-on-primary, #fff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
  transition: transform .2s ease, box-shadow .2s ease;
}
#hc-chat-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(15, 23, 42, 0.4); }
#hc-chat-launcher:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-bg, #0B1220), 0 0 0 6px var(--color-primary, #1D4ED8);
}
#hc-chat-launcher svg { width: 24px; height: 24px; transition: transform .2s ease; }
#hc-chat-launcher.hc-launcher-active svg { transform: rotate(90deg) scale(0.9); }
#hc-chat-launcher.hc-launcher-active { animation: none; }

@keyframes hc-fab-pulse {
  0%   { box-shadow: 0 8px 24px rgba(15,23,42,0.35), 0 0 0 0 rgba(29,78,216,0.5); }
  70%  { box-shadow: 0 8px 24px rgba(15,23,42,0.35), 0 0 0 14px rgba(29,78,216,0); }
  100% { box-shadow: 0 8px 24px rgba(15,23,42,0.35), 0 0 0 0 rgba(29,78,216,0); }
}

/* "Chat with us" tooltip on hover (desktop only) */
#hc-chat-launcher::after {
  content: "Chat with us";
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
#hc-chat-launcher:hover::after { opacity: 1; }
@media (max-width: 768px) {
  #hc-chat-launcher::after { display: none; }
}

/* Auto greeting bubble */
#hc-chat-bubble {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99998;
  max-width: 250px;
  background: var(--color-card, #101a2c);
  color: var(--color-text-primary, #E2E8F0);
  border: 1px solid var(--color-border, #1F2A3D);
  border-radius: 16px 16px 4px 16px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#hc-chat-bubble.hc-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#hc-chat-bubble p { margin: 0; padding-right: 6px; font-size:11px;}
#hc-chat-bubble .hc-close-bubble {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--color-text-secondary, #64748B);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#hc-chat-bubble .hc-close-bubble:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-bg, #0B1220), 0 0 0 4px var(--color-primary, #1D4ED8);
}

/* Chat window */
#hc-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99999;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--color-bg, #0B1220);
  border: 1px solid var(--color-border, #1F2A3D);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
#hc-chat-window.hc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#hc-chat-header {
  background: linear-gradient(135deg, var(--color-primary, #1D4ED8), #4338CA);
  color: var(--color-text-on-primary, #fff);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}
#hc-chat-header > div:nth-child(2) { flex: 1; }
.hc-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#hc-chat-header .hc-header-sub {
  font-weight: 400;
  font-size: 11.5px;
  opacity: 0.85;
}
#hc-chat-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 8px;
}
#hc-chat-close:hover { background: rgba(255,255,255,0.12); }
#hc-chat-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
}

#hc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hc-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: hc-msg-in .18s ease;
}
@keyframes hc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hc-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.hc-msg-bot {
  align-self: flex-start;
  background: var(--color-card, #101a2c);
  color: var(--color-text-primary, #E2E8F0);
  border: 1px solid var(--color-border, #1F2A3D);
  border-bottom-left-radius: 4px;
}
.hc-msg-user {
  align-self: flex-end;
  background: var(--color-primary, #1D4ED8);
  color: var(--color-text-on-primary, #fff);
  border-bottom-right-radius: 4px;
}
.hc-msg-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--color-card, #101a2c);
  border: 1px solid var(--color-border, #1F2A3D);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.hc-msg-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-text-secondary, #94A3B8);
  animation: hc-blink 1.1s infinite ease-in-out;
}
.hc-msg-typing span:nth-child(2) { animation-delay: .15s; }
.hc-msg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hc-blink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* Login CTA shown to logged-out visitors inside the chat window */
#hc-chat-window .hc-login-cta {
  align-self: flex-start;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--color-primary, #1D4ED8);
  color: var(--color-text-on-primary, #fff);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: transform .15s ease;
}
.hc-login-cta:hover { transform: translateY(-1px); }
.hc-login-cta:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-bg, #0B1220), 0 0 0 6px var(--color-primary, #1D4ED8);
}

#hc-chat-footer {
  border-top: 1px solid var(--color-border, #1F2A3D);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--color-card, #101a2c);
}
#hc-chat-input {
  flex: 1;
  border: 1px solid var(--color-border, #1F2A3D);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  background: var(--color-bg, #0B1220);
  color: var(--color-text-primary, #E2E8F0);
}
#hc-chat-input:focus { border-color: var(--color-border-focus, #3B82F6); }
#hc-chat-input:disabled { opacity: .6; cursor: not-allowed; }
#hc-chat-send {
  background: var(--color-primary, #1D4ED8);
  color: var(--color-text-on-primary, #fff);
  border: none;
  border-radius: 10px;
  width: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease;
}
#hc-chat-send:hover:not(:disabled) { transform: translateY(-1px); }
#hc-chat-send:disabled { opacity: .5; cursor: not-allowed; }
#hc-chat-send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-card, #101a2c), 0 0 0 4px var(--color-primary, #1D4ED8);
}

@media (max-width: 480px) {
  #hc-chat-window { right: 16px; bottom: 88px; width: calc(100vw - 32px); }
  #hc-chat-launcher { right: 16px; bottom: 16px; }
  #hc-chat-bubble { right: 16px; bottom: 88px; }
}

/*
 * Site-wide notification bell (#user-notif-widget / #user-notif-bell /
 * #user-notif-badge): positions and sizes now live once in style.css
 * ("Floating buttons"), because the bell is rendered on every page,
 * also when this widget stylesheet is not loaded.
 */

/* Dark mode: white "x" on --color-text-secondary (#94A3B8) was 2.56:1; use the page bg colour. */
[data-theme="dark"] #hc-chat-bubble .hc-close-bubble,
.dark-mode #hc-chat-bubble .hc-close-bubble {
  color: var(--color-bg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #hc-chat-bubble .hc-close-bubble {
    color: var(--color-bg);
  }
}
