/* ==========================================================================
   RGN FINSERV — AI Financial Advisor Chatbot Widget CSS
   Luxury Swiss Platinum & Royal Sapphire Navy Theme
   ========================================================================== */

:root {
  --rgn-chat-primary: #2563EB;
  --rgn-chat-primary-dark: #1D4ED8;
  --rgn-chat-accent: #0F172A;
  --rgn-chat-bg: #FFFFFF;
  --rgn-chat-bubble-assistant: #F8FAFC;
  --rgn-chat-bubble-user: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  --rgn-chat-text-dark: #0F172A;
  --rgn-chat-text-muted: #64748B;
  --rgn-chat-border: #E2E8F0;
  --rgn-chat-shadow: 0 20px 50px -10px rgba(15, 23, 42, 0.22), 0 0 1px 1px rgba(15, 23, 42, 0.05);
  --rgn-chat-radius: 20px;
  --rgn-chat-z: 99999;
}

/* Floating Trigger Button (Positioned above WhatsApp & Call floating buttons) */
.rgn-chat-trigger-btn {
  position: fixed;
  bottom: 155px;
  right: 25px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  color: #FFFFFF;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.42), 0 2px 8px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  z-index: var(--rgn-chat-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
  padding: 0;
}

.rgn-chat-trigger-btn:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.55), 0 0 20px rgba(96, 165, 250, 0.5);
}

.rgn-chat-trigger-btn:active {
  transform: scale(0.95);
}

.rgn-chat-trigger-btn svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

/* Active Online Indicator Badge */
.rgn-chat-trigger-btn .rgn-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #10B981;
  border: 2.5px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 10px #10B981;
  animation: rgnPulseDot 2.2s infinite;
}

@keyframes rgnPulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Modal Container */
.rgn-chat-widget-container {
  position: fixed;
  bottom: 25px;
  right: 90px;
  width: 385px;
  height: 560px;
  background: #FFFFFF;
  border: 1px solid var(--rgn-chat-border);
  border-radius: var(--rgn-chat-radius);
  box-shadow: var(--rgn-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--rgn-chat-z);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92) translateY(24px);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.rgn-chat-widget-container.rgn-chat-open {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* Header */
.rgn-chat-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rgn-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rgn-chat-avatar-wrapper {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.rgn-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rgn-chat-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border: 2px solid #0F172A;
  border-radius: 50%;
}

.rgn-chat-header-text h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}

.rgn-chat-header-text p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #93C5FD;
  font-weight: 500;
}

.rgn-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rgn-chat-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #E2E8F0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.rgn-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  transform: scale(1.05);
}

.rgn-chat-header-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

/* Chat Messages Body */
.rgn-chat-body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #F8FAFC;
  scroll-behavior: smooth;
}

.rgn-chat-body::-webkit-scrollbar {
  width: 5px;
}

.rgn-chat-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 999px;
}

/* Messages */
.rgn-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: rgnMsgFadeIn 0.25s ease-out;
}

@keyframes rgnMsgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.rgn-msg-assistant {
  align-self: flex-start;
}

.rgn-msg-user {
  align-self: flex-end;
}

.rgn-chat-bubble {
  padding: 12px 15px;
  font-size: 0.88rem;
  line-height: 1.55;
  border-radius: 16px;
  word-break: break-word;
}

.rgn-msg-assistant .rgn-chat-bubble {
  background: #FFFFFF;
  color: var(--rgn-chat-text-dark);
  border: 1px solid var(--rgn-chat-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.rgn-msg-assistant .rgn-chat-bubble strong {
  color: #0F172A;
  font-weight: 700;
}

.rgn-msg-user .rgn-chat-bubble {
  background: var(--rgn-chat-bubble-user);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.rgn-chat-time {
  font-size: 0.68rem;
  color: var(--rgn-chat-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.rgn-msg-assistant .rgn-chat-time {
  align-self: flex-start;
}

.rgn-msg-user .rgn-chat-time {
  align-self: flex-end;
}

/* Suggestions Chips */
.rgn-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.rgn-suggestion-chip {
  background: #FFFFFF;
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: #1D4ED8;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06);
}

.rgn-suggestion-chip:hover {
  background: #EFF6FF;
  border-color: #2563EB;
  transform: translateX(3px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

/* Dynamic Inline Quick Chips */
.rgn-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.rgn-chip-pill {
  background: #EFF6FF;
  border: 1px solid rgba(37, 99, 235, 0.35);
  color: #1D4ED8;
  padding: 5px 12px;
  border-radius: 18px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.rgn-chip-pill:hover {
  background: #2563EB;
  color: #FFFFFF;
  border-color: #2563EB;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.rgn-chip-pill:active {
  transform: scale(0.96);
}

/* Assistant Bubble Links */
.rgn-chat-bubble a {
  color: #2563EB;
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.15s ease;
}

.rgn-chat-bubble a:hover {
  color: #1D4ED8;
  text-decoration: underline;
}

/* Calculation summary callout inside chat */
.rgn-chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.82rem;
}

.rgn-chat-bubble th, .rgn-chat-bubble td {
  padding: 4px 8px;
  border-bottom: 1px solid #E2E8F0;
  text-align: left;
}

/* Typing Indicator */
.rgn-chat-typing-indicator {
  align-self: flex-start;
  background: #FFFFFF;
  border: 1px solid var(--rgn-chat-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.rgn-typing-dot {
  width: 7px;
  height: 7px;
  background: #94A3B8;
  border-radius: 50%;
  animation: rgnDotBounce 1.4s infinite ease-in-out;
}

.rgn-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.rgn-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes rgnDotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; background: #2563EB; }
}

/* Error Toast */
.rgn-chat-error-toast {
  display: none;
  background: #FEE2E2;
  color: #991B1B;
  border-top: 1px solid #FCA5A5;
  font-size: 0.78rem;
  padding: 8px 12px;
  text-align: center;
  font-weight: 500;
}

/* Footer / Input Area */
.rgn-chat-footer {
  padding: 12px 14px 10px;
  background: #FFFFFF;
  border-top: 1px solid var(--rgn-chat-border);
}

.rgn-chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 4px 6px 4px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rgn-chat-input-form:focus-within {
  border-color: #2563EB;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.rgn-chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: #0F172A;
  max-height: 100px;
  padding: 6px 0;
  line-height: 1.4;
}

.rgn-chat-textarea::placeholder {
  color: #94A3B8;
}

.rgn-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #2563EB;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.rgn-chat-send-btn:hover:not(:disabled) {
  background: #1D4ED8;
  transform: scale(1.05);
}

.rgn-chat-send-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
}

.rgn-chat-send-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  margin-left: 2px;
}

.rgn-chat-disclaimer {
  font-size: 0.68rem;
  color: #94A3B8;
  text-align: center;
  margin-top: 6px;
  letter-spacing: -0.01em;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .rgn-chat-trigger-btn {
    bottom: 145px;
    right: 18px;
    width: 52px;
    height: 52px;
  }
  
  .rgn-chat-trigger-btn svg {
    width: 24px;
    height: 24px;
  }

  .rgn-chat-widget-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 82vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .rgn-chat-widget-container.rgn-chat-open {
    transform: translateY(0);
  }
}
