/**
 * Product Expert Chat Widget Styles
 * Brand-matched to Virtasenkauppa.fi design
 */

/* Main widget container */
#product-expert-chat {
  margin: 20px 0;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

/* Header */
.pe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #f7f7f7;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
}

.pe-title {
  font-size: 16px;
  font-weight: 600;
  color: #111111;
}

.pe-collapse-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  font-weight: bold;
  color: #0a3fa0;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.pe-collapse-btn:hover {
  transform: scale(1.2);
}

/* Content area */
.pe-content {
  padding: 15px;
}

#product-expert-chat.collapsed .pe-content {
  display: none;
}

/* Conversation area */
.pe-conversation {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 15px;
  padding-right: 5px;
}

/* Scrollbar styling */
.pe-conversation::-webkit-scrollbar {
  width: 6px;
}

.pe-conversation::-webkit-scrollbar-track {
  background: #f7f7f7;
  border-radius: 3px;
}

.pe-conversation::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.pe-conversation::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Messages */
.pe-message {
  margin-bottom: 12px;
  display: flex;
  animation: fadeIn 0.3s ease;
}

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

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

.pe-message-assistant {
  justify-content: flex-start;
}

.pe-message-content {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.5;
  word-wrap: break-word;
}

.pe-message-user .pe-message-content {
  background: #0a3fa0;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.pe-message-assistant .pe-message-content {
  background: #f7f7f7;
  color: #111111;
  border-bottom-left-radius: 2px;
}

/* Markdown formatting in assistant messages */
.pe-message-assistant .pe-message-content strong {
  font-weight: 600;
  color: #000000;
}

.pe-message-assistant .pe-message-content em {
  font-style: italic;
}

.pe-message-assistant .pe-message-content br {
  line-height: 1.8;
}

/* Typing indicator */
#pe-typing-indicator .pe-message-content {
  background: #f7f7f7;
  color: #666;
  font-style: italic;
}

.pe-dots {
  animation: blink 1.4s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* Streaming message indicator */
#pe-streaming-message .pe-message-content {
  position: relative;
}

#pe-streaming-message .pe-message-content::after {
  content: '▋';
  animation: cursorBlink 1s infinite;
  margin-left: 2px;
  color: #0a3fa0;
}

@keyframes cursorBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Starter questions */
.pe-starter-questions {
  margin-top: 20px;
  margin-bottom: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Hide border when no messages yet */
.pe-conversation:empty + .pe-starter-questions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.pe-starter-btn {
  background: #ffffff;
  border: 1px solid #0a3fa0;
  color: #0a3fa0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.pe-starter-btn:hover {
  background: #0a3fa0;
  color: #ffffff;
}

/* Input area */
.pe-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pe-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.pe-input:focus {
  outline: none;
  border-color: #0a3fa0;
  box-shadow: 0 0 0 2px rgba(10, 63, 160, 0.1);
}

.pe-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.pe-send-btn {
  background: #4f81db;
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.pe-send-btn:hover:not(:disabled) {
  background: #3d6bc4;
}

.pe-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Error messages */
.pe-error {
  padding: 10px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 4px;
  color: #c00;
  font-size: 13px;
  margin-bottom: 10px;
  animation: fadeIn 0.3s ease;
}

/* Responsive design */
@media (max-width: 768px) {
  .pe-conversation {
    max-height: 250px;
  }

  .pe-message-content {
    max-width: 85%;
    font-size: 14px;
  }

  .pe-starter-btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .pe-input {
    font-size: 13px;
  }

  .pe-send-btn {
    padding: 10px 15px;
    font-size: 13px;
  }
}

/* Mobile - very small screens */
@media (max-width: 480px) {
  .pe-input-area {
    flex-direction: column;
    gap: 8px;
  }

  .pe-input,
  .pe-send-btn {
    width: 100%;
  }

  .pe-starter-questions {
    flex-direction: column;
  }

  .pe-starter-btn {
    width: 100%;
  }
}
