/**
 * RCODE.IN - AI CONSULTANT (ROHIT)
 * Conversational Chatbot Widget Stylesheet
 * Futuristic Dark Glass & Cyberpunk AI Aesthetic
 */

:root {
  --chat-primary-cyan: #00F2FE;
  --chat-primary-violet: #7000FF;
  --chat-accent-emerald: #00F5A0;
  --chat-bg-dark: #06080F;
  --chat-bg-card: rgba(10, 14, 25, 0.95);
  --chat-bg-bubble-bot: rgba(18, 24, 40, 0.9);
  --chat-border: rgba(0, 242, 254, 0.25);
  --chat-border-hover: rgba(0, 242, 254, 0.6);
  --chat-text-main: #F1F5F9;
  --chat-text-muted: #94A3B8;
  --chat-glow-cyan: 0 0 20px rgba(0, 242, 254, 0.35);
  --chat-glow-violet: 0 0 25px rgba(112, 0, 255, 0.35);
}

/* Chatbot Widget Container (Positioned Above Scroll-To-Top Button) */
.rcode-chat-widget {
  position: fixed;
  bottom: 88px;
  right: 28px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Launcher Floating Button */
.chat-launcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0A0E1A 0%, #10172A 100%);
  border: 1px solid var(--chat-border);
  padding: 0 18px 0 12px;
  height: 52px;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), var(--chat-glow-cyan);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: none;
}

.chat-launcher-btn:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--chat-primary-cyan);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.8), 0 0 28px rgba(0, 242, 254, 0.55);
}

.chat-launcher-icon-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary-cyan), var(--chat-primary-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #040914;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.5);
}

.chat-launcher-text {
  font-size: 0.875rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-launcher-text span.ai-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 242, 254, 0.15);
  color: var(--chat-primary-cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* Pulse Dot */
.chat-launcher-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
}

.chat-pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--chat-accent-emerald);
  opacity: 0.75;
  animation: chat-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.chat-pulse-dot {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--chat-accent-emerald);
  border: 2px solid #06080F;
}

@keyframes chat-ping {
  75%, 100% {
    transform: scale(2.3);
    opacity: 0;
  }
}

/* Launcher Tooltip */
.chat-launcher-tooltip {
  position: absolute;
  right: 0;
  bottom: 64px;
  background: #0D1322;
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--chat-border);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
}

.chat-launcher-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 26px;
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #0D1322 transparent transparent transparent;
}

.rcode-chat-widget:hover .chat-launcher-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-4px);
}

/* Chat Dialog Panel */
.chat-dialog-panel {
  position: absolute;
  bottom: 62px;
  right: 0;
  width: 395px;
  max-width: calc(100vw - 32px);
  height: min(540px, calc(100vh - 170px));
  max-height: calc(100vh - 170px);
  background: var(--chat-bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), var(--chat-glow-cyan);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  transform-origin: bottom right;
}

.rcode-chat-widget.chat-open .chat-dialog-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.rcode-chat-widget.chat-open .chat-launcher-tooltip {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, rgba(14, 19, 32, 0.95) 0%, rgba(20, 27, 48, 0.95) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

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

.chat-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0A0E1A;
  border: 1.5px solid var(--chat-primary-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
  flex-shrink: 0;
  overflow: hidden;
}

.chat-avatar-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(1.8) drop-shadow(0 0 4px rgba(0, 242, 254, 0.8));
}

.chat-header-info h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

.chat-header-info span {
  font-size: 0.72rem;
  color: var(--chat-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-header-info span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-accent-emerald);
  box-shadow: 0 0 6px var(--chat-accent-emerald);
}

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

.chat-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #CBD5E1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.chat-header-btn:hover {
  background: rgba(0, 242, 254, 0.2);
  color: var(--chat-primary-cyan);
  border-color: var(--chat-primary-cyan);
}

/* Quick Action / Direct Advisory Top Bar */
.chat-human-bar {
  background: rgba(13, 18, 30, 0.9);
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.chat-human-desc {
  font-size: 0.72rem;
  color: var(--chat-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-human-actions {
  display: flex;
  gap: 6px;
}

.chat-quick-link {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.chat-quick-link.whatsapp {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.4);
  color: #25D366;
}

.chat-quick-link.whatsapp:hover {
  background: #25D366;
  color: #040914 !important;
}

.chat-quick-link.consult {
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.35);
  color: var(--chat-primary-cyan);
}

.chat-quick-link.consult:hover {
  background: var(--chat-primary-cyan);
  color: #040914 !important;
}

/* Messages Area */
.chat-messages-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: transparent;
  font-size: 0.835rem;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 90%;
  outline: none;
}

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

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

.chat-msg-category {
  font-size: 0.625rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chat-primary-cyan);
  background: rgba(0, 242, 254, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  border: 1px solid rgba(0, 242, 254, 0.25);
}

.chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg-row.assistant .chat-bubble {
  background: var(--chat-bg-bubble-bot);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--chat-text-main);
  border-bottom-left-radius: 2px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chat-msg-row.assistant .chat-bubble strong {
  color: var(--chat-primary-cyan);
}

.chat-msg-row.user .chat-bubble {
  background: linear-gradient(135deg, #00F2FE 0%, #7000FF 100%);
  color: #FFFFFF;
  font-weight: 500;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 242, 254, 0.35);
}

.chat-bubble p {
  margin: 0 0 8px 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

/* Callout Quote in Bot Answer */
.chat-quote-block {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(0, 242, 254, 0.06);
  border-left: 3px solid var(--chat-primary-cyan);
  border-radius: 0 6px 6px 0;
  font-size: 0.78rem;
  font-style: italic;
  color: #E2E8F0;
}

.chat-quote-source {
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  color: var(--chat-primary-cyan);
  margin-top: 4px;
  display: block;
}

/* Action Link Box inside Bot Answer */
.chat-link-box {
  margin-top: 10px;
}

.chat-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.15) 0%, rgba(112, 0, 255, 0.15) 100%);
  border: 1px solid var(--chat-border);
  color: var(--chat-primary-cyan) !important;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.chat-action-link:hover {
  background: var(--chat-primary-cyan);
  color: #040914 !important;
  border-color: var(--chat-primary-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.5);
  transform: translateY(-1px);
}

