/**
 * Chat Component Styles
 * Real-time chat with bubble icon and notification badge
 */

#chat-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Chat bubble button */
.chat-bubble {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  color: white;
}

.chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

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

.chat-bubble svg {
  width: 28px;
  height: 28px;
}

/* Unread badge */
.chat-unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #dc3545;
  color: white;
  border-radius: 12px;
  min-width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  padding: 0 6px;
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
  animation: pulse 2s infinite;
}

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

/* Chat window */
.chat-window {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 350px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s ease;
  overflow: hidden;
}

.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat header */
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
}

.chat-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chat-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chat messages container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: #e9ecef;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #6c757d;
}

/* Empty state */
.chat-empty {
  text-align: center;
  color: #6c757d;
  padding: 40px 20px;
  font-size: 14px;
}

/* Chat message */
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: slideIn 0.3s ease;
}

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

.chat-message-other {
  align-self: flex-start;
  flex-direction: row;
}

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

/* Avatar */
.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Message content */
.chat-message-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.chat-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.chat-message-username {
  font-weight: 600;
  color: #495057;
}

.chat-message-time {
  color: #adb5bd;
  font-size: 11px;
}

.chat-message-text {
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  font-size: 14px;
  color: #212529;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message-own .chat-message-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chat-message-own .chat-message-username {
  color: #667eea;
}

/* Chat input */
.chat-input-container {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: white;
  border-top: 1px solid #e9ecef;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #667eea;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

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

/* Mobile responsive */
@media (max-width: 480px) {
  #chat-container {
    bottom: 10px;
    left: 10px;
    right: 10px;
  }

  .chat-bubble {
    width: 56px;
    height: 56px;
  }

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

  .chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    left: 0;
    right: 0;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .chat-header h3 {
    font-size: 16px;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-message {
    max-width: 85%;
  }
}

/* Header actions container */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Settings button in header */
.chat-settings-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-settings-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Message action buttons */
.chat-message-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-message:hover .chat-message-actions {
  opacity: 1;
}

.chat-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.2s;
}

.chat-reply-btn {
  color: #667eea;
}

.chat-reply-btn:hover {
  background: rgba(102, 126, 234, 0.1);
}

.chat-delete-btn {
  color: #dc3545;
}

.chat-delete-btn:hover {
  background: rgba(220, 53, 69, 0.1);
}

/* Reply preview above input */
.chat-reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #e9ecef;
  border-top: 1px solid #dee2e6;
  font-size: 12px;
  color: #667eea;
}

#chat-reply-preview-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-reply-cancel {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  margin-left: 8px;
}

.chat-reply-cancel:hover {
  color: #dc3545;
}

/* Reply quote in message */
.chat-reply-quote {
  background: rgba(102, 126, 234, 0.1);
  border-left: 3px solid #667eea;
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
}

.chat-reply-mention {
  font-weight: 600;
  color: #667eea;
}

.chat-reply-text {
  color: #6c757d;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message-own .chat-reply-quote {
  background: rgba(255, 255, 255, 0.2);
  border-left-color: rgba(255, 255, 255, 0.5);
}

.chat-message-own .chat-reply-mention {
  color: rgba(255, 255, 255, 0.9);
}

.chat-message-own .chat-reply-text {
  color: rgba(255, 255, 255, 0.7);
}

/* Settings modal */
.chat-settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-settings-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.chat-settings-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-settings-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chat-settings-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-settings-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-settings-body {
  padding: 20px;
}

.chat-settings-photo-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-settings-photo-section label {
  font-weight: 600;
  color: #495057;
  font-size: 14px;
}

.chat-settings-photo-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e9ecef;
  margin: 0 auto;
  display: block;
}

.chat-settings-upload-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
}

.chat-settings-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-settings-upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-settings-or {
  color: #6c757d;
  font-size: 12px;
}

.chat-settings-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.chat-settings-input:focus {
  border-color: #667eea;
}

.chat-settings-hint {
  font-size: 12px;
  color: #6c757d;
  margin: 0;
}

.chat-settings-save {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-settings-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-settings-save:active {
  transform: translateY(0);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .chat-window {
    background: #1e1e1e;
  }

  .chat-messages {
    background: #2d2d2d;
  }

  .chat-message-text {
    background: #3d3d3d;
    color: #e0e0e0;
  }

  .chat-message-username {
    color: #b0b0b0;
  }

  .chat-input-container {
    background: #1e1e1e;
    border-top-color: #3d3d3d;
  }

  .chat-input {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #e0e0e0;
  }

  .chat-empty {
    color: #b0b0b0;
  }

  /* Dark mode for reply preview */
  .chat-reply-preview {
    background: #3d3d3d;
    border-top-color: #4d4d4d;
  }

  .chat-reply-quote {
    background: rgba(102, 126, 234, 0.2);
  }

  .chat-reply-text {
    color: #b0b0b0;
  }

  /* Dark mode for settings modal */
  .chat-settings-content {
    background: #1e1e1e;
  }

  .chat-settings-body {
    background: #1e1e1e;
  }

  .chat-settings-photo-section label {
    color: #e0e0e0;
  }

  .chat-settings-input {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #e0e0e0;
  }

  .chat-settings-hint {
    color: #b0b0b0;
  }

  .chat-settings-photo-preview {
    border-color: #3d3d3d;
  }
}
