/* ==========================================================================
   WE-GYAAN CLASSES - INTERACTIVE ACADEMIC DESK CHATBOT WIDGET
   Brand Aligned with Emerald Green, Royal Blue, and Deep Slate Navy
   Strictly Zero Em-Dashes and En-Dashes
   ========================================================================== */

:root {
  --chat-brand-grad: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #10b981 100%);
  --chat-brand-grad-hover: linear-gradient(135deg, #020617 0%, #0f172a 50%, #059669 100%);
  --chat-primary: #10b981;
  --chat-primary-hover: #059669;
  --chat-secondary: #2563eb;
  --chat-accent-orange: #f59e0b;
  --chat-dark: #0f172a;
  --chat-dark-surface: #1e293b;
  --chat-bg-bubble: #f8fafc;
  --chat-border: #e2e8f0;
  --chat-text: #0f172a;
  --chat-text-muted: #64748b;
  --chat-accent-green: #10b981;
}

/* Floating Launcher Container */
.wegyaan-chat-widget {
  position: fixed;
  bottom: 185px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
}

/* Floating Launcher Toggle Button */
.chat-launcher-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--chat-brand-grad);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.45), 0 8px 10px -6px rgba(15, 23, 42, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.2s ease;
  outline: none;
}

.chat-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 32px -5px rgba(16, 185, 129, 0.5), 0 10px 18px -4px rgba(15, 23, 42, 0.4);
  border-color: #ffffff;
}

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

.wegyaan-chat-widget.chat-open .chat-launcher-btn,
.chat-launcher-btn.chat-launcher-hidden {
  opacity: 0 !important;
  transform: scale(0.4) !important;
  pointer-events: none !important;
  visibility: hidden !important;
  display: none !important;
}

.chat-launcher-icon-wrap {
  width: 40px;
  height: 40px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s ease;
}

.chat-launcher-btn:hover .chat-launcher-icon-wrap {
  transform: scale(1.06);
}

.chat-launcher-favicon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.chat-launcher-btn svg {
  width: 26px;
  height: 26px;
  stroke: #ffffff;
  transition: transform 0.2s ease;
}

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

.chat-pulse-ping {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--chat-accent-green);
  opacity: 0.75;
  animation: chat-ping 1.5s 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-green);
  border: 2px solid #ffffff;
}

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

/* Tooltip Badge on Initial Visit */
.chat-launcher-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: #0f172a;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 20px -3px rgba(15, 23, 42, 0.3), 0 4px 12px rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.5);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: chat-bounce 2s infinite ease-in-out;
  pointer-events: none;
}

.chat-launcher-tooltip svg {
  width: 14px;
  height: 14px;
  color: #10b981;
}

@keyframes chat-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Dialogue Window Container */
.chat-dialog-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid var(--chat-border);
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}

.chat-dialog-panel.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.chat-header {
  padding: 14px 18px;
  background: var(--chat-brand-grad);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  flex-shrink: 0;
}

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

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

.chat-header-favicon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.chat-header-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chat-accent-green);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chat-header-title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  margin: 0;
}

.chat-header-subtitle {
  font-size: 0.6875rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 2px 0 0 0;
}

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

.chat-action-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* Persistent "Chat with Human / Mentor" Bar */
.chat-human-bar {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-human-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: #16a34a;
  color: #ffffff !important;
  font-size: 0.7813rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-human-btn:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  color: #ffffff !important;
}

.chat-human-wa-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
}

.chat-human-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  margin-left: auto;
  transition: transform 0.15s ease;
}

.chat-human-btn:hover .chat-human-arrow {
  transform: translateX(3px);
}

/* 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: #ffffff;
  font-size: 0.8125rem;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 88%;
  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: monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chat-primary);
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  border: 1px solid rgba(16, 185, 129, 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);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-bottom-left-radius: 2px;
}

.chat-msg-row.user .chat-bubble {
  background: var(--chat-brand-grad);
  color: #ffffff;
  font-weight: 500;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.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(16, 185, 129, 0.05);
  border-left: 3px solid var(--chat-primary);
  border-radius: 0 6px 6px 0;
  font-size: 0.75rem;
  font-style: italic;
  color: #334155;
}

.chat-quote-source {
  font-style: normal;
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--chat-text-muted);
  margin-top: 4px;
  display: block;
}

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

.chat-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--chat-brand-grad);
  color: #ffffff !important;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.chat-action-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
  filter: brightness(1.05);
}

.chat-action-link.whatsapp-link {
  background: #16a34a;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.25);
}

.chat-action-link.whatsapp-link:hover {
  background: #15803d;
  box-shadow: 0 5px 15px rgba(22, 163, 74, 0.35);
  filter: none;
}

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

.chat-chip-btn {
  background: #ffffff;
  border: 1px solid var(--chat-border);
  color: #334155;
  font-size: 0.7188rem;
  padding: 5px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.chat-chip-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
  background: rgba(16, 185, 129, 0.08);
}

/* Typing Indicator Animation */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--chat-bg-bubble);
  border: 1px solid var(--chat-border);
  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: #0f172a;
  animation-delay: 0s;
}

.chat-typing-dot:nth-child(2) {
  background: #2563eb;
  animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
  background: #10b981;
  animation-delay: 0.4s;
}

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

/* Quick Topics Bar */
.chat-topics-bar {
  flex-shrink: 0;
  padding: 8px 14px;
  background: #f8fafc;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.6875rem;
  scrollbar-width: none;
}

.chat-topics-bar::-webkit-scrollbar {
  display: none;
}

.chat-topics-label {
  color: var(--chat-text-muted);
  font-family: monospace;
  font-weight: 600;
  text-transform: uppercase;
}

.chat-topic-tag {
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.chat-topic-tag:hover {
  color: var(--chat-primary);
  background: rgba(16, 185, 129, 0.08);
}

.chat-topic-tag.chat-topic-human {
  color: #16a34a;
  font-weight: 600;
}

.chat-topic-tag.chat-topic-human:hover {
  color: #15803d;
  background: rgba(22, 163, 74, 0.1);
}

/* Input Area */
.chat-input-form {
  flex-shrink: 0;
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-text-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  font-size: 0.8125rem;
  color: var(--chat-text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-text-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--chat-brand-grad);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
  filter: brightness(1.06);
}

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

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .wegyaan-chat-widget {
    bottom: 175px;
    right: 14px;
  }

  .chat-launcher-btn {
    width: 52px;
    height: 52px;
  }

  .wegyaan-chat-widget.chat-open {
    position: static;
  }

  .wegyaan-chat-widget.chat-open .chat-launcher-btn,
  .chat-launcher-btn.chat-launcher-hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  .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 36px rgba(15, 23, 42, 0.35);
    z-index: 100000;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .chat-header-avatar {
    width: 32px;
    height: 32px;
  }

  .chat-header-favicon {
    width: 20px;
    height: 20px;
  }

  .chat-header-title {
    font-size: 0.8125rem;
  }

  .chat-header-subtitle {
    font-size: 0.625rem;
  }

  .chat-human-bar {
    padding: 6px 12px;
  }

  .chat-human-btn {
    padding: 7px 12px;
    font-size: 0.75rem;
  }

  .chat-messages-container {
    padding: 12px;
    gap: 12px;
  }

  .chat-bubble {
    padding: 10px 12px;
  }

  .chat-topics-bar {
    padding: 6px 12px;
  }

  .chat-input-form {
    padding: 10px 12px;
  }
}