.chat-action-link.whatsapp-link {
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.4);
  color: #25D366 !important;
}

.chat-action-link.whatsapp-link:hover {
  background: #25D366;
  color: #040914 !important;
  border-color: #25D366;
  box-shadow: 0 0 15px rgba(37, 211, 102, 0.5);
}

/* Suggested Followup Chips */
.chat-followups-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.chat-chip-btn {
  background: rgba(18, 24, 40, 0.95);
  border: 1px solid var(--chat-border);
  color: #CBD5E1;
  font-size: 0.72rem;
  padding: 5px 11px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.chat-chip-btn:hover {
  border-color: var(--chat-primary-cyan);
  color: var(--chat-primary-cyan);
  background: rgba(0, 242, 254, 0.1);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

/* Typing Indicator Animation */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--chat-bg-bubble-bot);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 2px;
  width: fit-content;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.4;
  animation: chat-typing-pulse 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(1) {
  background: var(--chat-primary-cyan);
  animation-delay: 0s;
}

.chat-typing-dot:nth-child(2) {
  background: var(--chat-primary-violet);
  animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
  background: var(--chat-accent-emerald);
  animation-delay: 0.4s;
}

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

/* Quick High-Yield Topics Auto-Sliding Bar */
.chat-topics-wrapper {
  flex-shrink: 0;
  padding: 8px 0;
  background: rgba(10, 14, 25, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to right, transparent, black 6%, black 94%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 6%, black 94%, transparent);
}

.chat-topics-track {
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  animation: chat-topics-slide 32s linear infinite;
  padding: 0 4px;
}

.chat-topics-wrapper:hover .chat-topics-track,
.chat-topics-track:hover {
  animation-play-state: paused;
}

@keyframes chat-topics-slide {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.chat-topic-tag {
  background: rgba(18, 24, 40, 0.95);
  border: 1px solid var(--chat-border);
  color: #CBD5E1;
  cursor: pointer;
  padding: 4px 11px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.chat-topic-tag:hover {
  color: #040914;
  background: var(--chat-primary-cyan);
  border-color: var(--chat-primary-cyan);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.5);
  transform: translateY(-1px);
}

/* Input Form Footer */
.chat-input-form {
  flex-shrink: 0;
  padding: 12px 14px;
  background: rgba(10, 14, 25, 0.98);
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-text-input {
  flex: 1;
  padding: 9px 14px;
  background: rgba(18, 24, 40, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  font-size: 0.835rem;
  color: #FFFFFF;
  outline: none;
  transition: all 0.15s ease;
}

.chat-text-input::placeholder {
  color: #64748B;
}

.chat-text-input:focus {
  border-color: var(--chat-primary-cyan);
  box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.2);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-primary-cyan), var(--chat-primary-violet));
  border: none;
  color: #040914;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.9rem;
  box-shadow: 0 3px 12px rgba(0, 242, 254, 0.35);
  transition: all 0.2s ease;
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 5px 18px rgba(0, 242, 254, 0.6);
  filter: brightness(1.1);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Ensure .scroll-to-top-btn stays at bottom while chatbot floats above it */
.scroll-to-top-btn {
  bottom: 28px !important;
  right: 28px !important;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .scroll-to-top-btn {
    bottom: 20px !important;
    right: 20px !important;
  }

  .rcode-chat-widget {
    bottom: 74px !important;
    right: 16px !important;
  }

  .chat-launcher-btn {
    height: 46px;
    padding: 0 14px 0 10px;
  }

  .chat-dialog-panel {
    position: fixed;
    top: 10px;
    top: max(10px, env(safe-area-inset-top, 10px));
    bottom: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    left: 10px;
    left: max(10px, env(safe-area-inset-left, 10px));
    right: 10px;
    right: max(10px, env(safe-area-inset-right, 10px));
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9);
    z-index: 100000;
  }
}
