/* ==========================================
   MR Web Solutions - AI Chat Widget styles
   Extracted verbatim from the previous styles.css so the
   live chatbot (chatbot.js) is unaffected by site redesigns.
   Depends on CSS variables defined in styles.css.
   ========================================== */

/* --- Chat Widget --- */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--font-body);
}

/* Toggle Button */
.chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 4px 24px rgba(68, 217, 245, 0.25),
    0 8px 32px rgba(0, 0, 0, 0.4);
  transition: var(--transition);
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 32px rgba(68, 217, 245, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.5);
}

.chat-toggle-icon.close {
  display: none;
}

.chat-widget.open .chat-toggle-icon.open {
  display: none;
}

.chat-widget.open .chat-toggle-icon.close {
  display: block;
}

.chat-toggle-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  animation: chatPulse 2s ease-in-out infinite;
}

.chat-widget.open .chat-toggle-pulse,
.chat-widget.interacted .chat-toggle-pulse {
  display: none;
}

@keyframes chatPulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* Chat Panel */
.chat-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-height: 560px;
  background: var(--bg-surface);
  border: 2px solid rgba(106, 90, 224, 0.6);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  box-shadow:
    0 16px 64px rgba(0, 0, 0, 0.5),
    0 0 35px rgba(106, 90, 224, 0.2),
    0 0 80px rgba(68, 217, 245, 0.1);
}

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

/* Panel Header */
.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.chat-panel-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-panel-avatar img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.chat-panel-info {
  flex: 1;
}

.chat-panel-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  color: var(--text-primary);
}

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

.chat-panel-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

/* Language Toggle */
.chat-panel-lang {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid rgba(106, 90, 224, 0.3);
  border-radius: 100px;
  padding: 2px;
  flex-shrink: 0;
}

.chat-lang-btn {
  padding: 3px 10px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.03em;
}

.chat-lang-btn.active {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
}

.chat-lang-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Ellipsis Menu */
.chat-menu-wrapper {
  position: relative;
  flex-shrink: 0;
}

.chat-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chat-menu-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.chat-menu-dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  min-width: 150px;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.chat-menu-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chat-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.chat-menu-item:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.chat-menu-item svg {
  flex-shrink: 0;
  color: var(--accent-cyan);
}

/* Messages Area */
.chat-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 320px;
  scroll-behavior: smooth;
}

.chat-panel-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-panel-messages::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

/* Message Bubbles */
.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.55;
  animation: chatBubbleIn 0.3s ease-out;
  word-wrap: break-word;
}

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

.chat-bubble.bot {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  color: var(--text-primary);
}

.chat-bubble.user {
  background: linear-gradient(135deg, rgba(68, 217, 245, 0.15), rgba(106, 90, 224, 0.1));
  border: 1px solid rgba(68, 217, 245, 0.35);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  color: var(--text-primary);
}

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

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

.chat-bubble.bot strong {
  color: var(--accent-cyan);
  font-weight: 600;
}

.chat-bubble.bot ul,
.chat-bubble.bot ol {
  margin: 4px 0;
  padding-left: 18px;
}

.chat-bubble.bot li {
  margin-bottom: 2px;
}

.chat-bubble.bot .chat-label {
  color: var(--accent-cyan);
  margin: 4px 0 2px;
  font-size: 0.88rem;
}

/* Typing Indicator */
.chat-bubble.typing {
  padding: 14px 20px;
}

.chat-typing-dots {
  display: flex;
  gap: 5px;
}

.chat-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

/* Quick Replies */
.chat-panel-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.chat-panel-quick-replies:empty {
  display: none;
}

.chat-quick-btn {
  padding: 7px 14px;
  background: var(--glass-bg);
  border: 1px solid rgba(68, 217, 245, 0.35);
  border-radius: 100px;
  color: var(--accent-cyan);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chat-quick-btn:hover {
  background: rgba(68, 217, 245, 0.1);
  border-color: rgba(68, 217, 245, 0.35);
  transform: translateY(-1px);
}

/* Input Area */
.chat-panel-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--glass-border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.chat-panel-input input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 100px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: var(--transition);
}

.chat-panel-input input:focus {
  border-color: rgba(68, 217, 245, 0.3);
  box-shadow: 0 0 0 3px rgba(68, 217, 245, 0.08);
}

.chat-panel-input input::placeholder {
  color: var(--text-muted);
}

.chat-panel-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-panel-send:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(68, 217, 245, 0.3);
}

.chat-panel-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Branding */
.chat-panel-branding {
  text-align: center;
  padding: 6px 16px 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-panel-branding a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 500;
}

.chat-panel-branding a:hover {
  text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .chat-toggle {
    width: 54px;
    height: 54px;
  }

  .chat-panel {
    width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    right: -8px;
    bottom: 68px;
  }

  .chat-panel-messages {
    max-height: calc(100vh - 300px);
  }
}
