/* IndustrialMint Chat Widget Styles */
:root {
  --im-chat-primary: #00a859;
  --im-chat-primary-hover: #00904d;
  --im-chat-primary-light: #e6f4f1;
  --im-chat-bg: #ffffff;
  --im-chat-text: #1a1f36;
  --im-chat-text-light: #6b7a93;
  --im-chat-border: #e4eaf2;
  --im-chat-user-msg: #00a859;
  --im-chat-user-text: #ffffff;
  --im-chat-agent-msg: #f5f7fa;
  --im-chat-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
  --im-chat-radius: 16px;
  --im-chat-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Widget Container */
.im-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --chat-width: 380px;
  --chat-height: 580px;
}

/* Toggle Button - Human Avatar Style */
.im-chat-toggle {
  width: auto;
  min-width: 60px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--im-chat-primary), #008f4a);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px 0 14px;
  box-shadow: var(--im-chat-shadow);
  transition: var(--im-chat-transition);
  position: relative;
  overflow: visible;
}

.im-chat-toggle:hover {
  transform: translateX(-4px) scale(1.02);
  box-shadow: 0 16px 48px rgba(0, 168, 89, 0.4);
}

.im-chat-toggle:active {
  transform: scale(0.98);
}

.im-chat-toggle-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.im-chat-toggle-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.im-chat-toggle-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.im-chat-toggle-text {
  color: white;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.2px;
}

.im-chat-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: #e5484d;
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(229, 72, 77, 0.3);
  animation: badgePop 0.3s ease;
}

@keyframes badgePop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.im-chat-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--im-chat-primary);
  opacity: 0;
  animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Chat Window */
.im-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--im-chat-bg);
  border-radius: var(--im-chat-radius);
  box-shadow: var(--im-chat-shadow), 0 0 0 1px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpFade 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--im-chat-border);
}

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

/* Header */
.im-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--im-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

.im-chat-agent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.im-chat-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--im-chat-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  position: relative;
}

.im-chat-agent-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #1fae68;
  border: 2px solid white;
  border-radius: 50%;
}

.im-chat-agent-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.im-chat-agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--im-chat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.im-chat-agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--im-chat-text-light);
}

.im-status-dot {
  width: 8px;
  height: 8px;
  background: #1fae68;
  border-radius: 50%;
  animation: statusPulse 2s ease-in-out infinite;
}

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

.im-chat-header-actions {
  display: flex;
  gap: 4px;
}

.im-chat-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--im-chat-text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--im-chat-transition);
}

.im-chat-header-btn:hover {
  background: var(--im-chat-border);
  color: var(--im-chat-text);
}

/* Messages Area */
.im-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fafbfc;
}

/* Welcome Card */
.im-chat-welcome {
  width: 100%;
}

.im-welcome-card {
  background: var(--im-chat-bg);
  border: 1px solid var(--im-chat-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.im-welcome-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--im-chat-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px;
}

.im-welcome-card h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--im-chat-text);
}

.im-welcome-card p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--im-chat-text-light);
  line-height: 1.5;
}

.im-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.im-quick-reply {
  background: var(--im-chat-primary-light);
  color: var(--im-chat-primary);
  border: 1px solid var(--im-chat-primary);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--im-chat-transition);
  white-space: nowrap;
}

.im-quick-reply:hover {
  background: var(--im-chat-primary);
  color: white;
}

/* Message Bubbles */
.im-chat-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: messageIn 0.3s ease;
}

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

.im-chat-message.agent {
  align-self: flex-start;
}

.im-chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.im-chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.im-chat-message.agent .im-chat-message-avatar {
  background: var(--im-chat-primary-light);
  color: var(--im-chat-primary);
}

.im-chat-message.user .im-chat-message-avatar {
  background: var(--im-chat-primary);
  color: white;
}

.im-chat-message-content {
  background: var(--im-chat-agent-msg);
  border-radius: 16px;
  padding: 12px 16px;
  position: relative;
}

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

.im-chat-message.agent .im-chat-message-content {
  border-bottom-left-radius: 4px;
}

.im-chat-message-text {
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}

.im-chat-message.user .im-chat-message-text {
  color: var(--im-chat-user-text);
}

.im-chat-message-time {
  font-size: 10px;
  color: var(--im-chat-text-light);
  margin-top: 4px;
  text-align: right;
}

.im-chat-message.user .im-chat-message-time {
  color: rgba(255,255,255,0.7);
}

/* Typing Indicator */
.im-chat-typing {
  padding: 0 20px 12px;
  animation: typingSlide 0.2s ease;
}

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

.im-typing-bubble {
  background: var(--im-chat-agent-msg);
  border-radius: 16px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 180px;
  border-bottom-left-radius: 4px;
}

.im-typing-dots {
  display: flex;
  gap: 3px;
}

.im-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--im-chat-text-light);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite both;
}

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.im-typing-text {
  font-size: 11.5px;
  color: var(--im-chat-text-light);
  font-style: italic;
}

/* Quick Replies in Chat */
.im-chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
  max-height: 80px;
  overflow-y: auto;
}

.im-chat-quick-reply {
  background: var(--im-chat-primary-light);
  color: var(--im-chat-primary);
  border: 1px solid var(--im-chat-primary);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--im-chat-transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.im-chat-quick-reply:hover {
  background: var(--im-chat-primary);
  color: white;
}

/* Input Area */
.im-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--im-chat-border);
  background: var(--im-chat-bg);
}

.im-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.im-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--im-chat-border);
  border-radius: 22px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--im-chat-text);
  background: var(--im-chat-bg);
  resize: none;
  outline: none;
  transition: var(--im-chat-transition);
  line-height: 1.4;
}

.im-chat-input:focus {
  border-color: var(--im-chat-primary);
  box-shadow: 0 0 0 3px var(--im-chat-primary-light);
}

.im-chat-input::placeholder {
  color: var(--im-chat-text-light);
}

.im-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--im-chat-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--im-chat-transition);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 168, 89, 0.3);
}

.im-chat-send:hover {
  background: var(--im-chat-primary-hover);
  transform: scale(1.05);
}

.im-chat-send:active {
  transform: scale(0.95);
}

.im-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.im-chat-footer-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--im-chat-text-light);
  padding-top: 4px;
}

.im-chat-footer-hint .material-symbols-outlined {
  font-size: 12px;
}

/* Scrollbar */
.im-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.im-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.im-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.im-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .im-chat-widget {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
  
  .im-chat-window {
    width: 100%;
    height: calc(100vh - 100px);
    max-height: 600px;
    bottom: 80px;
    right: 0;
    left: 0;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
  
  .im-chat-toggle {
    width: 56px;
    height: 56px;
    margin: 0 auto;
    display: block;
  }
  
  .im-chat-widget {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Hidden state */
.im-chat-widget.hidden .im-chat-window {
  display: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .im-chat-window,
  .im-chat-message,
  .im-chat-toggle,
  .im-status-dot,
  .im-typing-dots span {
    animation: none !important;
    transition: none !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .im-chat-toggle {
    border: 2px solid currentColor;
  }
  .im-chat-window {
    border-width: 2px;
  }
  .im-chat-message-content {
    border: 1px solid currentColor;
  }
}