/* Cloudy Chat Widget - Salesforce Einstein-style Assistant */

.cloudy-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: 'Salesforce Sans', Arial, sans-serif;
}

.cloudy-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #0070d2;
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  outline: none;
  position: relative;
}

.cloudy-button::after {
  content: 'Chat with Cloudy';
  position: absolute;
  background-color: #032d60;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  right: 70px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.cloudy-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.7);
}

.cloudy-button:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.cloudy-button img {
  width: 32px;
  height: 32px;
}

/* Subtle pulse animation to attract attention */
@keyframes subtle-pulse {
  0% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 255, 255, 0.5); }
  50% { box-shadow: 0 2px 12px rgba(0, 112, 210, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.7); }
  100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 255, 255, 0.5); }
}

/* Apply animation only on page load, not continuously */
.cloudy-button-animated {
  animation: subtle-pulse 2s ease-in-out 2;
}

.cloudy-chat-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 350px;
  height: 450px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
  z-index: 999;
  visibility: hidden;
}

/* Hide Cloudy chat widget on mobile devices */
@media (max-width: 767px) {
  .cloudy-widget {
    display: none !important;
  }
  
  /* Mobile responsive styles */
  .cloudy-chat-container {
    width: 100%;
    height: calc(100% - 80px);
    bottom: 80px;
    right: 0;
    border-radius: 0;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }
  
  /* Adjust chat container when virtual keyboard is open */
  .cloudy-mobile-open .cloudy-chat-container {
    height: 100%;
    bottom: 0;
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
  }
  
  /* Make chat messages scroll to accommodate keyboard */
  .cloudy-mobile-open .cloudy-chat-messages {
    height: calc(100% - 120px);
  }
  
  /* Ensure the chat input stays visible above keyboard */
  .cloudy-mobile-open .cloudy-chat-input {
    position: sticky;
    bottom: 0;
    background-color: #f9f9f9;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }
  
  /* Make the send button more prominent on mobile */
  .cloudy-mobile-open .cloudy-send-button {
    width: 44px;
    height: 44px;
  }
}

.cloudy-chat-container.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
  visibility: visible;
}

.cloudy-chat-header {
  background-color: #0070d2;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cloudy-chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cloudy-chat-header-title img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.cloudy-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.cloudy-close-button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
}

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

.cloudy-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.4;
  font-size: 14px;
  position: relative;
  animation: fadeIn 0.3s;
}

.cloudy-message-assistant {
  background-color: #f2f7fc;
  border-left: 3px solid #0070d2;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.cloudy-message-user {
  background-color: #0070d2;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.cloudy-chat-input {
  padding: 12px;
  border-top: 1px solid #e5e5e5;
  background-color: #f9f9f9;
  position: relative;
}

.cloudy-chat-input form {
  display: flex;
  align-items: center;
  position: relative;
}

.cloudy-chat-input input {
  flex: 1;
  padding: 10px 12px;
  padding-right: 45px; /* Make room for the send button */
  border: 1px solid #d8dde6;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.cloudy-chat-input input:focus {
  border-color: #0070d2;
}

.cloudy-send-button {
  margin-left: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #0070d2;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.cloudy-send-button:hover {
  background-color: #005fb2;
}

.cloudy-send-button:disabled {
  background-color: #dddbda;
  cursor: not-allowed;
}

/* Mobile-specific styles for the chat input */
@media (max-width: 767px) {
  .cloudy-chat-input {
    padding: 10px;
    padding-bottom: env(safe-area-inset-bottom, 10px); /* Handle iPhone notch */
  }
  
  .cloudy-chat-input form {
    position: relative;
  }
  
  .cloudy-chat-input input {
    width: 100%;
    padding-right: 45px;
    height: 44px; /* Larger touch target */
  }
  
  .cloudy-send-button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
    width: 40px;
    height: 40px;
  }
}

.cloudy-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background-color: #f2f7fc;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  max-width: 80px;
  align-self: flex-start;
  animation: fadeIn 0.3s;
}

.cloudy-typing-dot {
  width: 8px;
  height: 8px;
  background-color: #0070d2;
  border-radius: 50%;
  animation: typingAnimation 1.4s infinite ease-in-out;
}

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

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

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

@keyframes typingAnimation {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

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

/* Responsive adjustments */
@media (max-width: 480px) {
  .cloudy-chat-container {
    width: calc(100% - 40px);
    height: 60vh;
    bottom: 80px;
  }
}
