/**
 * Leveraged Mining - Anna Client Chatbot Widget Styles
 * Version: 2.0.0
 *
 * All classes are namespaced with .lm-chat- to avoid conflicts
 * with the host application's styles.
 */

/* CSS Reset for widget container */
.lm-chat-widget,
.lm-chat-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
}

/* ========================================
   FLOATING BUTTON
   ======================================== */

.lm-chat-button {
  position: fixed;
  bottom: 56px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #65b3fe 0%, #4a9ae8 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(101, 179, 254, 0.4);
  z-index: 99998;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lm-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(101, 179, 254, 0.5);
}

.lm-chat-button:active {
  transform: scale(0.95);
}

.lm-chat-button-icon {
  width: 24px;
  height: 24px;
  fill: white;
}

.lm-chat-button-close {
  display: none;
}

.lm-chat-button.lm-chat-open .lm-chat-button-icon {
  display: none;
}

.lm-chat-button.lm-chat-open .lm-chat-button-close {
  display: block;
}

/* Notification badge */
.lm-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
}

.lm-chat-badge.lm-chat-visible {
  display: flex;
}

/* ========================================
   CHAT WINDOW
   ======================================== */

.lm-chat-window {
  position: fixed;
  bottom: 124px;
  right: 16px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
}

.lm-chat-window.lm-chat-visible {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ========================================
   HEADER
   ======================================== */

.lm-chat-header {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lm-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #65b3fe 0%, #4a9ae8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
}

.lm-chat-header-info {
  flex: 1;
}

.lm-chat-header-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.lm-chat-header-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lm-chat-header-status::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
}

.lm-chat-header-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.lm-chat-header-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lm-chat-header-close svg {
  width: 20px;
  height: 20px;
  fill: rgba(255, 255, 255, 0.7);
}

/* ========================================
   MESSAGES AREA
   ======================================== */

.lm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

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

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

.lm-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* Message bubbles */
.lm-chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: lm-chat-fade-in 0.3s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

@keyframes lm-chat-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lm-chat-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #65b3fe 0%, #4a9ae8 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.lm-chat-message-assistant {
  align-self: flex-start;
  background: white;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.lm-chat-message-assistant strong {
  font-weight: 600;
}

.lm-chat-message-assistant em {
  font-style: italic;
}

.lm-chat-message-system {
  align-self: center;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  text-align: center;
  max-width: 95%;
}

/* Typing indicator */
.lm-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.lm-chat-typing-dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: lm-chat-typing-bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes lm-chat-typing-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   INPUT AREA
   ======================================== */

.lm-chat-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-shrink: 0;
}

.lm-chat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  color: black;
}

.lm-chat-input:focus {
  border-color: #65b3fe;
}

.lm-chat-input::placeholder {
  color: #9ca3af;
}

.lm-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #65b3fe 0%, #4a9ae8 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.lm-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(101, 179, 254, 0.4);
}

.lm-chat-send:active {
  transform: scale(0.95);
}

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

.lm-chat-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* ========================================
   SESSION EXPIRED OVERLAY
   ======================================== */

.lm-chat-session-expired {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  z-index: 10;
}

.lm-chat-session-expired.lm-chat-visible {
  display: flex;
}

.lm-chat-session-expired-icon {
  width: 64px;
  height: 64px;
  fill: #65b3fe;
  margin-bottom: 16px;
}

.lm-chat-session-expired-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}

.lm-chat-session-expired-message {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 20px;
}

.lm-chat-session-expired-button {
  background: linear-gradient(135deg, #65b3fe 0%, #4a9ae8 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.lm-chat-session-expired-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(101, 179, 254, 0.4);
}

/* ========================================
   NO TOKEN WARNING
   ======================================== */

.lm-chat-no-token {
  padding: 16px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  text-align: center;
  font-size: 13px;
  color: #92400e;
  display: none;
}

.lm-chat-no-token.lm-chat-visible {
  display: block;
}

/* ========================================
   POWERED BY FOOTER
   ======================================== */

.lm-chat-footer {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.lm-chat-footer a {
  color: #6b7280;
  text-decoration: none;
}

.lm-chat-footer a:hover {
  color: #65b3fe;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  .lm-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .lm-chat-button {
    bottom: 72px;
    right: 12px;
  }
}

/* ========================================
   DARK MODE (Optional - matches if host uses dark mode)
   ======================================== */

@media (prefers-color-scheme: dark) {
  .lm-chat-window.lm-chat-dark-mode {
    background: #1f2937;
  }

  .lm-chat-window.lm-chat-dark-mode .lm-chat-messages {
    background: #111827;
  }

  .lm-chat-window.lm-chat-dark-mode .lm-chat-message-assistant {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }

  .lm-chat-window.lm-chat-dark-mode .lm-chat-input-area {
    background: #1f2937;
    border-color: #374151;
  }

  .lm-chat-window.lm-chat-dark-mode .lm-chat-input {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }

  .lm-chat-window.lm-chat-dark-mode .lm-chat-footer {
    background: #111827;
    border-color: #374151;
  }
}
