/**
 * EMOCOM Chat Widget Styles
 * Simplified, clean implementation with proper positioning and z-index
 */

/* Chat widget variables */
:root {
  --chat-primary: #1e40af;
  --chat-primary-hover: #1d4ed8;
  --chat-bg: #ffffff;
  --chat-text: #1e293b;
  --chat-text-light: #64748b;
  --chat-border: #e2e8f0;
  --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  --chat-border-radius: 16px;
  --chat-transition: all 0.3s ease;
}

/* Chat container - positioned in bottom right */
.emocom-chat-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 99999; /* Ensure it's above all other elements */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Chat toggle button */
.emocom-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chat-transition);
  color: white;
  position: relative;
  z-index: 2;
  outline: none;
}

.emocom-chat-button:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Button icons */
.emocom-chat-button svg {
  width: 24px;
  height: 24px;
  transition: var(--chat-transition);
}

.emocom-chat-button .close-icon {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

.emocom-chat-button.active .chat-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

.emocom-chat-button.active .close-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Chat window */
.emocom-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 360px;
  height: 500px;
  background: var(--chat-bg);
  border-radius: var(--chat-border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--chat-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  
  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: var(--chat-transition);
  pointer-events: none;
}

/* Active chat window */
.emocom-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat header */
.emocom-chat-header {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--chat-primary);
  color: white;
}

.emocom-chat-header-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 20px;
}

.emocom-chat-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.emocom-chat-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: var(--chat-transition);
}

.emocom-chat-close:hover {
  opacity: 1;
}

/* Chat messages area */
.emocom-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f9fafb;
}

.emocom-welcome-message {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.emocom-welcome-message h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: var(--chat-primary);
  font-size: 16px;
}

.emocom-welcome-message p {
  margin: 0;
  color: var(--chat-text-light);
  font-size: 14px;
  line-height: 1.5;
}

/* Chat message bubbles */
.emocom-message {
  display: flex;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
}

.emocom-message .message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.user-message {
  justify-content: flex-end;
}

.bot-message {
  justify-content: flex-start;
}

.user-message .message-content {
  background: var(--chat-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.bot-message .message-content {
  background: white;
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  width: fit-content;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.4;
  animation: pulse 1s infinite;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}
.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.4; }
}

/* Chat input area */
.emocom-chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  background: white;
}

.emocom-chat-input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 10px 16px;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  max-height: 100px;
  min-height: 40px;
  transition: var(--chat-transition);
}

.emocom-chat-input:focus {
  border-color: var(--chat-primary);
}

.emocom-chat-send {
  background: var(--chat-primary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--chat-transition);
  color: white;
}

.emocom-chat-send:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-2px);
}

/* Responsive styles */
@media (max-width: 480px) {
  .emocom-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 140px);
    right: 0;
    bottom: 80px;
    max-width: 360px;
  }
  
  .emocom-chat-button {
    width: 50px;
    height: 50px;
  }
  
  .emocom-chat-button svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 360px) {
  .emocom-chat-window {
    width: calc(100vw - 16px);
    right: -8px;
    max-width: none;
  }
}
