/* Live Chat Widget — admin-initiated real-time chat */

/* Online indicator dot on existing chatbot toggle */
.live-chat-online-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 10001;
  animation: liveChatPulse 2s ease-in-out infinite;
}

@keyframes liveChatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* Nudge bubble */
.live-chat-nudge {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #22c55e;
  border-radius: 12px;
  padding: 12px 32px 12px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 14px;
  color: #111827;
  max-width: 300px;
  z-index: 10002;
  animation: liveChatNudgeIn 0.3s ease;
  cursor: pointer;
  line-height: 1.5;
}
.live-chat-nudge-close {
  position: absolute;
  top: 4px;
  right: 8px;
  cursor: pointer;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
}
.live-chat-nudge-close:hover { color: #6b7280; }

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

/* Chat window */
.live-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--bg-white, #fff);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border, #e5e7eb);
}
.live-chat-window.open { display: flex; }

/* Header — green gradient to distinguish from FAQ chatbot */
.live-chat-header {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.live-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-chat-header-dot {
  width: 8px;
  height: 8px;
  background: #bbf7d0;
  border-radius: 50%;
  flex-shrink: 0;
  animation: liveChatPulse 2s ease-in-out infinite;
}
.live-chat-header-name {
  font-size: 15px;
  font-weight: 600;
}
.live-chat-header-role {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  display: block;
}
.live-chat-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.live-chat-header-close:hover { opacity: 1; }

/* Message body */
.live-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 340px;
}

/* Messages */
.live-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  animation: liveChatMsgIn 0.25s ease;
  word-wrap: break-word;
}
@keyframes liveChatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.live-chat-msg.admin {
  background: #f0fdf4;
  color: var(--text-primary, #111827);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border-left: 2px solid #22c55e;
}
.live-chat-msg.visitor {
  background: var(--accent-purple, #8b5cf6);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.live-chat-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #f0fdf4;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
  color: #6b7280;
  display: none;
  align-items: center;
  gap: 2px;
}
.live-chat-typing.visible { display: flex; }
.live-chat-typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: liveChatTypingBounce 1.4s ease-in-out infinite;
}
.live-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.live-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes liveChatTypingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Input area */
.live-chat-input {
  display: flex;
  border-top: 1px solid var(--border, #e5e7eb);
  padding: 10px 12px;
  gap: 8px;
  background: var(--bg-white, #fff);
}
.live-chat-input input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.live-chat-input input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.live-chat-input button {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.live-chat-input button:hover { opacity: 0.9; }

/* Offline form */
.live-chat-offline-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.live-chat-offline-form p {
  font-size: 14px;
  color: var(--text-primary, #111827);
  margin: 0;
  line-height: 1.5;
}
.live-chat-offline-form input,
.live-chat-offline-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.live-chat-offline-form input:focus,
.live-chat-offline-form textarea:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.live-chat-offline-form textarea {
  resize: vertical;
  min-height: 60px;
  font-size: 13px;
}
.live-chat-offline-form button {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.live-chat-offline-form button:hover { opacity: 0.9; }
.live-chat-offline-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.live-chat-offline-form .live-chat-form-error {
  border-color: #dc2626 !important;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .live-chat-window {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 84px;
    max-height: 70vh;
  }
  .live-chat-nudge {
    right: 16px;
    bottom: 76px;
    max-width: calc(100vw - 80px);
  }
}
