/**
 * Navi AI — Chat Widget Styles (Frontend)
 *
 * Scoped to .navi-ai-* to avoid conflicts with themes.
 *
 * @package Navi_AI
 */

/* =========================================================================
   Container
   ========================================================================= */

.navi-ai-widget-container {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
  box-sizing: border-box;
}

.navi-ai-widget-container[data-position="right"] {
  right: 24px;
}

.navi-ai-widget-container[data-position="left"] {
  left: 24px;
}

.navi-ai-widget-container *,
.navi-ai-widget-container *::before,
.navi-ai-widget-container *::after {
  box-sizing: border-box;
}

/* =========================================================================
   Toggle Button
   ========================================================================= */

.navi-ai-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.navi-ai-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.navi-ai-toggle-btn:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.navi-ai-icon-close {
  display: none;
}

.navi-ai-open .navi-ai-icon-chat {
  display: none;
}

.navi-ai-open .navi-ai-icon-close {
  display: block;
}

/* =========================================================================
   Chat Window
   ========================================================================= */

.navi-ai-chat-window {
  position: absolute;
  bottom: 72px;
  width: 380px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  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 ease;
}

.navi-ai-widget-container[data-position="right"] .navi-ai-chat-window {
  right: 0;
}

.navi-ai-widget-container[data-position="left"] .navi-ai-chat-window {
  left: 0;
}

.navi-ai-open .navi-ai-chat-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* =========================================================================
   Header
   ========================================================================= */

.navi-ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  color: #ffffff;
  flex-shrink: 0;
}

.navi-ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navi-ai-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.navi-ai-chat-header-text {
  display: flex;
  flex-direction: column;
}

.navi-ai-chat-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.navi-ai-chat-subtitle {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}

.navi-ai-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.navi-ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* =========================================================================
   Messages
   ========================================================================= */

.navi-ai-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 340px;
  scroll-behavior: smooth;
}

.navi-ai-message {
  display: flex;
  max-width: 85%;
  animation: naviAiFadeIn 0.25s ease;
}

.navi-ai-message-bot {
  align-self: flex-start;
}

.navi-ai-message-user {
  align-self: flex-end;
}

.navi-ai-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.navi-ai-message-bot .navi-ai-bubble {
  background: #f0f0f0;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.navi-ai-message-user .navi-ai-bubble {
  background: #4F46E5;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* =========================================================================
   Typing Indicator
   ========================================================================= */

.navi-ai-typing .navi-ai-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.navi-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: naviAiBounce 1.4s infinite ease-in-out both;
}

.navi-ai-dot:nth-child(1) {
  animation-delay: 0s;
}

.navi-ai-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.navi-ai-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes naviAiBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes naviAiFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================================
   Input Area
   ========================================================================= */

.navi-ai-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eaeaea;
  background: #fafafa;
}

.navi-ai-chat-input {
  flex: 1 1 auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  background: #fff;
  color: #1a1a1a;
  transition: border-color 0.15s ease;
}

.navi-ai-chat-input:focus {
  outline: none;
  border-color: #4F46E5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.navi-ai-chat-input::placeholder {
  color: #999;
}

.navi-ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.navi-ai-chat-send:hover {
  opacity: 0.9;
}

/* =========================================================================
   Powered By
   ========================================================================= */

.navi-ai-powered-by {
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #999;
  background: #fafafa;
}

.navi-ai-powered-by strong {
  color: #666;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 480px) {
  .navi-ai-chat-window {
    width: calc(100vw - 32px);
    max-height: 70vh;
    bottom: 72px;
  }

  .navi-ai-widget-container {
    bottom: 16px;
  }

  .navi-ai-widget-container[data-position="right"] {
    right: 16px;
  }

  .navi-ai-widget-container[data-position="left"] {
    left: 16px;
  }
}
