/* ═══════════════════════════════════════════════════════════
   V4.5 Premium Chat Widget CSS
   Professional, smooth, high-quality chat interface
   ═══════════════════════════════════════════════════════════ */

:root {
  --chat-primary: #f97316;
  --chat-primary-hover: #ea580c;
  --chat-secondary: #fff7ed;
  --chat-text: #1f2937;
  --chat-text-light: #6b7280;
  --chat-border: #e5e7eb;
  --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  --chat-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* Chat Button (FAB) */
#chat-widget-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, #fb923c 100%);
  border: none;
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-widget-button:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: var(--chat-shadow-lg);
}

#chat-widget-button:active {
  transform: scale(0.95);
}

#chat-widget-button svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: transform 0.3s ease;
}

#chat-widget-button:hover svg {
  transform: scale(1.1);
}

/* Notification Badge */
#chat-widget-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Chat Window */
#chat-widget-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 20px;
  box-shadow: var(--chat-shadow-lg);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-widget-window.open {
  display: flex;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
#chat-widget-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, #fb923c 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#chat-widget-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#chat-widget-header-info {
  flex: 1;
  min-width: 0;
}

#chat-widget-header-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

#chat-widget-header-status {
  font-size: 13px;
  opacity: 0.9;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

#chat-widget-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

#chat-widget-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

#chat-widget-close svg {
  width: 18px;
  height: 18px;
  color: white;
}

/* Messages Container */
#chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#chat-widget-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-widget-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chat-widget-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

#chat-widget-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Message Bubbles */
.chat-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

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

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

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

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), #fb923c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  color: white;
  font-weight: 600;
}

.chat-message.user .chat-message-avatar {
  background: #6b7280;
}

.chat-message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-message.agent .chat-message-bubble {
  background: white;
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-bubble {
  background: var(--chat-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-time {
  font-size: 11px;
  color: var(--chat-text-light);
  margin-top: 4px;
  padding: 0 16px;
}

/* Quick Actions */
.chat-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.chat-quick-action {
  background: white;
  border: 1.5px solid var(--chat-border);
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--chat-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-quick-action:hover {
  border-color: var(--chat-primary);
  background: var(--chat-secondary);
  transform: translateX(4px);
}

.chat-quick-action svg {
  width: 18px;
  height: 18px;
  color: var(--chat-primary);
}

/* Input Area */
#chat-widget-input-area {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

#chat-widget-input {
  flex: 1;
  border: 1.5px solid var(--chat-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  resize: none;
  max-height: 120px;
}

#chat-widget-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

#chat-widget-send {
  background: var(--chat-primary);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#chat-widget-send:hover:not(:disabled) {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
}

#chat-widget-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat-widget-send svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--chat-text-light);
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  #chat-widget-button {
    width: 56px;
    height: 56px;
    bottom: 20px;
    right: 20px;
  }

  #chat-widget-button svg {
    width: 24px;
    height: 24px;
  }

  #chat-widget-window {
    bottom: 88px;
    right: 20px;
    left: 20px;
    width: auto;
    max-width: none;
    height: calc(100vh - 120px);
    max-height: none;
  }
}
