/* ─── Rally Foundation Chat Widget ──────────────────────────────────────────── */

/* CSS Custom Properties for branding */
:root {
  --rally-gold: #f1c400;
  --rally-gold-dark: #d9b000;
  --rally-navy: #1B2A4A;
  --rally-navy-light: #2C3E6B;
  --rally-white: #FFFFFF;
  --rally-gray-light: #F5F5F5;
  --rally-gray: #E0E0E0;
  --rally-text: #333333;
  --rally-text-light: #666666;
  --rally-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --rally-radius: 16px;
  --rally-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Chat Bubble (trigger button) ────────────────────────────────────────── */
#rally-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--rally-gold);
  border: none;
  cursor: pointer;
  box-shadow: var(--rally-shadow);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#rally-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2);
}

#rally-chat-bubble svg {
  width: 32px;
  height: 32px;
  fill: var(--rally-navy);
}

/* ─── Chat Window ─────────────────────────────────────────────────────────── */
#rally-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--rally-white);
  border-radius: var(--rally-radius);
  box-shadow: var(--rally-shadow);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--rally-font);
}

#rally-chat-window.open {
  display: flex;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
#rally-chat-header {
  background: var(--rally-navy);
  color: var(--rally-white);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#rally-chat-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#rally-chat-header-text strong {
  font-size: 16px;
  font-weight: 700;
}

#rally-chat-header-text small {
  font-size: 12px;
  opacity: 0.8;
}

#rally-chat-close {
  background: none;
  border: none;
  color: var(--rally-white);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

#rally-chat-close:hover {
  opacity: 1;
}

/* ─── Messages area ───────────────────────────────────────────────────────── */
#rally-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Message bubbles */
.rally-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.rally-msg-user {
  background: var(--rally-navy);
  color: var(--rally-white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.rally-msg-bot {
  background: var(--rally-gray-light);
  color: var(--rally-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Links in bot messages */
.rally-msg-bot a {
  color: var(--rally-navy);
  font-weight: 600;
  text-decoration: underline;
}

.rally-msg-bot a:hover {
  color: var(--rally-navy-light);
}

/* ─── Input area ──────────────────────────────────────────────────────────── */
#rally-chat-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--rally-gray);
  gap: 8px;
  flex-shrink: 0;
}

#rally-chat-input {
  flex: 1;
  border: 1px solid var(--rally-gray);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  font-family: var(--rally-font);
  transition: border-color 0.15s ease;
}

#rally-chat-input:focus {
  border-color: var(--rally-navy);
}

#rally-chat-input::placeholder {
  color: var(--rally-text-light);
}

#rally-chat-send {
  background: var(--rally-gold);
  color: var(--rally-navy);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--rally-font);
  transition: background 0.15s ease;
}

#rally-chat-send:hover {
  background: var(--rally-gold-dark);
}

#rally-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Typing indicator ────────────────────────────────────────────────────── */
.rally-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.rally-typing-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rally-text-light);
  animation: rally-bounce 1.4s infinite ease-in-out;
}

.rally-typing-dots span:nth-child(1) { animation-delay: 0s; }
.rally-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.rally-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rally-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* ─── Powered-by footer ───────────────────────────────────────────────────── */
#rally-chat-footer {
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: var(--rally-text-light);
  border-top: 1px solid var(--rally-gray);
  flex-shrink: 0;
}

/* ─── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #rally-chat-window {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  #rally-chat-messages {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
  }

  #rally-chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}
