/* F&W Services Chat Widget - Premium Dark Theme */
/* Design System: Navy/Blue/Gold palette matching main site */

:root {
  --color-navy-deep: #0a1628;
  --color-navy-medium: #1a2942;
  --color-navy-light: #2a3952;
  --color-blue-electric: #2563eb;
  --color-blue-light: #3b82f6;
  --color-gold-warm: #f59e0b;
  --color-gold-light: #fbbf24;
  --color-text-primary: #ffffff;
  --color-text-secondary: #94a3b8;
  --color-border: #334155;
}

/* Chat Bubble (Bottom-right floating button) */
#fw-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--color-blue-electric), var(--color-blue-light));
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3),
              0 4px 12px rgba(0, 0, 0, 0.2);
  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);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#fw-chat-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.4),
              0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Hide bubble when panel is open (Fitts's Law — prevent confusion) */
#fw-chat-bubble.open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* SVG Icon */
#fw-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: white;
  transition: transform 0.3s ease;
}

/* Chat Panel */
#fw-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--color-navy-deep);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 1px rgba(255, 255, 255, 0.1) inset;
  z-index: 9997;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#fw-chat-panel.visible {
  display: flex;
}

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

/* Chat Header */
.fw-chat-header {
  padding: 20px 24px;
  background: var(--color-navy-medium);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.fw-chat-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-blue-electric), var(--color-gold-warm));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.fw-chat-title-group {
  flex: 1;
}

.fw-chat-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--color-text-primary);
  margin: 0 0 2px 0;
}

.fw-chat-status {
  font-size: 13px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.fw-status-dot {
  width: 8px;
  height: 8px;
  background: var(--color-gold-warm);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* Close Button (BUG 2 FIX — Fitts's Law: small, in corner, visually distinct from send) */
.fw-chat-close-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.fw-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.fw-chat-close-btn:active {
  transform: scale(0.95);
}

.fw-chat-close-btn svg {
  width: 18px;
  height: 18px;
}

/* Chat Messages */
.fw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fw-chat-messages::-webkit-scrollbar {
  width: 8px;
}

.fw-chat-messages::-webkit-scrollbar-track {
  background: var(--color-navy-medium);
}

.fw-chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-navy-light);
  border-radius: 4px;
}

.fw-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-border);
}

.fw-message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

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

.fw-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.fw-message.bot .fw-message-avatar {
  background: linear-gradient(135deg, var(--color-blue-electric), var(--color-gold-warm));
  color: white;
}

.fw-message.user .fw-message-avatar {
  background: var(--color-navy-light);
  color: var(--color-text-primary);
}

.fw-message.user {
  flex-direction: row-reverse;
}

.fw-message-content {
  background: var(--color-navy-medium);
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 75%;
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
}

.fw-message.user .fw-message-content {
  background: var(--color-blue-electric);
}

.fw-message-time {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Typing Indicator */
.fw-typing-indicator {
  display: none;
  gap: 12px;
  padding: 0 24px;
  margin-bottom: 16px;
}

.fw-typing-indicator.visible {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.fw-typing-dots {
  background: var(--color-navy-medium);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  gap: 4px;
}

.fw-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--color-text-secondary);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* Chat Input */
.fw-chat-input-wrapper {
  padding: 20px 24px;
  background: var(--color-navy-medium);
  border-top: 1px solid var(--color-border);
}

.fw-chat-input-container {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--color-navy-deep);
  border-radius: 24px;
  padding: 4px 4px 4px 20px;
  border: 1px solid var(--color-border);
  transition: border-color 0.2s ease;
}

.fw-chat-input-container:focus-within {
  border-color: var(--color-blue-electric);
}

#fw-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-size: 14px;
  padding: 8px 0;
  font-family: 'Inter', sans-serif;
}

#fw-chat-input::placeholder {
  color: var(--color-text-secondary);
}

/* Send Button — Fitts's Law: Large, prominent, far from close button */
#fw-chat-send {
  width: 36px;
  height: 36px;
  background: var(--color-blue-electric);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

#fw-chat-send:hover:not(:disabled) {
  background: var(--color-blue-light);
  transform: scale(1.05);
}

#fw-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

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

#fw-chat-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #fw-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  #fw-chat-bubble {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  #fw-chat-bubble svg {
    width: 24px;
    height: 24px;
  }

  .fw-chat-messages {
    padding: 16px;
  }

  .fw-message-content {
    max-width: 85%;
  }

  .fw-chat-header {
    padding: 16px 20px;
  }

  .fw-chat-close-btn {
    width: 36px;
    height: 36px;
  }

  .fw-chat-close-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* Error State */
.fw-error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin: 8px 0;
}

/* Rate Limit Warning */
.fw-rate-limit-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--color-gold-light);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin: 8px 0;
  text-align: center;
}
