/* ProBLife Chatbot Widget Styles */

:root {
  --problife-primary: #2563eb;
  --problife-secondary: #1e40af;
  --problife-bg: #ffffff;
  --problife-text: #1f2937;
  --problife-border: #e5e7eb;
  --problife-success: #10b981;
  --problife-assistant: #f3f4f6;
  --problife-user: #dbeafe;
}

.problife-chatbot.dark {
  --problife-bg: #1f2937;
  --problife-text: #f3f4f6;
  --problife-border: #374151;
  --problife-assistant: #374151;
  --problife-user: #1e40af;
}

#problife-chatbot-container {
  position: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  z-index: 9999;
  bottom: 20px;
  right: 20px;
}

body.problife-chatbot-open {
  overflow: hidden;
}

#problife-chatbot-container.bottom-left {
  right: auto;
  left: 20px;
}

/* Toggle Button */
.problife-chatbot-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--problife-primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 24px;
}

.problife-chatbot-toggle:hover {
  background-color: var(--problife-secondary);
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.problife-chatbot-toggle:active {
  transform: scale(0.95);
}

/* Chat Window */
.problife-chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 400px;
  height: 600px;
  background-color: var(--problife-bg);
  border-radius: 12px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

#problife-chatbot-container.bottom-left .problife-chatbot-window {
  right: auto;
  left: 0;
}

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

.problife-chatbot-window.hidden {
  display: none;
}

/* Header */
.problife-chatbot-header {
  background: linear-gradient(135deg, var(--problife-primary) 0%, var(--problife-secondary) 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--problife-border);
}

.problife-chatbot-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.problife-chatbot-title p {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.problife-chatbot-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.problife-chatbot-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Messages Container */
.problife-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--problife-bg);
}

/* Message Styles */
.problife-message {
  display: flex;
  animation: messageIn 0.3s ease;
}

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

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

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

.problife-message-error {
  justify-content: flex-start;
}

.problife-message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.problife-message-user .problife-message-content {
  background-color: var(--problife-user);
  color: var(--problife-text);
  border-bottom-right-radius: 4px;
}

.problife-message-assistant .problife-message-content {
  background-color: var(--problife-assistant);
  color: var(--problife-text);
  border-bottom-left-radius: 4px;
}

.problife-message-error .problife-message-content {
  background-color: #fee2e2;
  color: #991b1b;
  border-bottom-left-radius: 4px;
}

/* Handoff Message */
.problife-handoff-message {
  padding: 16px;
  background-color: #ecfdf5;
  border-radius: 12px;
  border-left: 4px solid var(--problife-success);
}

.problife-handoff-message .problife-message-content {
  background-color: transparent;
  padding: 0;
  margin-bottom: 12px;
}

.problife-handoff-message .problife-message-content p {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #1f2937;
}

.problife-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: #25d366;
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.2s;
  border: none;
  cursor: pointer;
}

.problife-whatsapp-btn:hover {
  background-color: #20ba5a;
}

/* Input Area */
.problife-chatbot-input-area {
  display: flex;
  gap: 8px;
  padding: 16px;
  background-color: var(--problife-bg);
  border-top: 1px solid var(--problife-border);
}

.problife-message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--problife-border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--problife-text);
  background-color: var(--problife-bg);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.problife-message-input:focus {
  border-color: var(--problife-primary);
}

.problife-message-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.problife-message-input::placeholder {
  color: #9ca3af;
}

.problife-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  background-color: var(--problife-primary);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.problife-send-btn:hover {
  background-color: var(--problife-secondary);
}

.problife-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Scrollbar */
.problife-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.problife-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.problife-chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--problife-border);
  border-radius: 3px;
}

.problife-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #d1d5db;
}

/* Responsive Design */
@media (max-width: 480px) {
  #problife-chatbot-container {
    bottom: 0;
    right: 0;
    left: 0;
    max-width: 100vw;
  }

  #problife-chatbot-container.bottom-left {
    left: 0;
  }

  .problife-chatbot-window {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    animation: none;
  }

  #problife-chatbot-container.bottom-left .problife-chatbot-window {
    left: 0;
  }

  .problife-chatbot-toggle {
    width: 48px;
    height: 48px;
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  #problife-chatbot-container.bottom-left .problife-chatbot-toggle {
    right: auto;
    left: 16px;
  }

  #problife-chatbot-container.chat-open .problife-chatbot-toggle {
    display: none;
  }

  .problife-chatbot-header {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }

  .problife-chatbot-input-area {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .problife-chatbot-messages {
    padding: 16px;
  }
}

/* Typing indicator */
.problife-typing-content {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  min-width: 40px;
}

.problife-typing-content span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #9ca3af;
  display: inline-block;
  animation: problife-bounce 1.2s infinite ease-in-out;
}

.problife-typing-content span:nth-child(1) { animation-delay: 0s; }
.problife-typing-content span:nth-child(2) { animation-delay: 0.2s; }
.problife-typing-content span:nth-child(3) { animation-delay: 0.4s; }

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