/* Floating Messenger - Clean Design */
#floating-messenger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
#chat-toggle {
  position: relative;
  background: var(--accent, #6366f1);
  color: white;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  outline: none;
}

#chat-toggle:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.5);
}

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

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

#chat-toggle:hover .toggle-icon {
  transform: scale(1.1);
}

/* Unread Badge */
.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  border-radius: 12px;
  padding: 0.125rem 0.375rem;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg, #ffffff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Chat Window */
#chat-window {
  width: 360px;
  height: 480px;
  background: var(--panel, #ffffff);
  color: var(--text, #212529);
  border: 1px solid var(--border, #dee2e6);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(20px);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

#chat-window.hidden {
  display: none;
}

/* Chat Header */
#chat-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--panel, #ffffff) 0%, var(--surface, #f8f9fa) 100%);
  border-bottom: 1px solid var(--border, #dee2e6);
  position: relative;
}

#chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border, #dee2e6), transparent);
}

.chat-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text, #212529);
}

.chat-header-logo img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-muted, #6c757d);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
}

.header-btn:hover {
  background: var(--hover, #f1f3f4);
  color: var(--text, #212529);
  transform: scale(1.05);
}

.close-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Chat Body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg, #ffffff);
  position: relative;
}

/* Welcome State */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted, #6c757d);
}

.welcome-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.welcome-text h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #212529);
}

.welcome-text p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Messages */
.message {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: flex-start;
  animation: messageSlideIn 0.3s ease-out;
}

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

.message.self {
  flex-direction: row-reverse;
}

.message-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface, #f8f9fa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text, #212529);
}

.message-content {
  flex: 1;
  min-width: 0;
  max-width: 75%;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted, #6c757d);
}

.message.self .message-header {
  justify-content: flex-end;
}

.sender-name {
  font-weight: 600;
}

.timestamp {
  font-size: 0.7rem;
  opacity: 0.7;
}

.content {
  background: var(--surface, #f8f9fa);
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  word-wrap: break-word;
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid var(--border, #dee2e6);
}

.message.self .content {
  background: var(--accent, #6366f1);
  color: white;
  border-color: var(--accent, #6366f1);
}

/* Reply Preview */
#reply-preview {
  background: var(--surface, #f8f9fa);
  border-left: 3px solid var(--accent, #6366f1);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-muted, #6c757d);
}

/* Chat Form */
#chat-form {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border, #dee2e6);
  background: var(--panel, #ffffff);
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--surface, #f8f9fa);
  border: 2px solid var(--border, #dee2e6);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  transition: all 0.3s ease;
}

.input-container:focus-within {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

#message-text {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text, #212529);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  resize: none;
  min-height: 20px;
  max-height: 80px;
  padding: 0;
}

#message-text::placeholder {
  color: var(--text-muted, #6c757d);
  opacity: 0.6;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.attach-btn,
.send-btn {
  background: none;
  border: none;
  color: var(--text-muted, #6c757d);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
}

.attach-btn:hover {
  background: var(--hover, #f1f3f4);
  color: var(--text, #212529);
  transform: scale(1.05);
}

.send-btn {
  color: var(--accent, #6366f1);
}

.send-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-hover, #8b5cf6);
  transform: scale(1.05);
}

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

/* Dark mode adjustments */
[data-theme="dark"] #chat-toggle {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] #chat-window {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .unread-badge {
  border-color: var(--bg, #1a1a1a);
}

/* Mobile responsive */
@media (max-width: 768px) {
  #floating-messenger {
    bottom: 16px;
    right: 16px;
  }
  
  #chat-window {
    width: calc(100vw - 32px);
    max-width: 360px;
    height: 400px;
  }
  
  #chat-toggle {
    width: 52px;
    height: 52px;
  }
}
