/* ==========================================================================
   LUNXCLOUD - Next-Gen Live Assistant & Problem Solver Engine
   Cyber Glassmorphism, Animated Diagnostics, Troubleshooting Cards, Responsive
   ========================================================================== */

/* Launcher Button Enhancements */
.chat-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #06b6d4 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.45), 0 0 20px rgba(6, 182, 212, 0.35);
  cursor: pointer !important;
  pointer-events: auto !important;
  z-index: 9999 !important;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  user-select: none;
}

.chat-launcher-btn * {
  pointer-events: none !important;
}

.chat-launcher-btn:hover {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.6), 0 0 30px rgba(6, 182, 212, 0.5);
}

.chat-launcher-btn svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
}

.chat-launcher-btn:hover svg {
  transform: rotate(8deg) scale(1.08);
}

.chat-launcher-btn .pulse-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, 0.6);
  animation: pulseBeacon 2.2s infinite;
  pointer-events: none !important;
}

@keyframes pulseBeacon {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.chat-bubble-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
  box-shadow: 0 0 8px #10b981;
}

/* Chat Floating Window */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 410px;
  height: 620px;
  max-height: calc(100vh - 120px);
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.35) !important;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(99, 102, 241, 0.25) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 10000 !important;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(24px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s;
}

.chat-window.active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* Chat Fullscreen Mode */
.chat-window.fullscreen {
  width: 820px;
  max-width: calc(100vw - 40px);
  height: calc(100vh - 100px);
  bottom: 50px;
  right: 20px;
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

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

.chat-bot-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.chat-bot-avatar svg {
  width: 22px;
  height: 22px;
}

.chat-avatar-status {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
  box-shadow: 0 0 6px #10b981;
}

.chat-header-text h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.chat-badge-specialist {
  background: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.chat-header-text p {
  font-size: 0.74rem;
  color: #94a3b8;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-status-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  display: inline-block;
}

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

.chat-action-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-action-icon-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

.chat-action-icon-btn.active {
  color: #06b6d4;
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.4);
}

/* Quick Problem Chips / Category Navigation Slider */
.chat-chips-slider-wrap {
  position: relative;
  background: rgba(10, 15, 29, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 4px 6px;
  gap: 4px;
}

.chat-chips-nav-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.chat-chips-nav-btn:hover {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
  transform: scale(1.12);
}

.chat-quick-chips-bar {
  flex: 1;
  padding: 4px 4px 6px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scroll-behavior: smooth;
  cursor: grab;
  user-select: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.chat-quick-chips-bar.grabbing {
  cursor: grabbing !important;
  scroll-behavior: auto;
}

/* Custom mini-scrollbar */
.chat-quick-chips-bar::-webkit-scrollbar {
  height: 3px;
}

.chat-quick-chips-bar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
}

.chat-quick-chips-bar::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.4);
  border-radius: 2px;
}

.chat-quick-chips-bar::-webkit-scrollbar-thumb:hover {
  background: #06b6d4;
}

.chat-chip-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #94a3b8;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-chip-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #e2e8f0;
  transform: translateY(-1px);
}

.chat-chip-btn.highlight {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.4);
  color: #38bdf8;
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Message Bubble */
.chat-msg {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeInMsg 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

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

.chat-msg.bot {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.chat-msg.user {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.chat-msg-time {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
  text-align: right;
}

/* Rich Card Elements inside Bot Message */
.chat-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
}

.chat-card-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* Step-by-Step List */
.chat-step-list {
  margin: 8px 0 8px 18px;
  padding: 0;
  color: #cbd5e1;
  font-size: 0.84rem;
  line-height: 1.6;
}

.chat-step-list li {
  margin-bottom: 6px;
}

.chat-step-list strong {
  color: #ffffff;
}

/* Code Snippet with Copy Button */
.chat-code-block {
  position: relative;
  background: #090d16;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  padding: 10px 38px 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #10b981;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text;
}

.chat-copy-code-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 3px;
}

.chat-copy-code-btn:hover {
  background: #6366f1;
  color: #ffffff;
}

/* Action Buttons inside Chat */
.chat-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chat-action-pill {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.chat-action-pill:hover {
  background: #6366f1;
  border-color: #6366f1;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.chat-action-pill.cyan {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.35);
  color: #67e8f9;
}

.chat-action-pill.cyan:hover {
  background: #06b6d4;
  border-color: #06b6d4;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.chat-action-pill.whatsapp {
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.35);
  color: #4ade80;
}

.chat-action-pill.whatsapp:hover {
  background: #25d366;
  border-color: #25d366;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

/* Diagnostic Scanner Tool Card */
.chat-diagnostic-tool {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.8) 100%);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-top: 10px;
}

.chat-diagnostic-input-wrap {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}

.chat-diagnostic-input {
  flex: 1;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 7px 10px;
  color: #ffffff;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
}

.chat-diagnostic-btn {
  background: #06b6d4;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chat-diagnostic-btn:hover {
  background: #0891b2;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.5);
}

.chat-scan-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
}

.chat-scan-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.chat-scan-step.passed {
  color: #10b981;
}

.chat-scan-step.warning {
  color: #f59e0b;
}

.chat-scan-step.failed {
  color: #ef4444;
}

.chat-scan-step.pending {
  color: #64748b;
}

/* Typing Indicator */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  align-self: flex-start;
  width: fit-content;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Bottom Input Area */
.chat-input-area {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-box {
  flex: 1;
  padding: 10px 14px;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.chat-input-box:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.chat-input-box::placeholder {
  color: #64748b;
  font-size: 0.84rem;
}

.chat-send-btn {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.chat-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

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

.chat-input-footnote {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #64748b;
  padding: 0 2px;
}

.chat-input-footnote a {
  color: #06b6d4;
  text-decoration: none;
}

.chat-input-footnote a:hover {
  text-decoration: underline;
}

/* Chat Launcher Floating Side Pill */
.chat-launcher-pill {
  position: absolute;
  right: 70px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(99, 102, 241, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: floatChatPill 3s infinite ease-in-out;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes floatChatPill {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.chat-launcher-pill .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Light Theme Support */
[data-theme="light"] .chat-window {
  background: rgba(255, 255, 255, 0.98) !important;
  border-color: rgba(99, 102, 241, 0.25) !important;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18) !important;
}

[data-theme="light"] .chat-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .chat-header-text h4 {
  color: #0f172a !important;
}

[data-theme="light"] .chat-header-text p {
  color: #64748b !important;
}

[data-theme="light"] .chat-chips-slider-wrap {
  background: #f8fafc !important;
  border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .chat-chip-btn {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #475569 !important;
}

[data-theme="light"] .chat-msg.bot {
  background: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #1e293b !important;
}

[data-theme="light"] .chat-card {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .chat-input-area {
  background: #ffffff !important;
  border-top-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .chat-input-box {
  background: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

[data-theme="light"] .chat-launcher-pill {
  background: #ffffff !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
  color: #0f172a !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12) !important;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .chat-window {
    width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    z-index: 100000 !important;
  }

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

  .chat-launcher-pill {
    display: none;
  }
}
