/* MAST AI Agent — chat widget styles.
   Namespaced under #mast-chat-widget so it won't collide with the rest of
   the site's CSS. Adjust colors/fonts to match the MAST site's branding. */

#mast-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px; /* pinned to the bottom-right of the screen regardless of RTL/LTR */
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Roboto, Arial, sans-serif;
}

#mast-chat-widget .mcw-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #0b4f8a; /* swap for the MAST/college brand color */
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

#mast-chat-widget .mcw-launcher:hover {
  filter: brightness(1.08);
}

#mast-chat-widget .mcw-panel {
  position: absolute;
  bottom: 76px;
  right: 0; /* stays under the launcher, which is now pinned to the right */
  width: 340px;
  max-width: calc(100vw - 40px);
  height: 460px;
  max-height: 70vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mast-chat-widget .mcw-panel[hidden] {
  display: none;
}

#mast-chat-widget .mcw-header {
  background: #0b4f8a;
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#mast-chat-widget .mcw-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

#mast-chat-widget .mcw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f8fa;
}

#mast-chat-widget .mcw-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#mast-chat-widget .mcw-msg a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all; /* long URLs shouldn't overflow the bubble */
}

#mast-chat-widget .mcw-msg.mcw-user {
  align-self: flex-end;
  background: #0b4f8a;
  color: #fff;
  border-end-end-radius: 2px; /* logical corner: mirrors correctly in RTL */
}

#mast-chat-widget .mcw-msg.mcw-assistant {
  align-self: flex-start;
  background: #e9edf1;
  color: #1a1a1a;
  border-end-start-radius: 2px; /* logical corner: mirrors correctly in RTL */
}

#mast-chat-widget .mcw-msg.mcw-error {
  align-self: flex-start;
  background: #fde2e2;
  color: #8a1f1f;
}

#mast-chat-widget .mcw-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  padding: 4px 12px;
}

#mast-chat-widget .mcw-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

#mast-chat-widget .mcw-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #666;
  animation: mcw-typing-bounce 1.2s infinite ease-in-out;
}

#mast-chat-widget .mcw-dot:nth-child(1) { animation-delay: 0s; }
#mast-chat-widget .mcw-dot:nth-child(2) { animation-delay: 0.2s; }
#mast-chat-widget .mcw-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mcw-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Respect users who've asked their OS/browser to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  #mast-chat-widget .mcw-dot {
    animation: none;
    opacity: 0.7;
  }
}

#mast-chat-widget .mcw-form {
  display: flex;
  border-top: 1px solid #e2e2e2;
  padding: 8px;
  gap: 8px;
}

#mast-chat-widget .mcw-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  height: 40px;
}

#mast-chat-widget .mcw-form button {
  background: #0b4f8a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
}

#mast-chat-widget .mcw-form button:disabled {
  opacity: 0.6;
  cursor: default;
}