/* ═══════════════════════════════════════════
   HighPex AI Assistant — Chat Widget
   ═══════════════════════════════════════════ */

/* Chat Button */
.ai-chat-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79,142,255,0.95), rgba(162,89,255,0.95));
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 4px 24px rgba(79,142,255,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 99999;
  color: #fff;
  font-size: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.ai-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(79,142,255,0.5), 0 0 0 1px rgba(255,255,255,0.15) inset;
}

.ai-chat-button:active {
  transform: scale(0.92);
}

.ai-chat-button.active {
  display: none;
}

/* Chat Container */
.ai-chat-container {
  position: fixed;
  bottom: 100px;
  right: 32px;
  width: 380px;
  height: 580px;
  background: rgba(16,16,30,0.94);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06) inset;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  animation: chatOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatOpen {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-chat-container.active {
  display: flex;
}

/* Glass shine effect */
.ai-chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(255,255,255,0.2) 25%, rgba(255,255,255,0.25) 50%, rgba(255,255,255,0.2) 75%, transparent 95%);
  pointer-events: none;
}

.ai-chat-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.01) 30%, transparent 60%);
  pointer-events: none;
}

/* Chat Header */
.ai-chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.ai-chat-header-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-header-title i {
  color: #4f8eff;
}

.ai-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
}

.ai-chat-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ai-chat-reset {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  margin-right: 8px;
}

.ai-chat-reset:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: rotate(180deg);
}

/* Chat Messages Area */
.ai-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

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

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.15);
}

/* Message Bubble */
.ai-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.ai-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(79,142,255,0.3), rgba(162,89,255,0.3));
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #4f8eff;
  font-size: 16px;
}

.user-message .ai-message-avatar {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  color: rgba(255,255,255,0.7);
}

.ai-message-content {
  flex: 1;
}

.ai-message-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
}

.user-message .ai-message-bubble {
  background: linear-gradient(135deg, rgba(79,142,255,0.2), rgba(162,89,255,0.2));
  border-color: rgba(79,142,255,0.3);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(79,142,255,0.6);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Language Selection Buttons */
.language-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.language-btn {
  flex: 1;
  padding: 10px 20px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.2s ease;
}

.language-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}

.language-btn:active {
  transform: scale(0.98);
}

/* Chat Input Area */
.ai-chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  position: relative;
  z-index: 1;
  display: none;
}

.ai-chat-input-area.active {
  display: block;
}

.ai-chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #fff;
  resize: none;
  max-height: 120px;
  min-height: 44px;
  transition: all 0.2s ease;
}

.ai-chat-input:focus {
  outline: none;
  background: rgba(255,255,255,0.07);
  border-color: rgba(79,142,255,0.4);
  box-shadow: 0 0 0 3px rgba(79,142,255,0.1);
}

.ai-chat-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.ai-chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(79,142,255,0.75), rgba(162,89,255,0.75));
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(79,142,255,0.35);
  background: linear-gradient(135deg, rgba(79,142,255,0.85), rgba(162,89,255,0.85));
}

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

/* Thinking Indicator - Gemini Style */
.ai-thinking-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(162,89,255,0.9);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  padding: 12px 16px;
}

.ai-thinking-status i {
  color: rgba(162,89,255,0.8);
  animation: pulse 1.5s ease-in-out infinite;
}

.thinking-dots {
  display: inline-block;
}

.thinking-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

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

/* AI Thinking Indicator */
.ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(162,89,255,0.8);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 4px;
}

.ai-thinking-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(162,89,255,0.3);
  border-top-color: rgba(162,89,255,0.8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Knowledge Base Articles */
.kb-articles-message .ai-message-avatar {
  background: linear-gradient(135deg, rgba(79,142,255,0.3), rgba(162,89,255,0.3));
  color: #a259ff;
}

.kb-articles-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(162,89,255,0.08);
  border: 1px solid rgba(162,89,255,0.15);
  border-radius: 10px;
  margin-bottom: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(162,89,255,0.9);
}

.kb-articles-header i {
  font-size: 0.9rem;
}

.kb-articles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-article-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 14px 16px;
  transition: all 0.2s ease;
}

.kb-article-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(79,142,255,0.3);
  transform: translateX(2px);
}

.kb-article-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.4;
}

.kb-article-excerpt {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-article-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(79,142,255,0.15), rgba(162,89,255,0.15));
  border: 1px solid rgba(79,142,255,0.3);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4f8eff;
  text-decoration: none;
  transition: all 0.2s ease;
}

.kb-article-link:hover {
  background: linear-gradient(135deg, rgba(79,142,255,0.25), rgba(162,89,255,0.25));
  border-color: rgba(79,142,255,0.5);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(79,142,255,0.2);
}

.kb-article-link i {
  font-size: 0.75rem;
}

/* Service Buttons */
.service-buttons-message .ai-message-avatar {
  background: linear-gradient(135deg, rgba(79,142,255,0.3), rgba(162,89,255,0.3));
  color: #4f8eff;
}

.service-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.service-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 85px;
}

.service-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  border-color: rgba(79,142,255,0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79,142,255,0.2);
}

.service-btn:active:not(:disabled) {
  transform: translateY(0);
}

.service-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.service-btn i {
  font-size: 1.5rem;
  color: #4f8eff;
}

.service-btn span {
  text-align: center;
  line-height: 1.3;
}

/* Service Action Link */
.service-action-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(79,142,255,0.2), rgba(162,89,255,0.2));
  border: 1px solid rgba(79,142,255,0.4);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4f8eff;
  text-decoration: none;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: space-between;
}

.service-action-link:hover {
  background: linear-gradient(135deg, rgba(79,142,255,0.3), rgba(162,89,255,0.3));
  border-color: rgba(79,142,255,0.6);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(79,142,255,0.3);
}

.service-action-link i {
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.service-action-link:hover i {
  transform: translateX(4px);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-chat-container {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 16px;
    right: 16px;
  }

  .ai-chat-button {
    bottom: 16px;
    right: 16px;
  }
}
