/**
 * AI Sales Agent - Chat Widget Styles
 */

/* Chat Widget Container */
.aisales-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  transition: all 0.3s ease;
}

/* Chat Button */
.aisales-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #0073aa;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.aisales-chat-button:hover {
  transform: scale(1.05);
  background-color: #005d87;
}

.aisales-chat-button svg {
  width: 30px;
  height: 30px;
  fill: white;
}

.aisales-chat-button.active {
  transform: scale(0);
  opacity: 0;
}

/* Chat Window */
.aisales-chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  height: 500px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
}

.aisales-chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Chat Header */
.aisales-chat-header {
  padding: 15px 20px;
  background-color: #0073aa;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aisales-chat-header-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
}

.aisales-chat-header-title svg {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  fill: white;
}

.aisales-chat-close {
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.aisales-chat-close:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

.aisales-chat-close svg {
  width: 16px;
  height: 16px;
  fill: white;
}

/* Chat Messages Container */
.aisales-chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background-color: #f5f8fa;
}

/* Message Bubbles */
.aisales-message {
  display: flex;
  margin-bottom: 15px;
  position: relative;
  clear: both;
}

.aisales-message-user {
  justify-content: flex-end;
}

.aisales-message-bot {
  justify-content: flex-start;
}

.aisales-message-content {
  max-width: 70%;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
}

.aisales-message-user .aisales-message-content {
  background-color: #0073aa;
  color: white;
  border-bottom-right-radius: 5px;
}

.aisales-message-bot .aisales-message-content {
  background-color: white;
  color: #333;
  border-bottom-left-radius: 5px;
}

/* Typing Indicator */
.aisales-typing-indicator {
  display: none;
  align-items: center;
  margin-bottom: 15px;
}

.aisales-typing-indicator.active {
  display: flex;
}

.aisales-typing-indicator .aisales-message-content {
  background-color: white;
  color: #333;
  border-bottom-left-radius: 5px;
  padding: 12px 15px;
  display: flex;
}

.aisales-typing-indicator .dot {
  width: 8px;
  height: 8px;
  background-color: #bbb;
  border-radius: 50%;
  margin: 0 3px;
  animation: typing-dot 1.4s infinite ease-in-out;
}

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

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

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

@keyframes typing-dot {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-5px);
  }
}

/* Product Recommendations */
.aisales-product-recommendations {
  margin-top: 10px;
  margin-bottom: 15px;
  display: flex;
  overflow-x: auto;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.aisales-product-card {
  flex: 0 0 auto;
  width: 140px;
  margin-right: 10px;
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}

.aisales-product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.aisales-product-image {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f9f9f9;
  overflow: hidden;
}

.aisales-product-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.aisales-product-info {
  padding: 10px;
}

.aisales-product-title {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aisales-product-price {
  font-size: 13px;
  font-weight: 700;
  color: #0073aa;
}

/* Input Area */
.aisales-chat-input {
  padding: 15px;
  background-color: white;
  border-top: 1px solid #eaeaea;
  display: flex;
}

.aisales-chat-input-box {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 14px;
  resize: none;
  outline: none;
  height: 40px;
  line-height: 20px;
  max-height: 100px;
  overflow-y: auto;
  
  /* Prevent rich text formatting */
  -webkit-user-modify: read-write-plaintext-only;
  white-space: pre-wrap;
  word-wrap: break-word;
  
  /* Disable file drop styling */
  -webkit-user-drag: none;
  -moz-user-drag: none;
  user-drag: none;
}

.aisales-chat-input-box:focus {
  border-color: #0073aa;
}

/* Drag and drop feedback */
.aisales-chat-input-box.drag-over {
  border-color: #ff6b6b;
  background-color: #ffe6e6;
}

/* Prevent rich text formatting while preserving normal typing */
.aisales-chat-input-box b,
.aisales-chat-input-box strong {
  font-weight: normal !important;
}

.aisales-chat-input-box i,
.aisales-chat-input-box em {
  font-style: normal !important;
}

.aisales-chat-input-box u {
  text-decoration: none !important;
}

.aisales-chat-input-box span[style],
.aisales-chat-input-box div[style],
.aisales-chat-input-box p[style] {
  color: inherit !important;
  background: none !important;
  font-size: inherit !important;
  font-weight: normal !important;
  font-style: normal !important;
}

/* File upload prevention visual feedback */
.aisales-file-upload-blocked {
  background-color: #ffe6e6;
  border-color: #ff6b6b;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Undo/Redo visual feedback */
.aisales-chat-input-box.undo-applied {
  box-shadow: 0 0 0 2px #28a745;
  animation: undoFeedback 0.3s ease-in-out;
}

.aisales-chat-input-box.redo-applied {
  box-shadow: 0 0 0 2px #007bff;
  animation: redoFeedback 0.3s ease-in-out;
}

@keyframes undoFeedback {
  0% { box-shadow: 0 0 0 2px #28a745; }
  50% { box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.3); }
  100% { box-shadow: 0 0 0 2px #28a745; }
}

@keyframes redoFeedback {
  0% { box-shadow: 0 0 0 2px #007bff; }
  50% { box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.3); }
  100% { box-shadow: 0 0 0 2px #007bff; }
}

.aisales-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #0073aa;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.aisales-chat-send:hover {
  background-color: #005d87;
}

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

.aisales-chat-send.disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* Chat Persistence Styles */
.aisales-restoration-indicator {
  background-color: #e8f5e8;
  color: #4a7c4a;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  margin-bottom: 10px;
  border: 1px solid #d4edda;
}

.aisales-new-chat-container {
  text-align: center;
  margin-bottom: 15px;
  padding: 10px;
  border-bottom: 1px solid #eee;
}

.aisales-new-chat-btn {
  background-color: #f8f9fa;
  color: #6c757d;
  border: 1px solid #dee2e6;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.aisales-new-chat-btn:hover {
  background-color: #e9ecef;
  color: #495057;
}

.aisales-new-chat-btn:active {
  background-color: #dee2e6;
}

/* Responsive Styles */
@media (max-width: 576px) {
  .aisales-chat-window {
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .aisales-chat-button {
    bottom: 10px;
    right: 10px;
  }
}
