/* Enhanced Chat UI Styles */

/* Typing indicator animation */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: var(--chat-bubble-ai);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  max-width: 75%;
  align-self: flex-start;
  margin: 0.5rem 0;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

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

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

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.3);
    opacity: 1;
  }
}

.typing-text {
  margin-left: 10px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Message timestamps */
.message-wrapper {
  display: flex;
  flex-direction: column;
  position: relative;
}

.message-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 2px 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message-wrapper.user-message .message-timestamp {
  align-self: flex-end;
  text-align: right;
}

.message-wrapper.ai-response .message-timestamp {
  align-self: flex-start;
  text-align: left;
}

.message-wrapper:hover .message-timestamp {
  opacity: 1;
}

.timestamp-tooltip {
  position: absolute;
  background: var(--bg-header);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 1001;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.timestamp-tooltip.show {
  opacity: 1;
}

/* Copy button */
.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  z-index: 10;
}

.chat-bubble:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: var(--accent-primary);
  color: white;
}

.copy-success {
  background: var(--accent-secondary) !important;
  color: white !important;
  animation: copySuccess 2s ease-out;
}

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

/* Drag and drop overlay */
.drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(88, 166, 255, 0.15);
  border: 3px dashed var(--accent-primary);
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

.drag-overlay-active {
  display: flex;
}

.drag-overlay-content {
  text-align: center;
  color: var(--accent-primary);
  font-size: 1.5rem;
  font-weight: bold;
}

.drag-overlay-content i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

/* File preview styles */
.file-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  position: relative;
}

.file-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon {
  font-size: 24px;
  color: var(--text-secondary);
}

.file-icon.pdf { color: #e74c3c; }
.file-icon.doc, .file-icon.docx { color: #3498db; }
.file-icon.txt { color: #95a5a6; }
.file-icon.image { color: #9b59b6; }

.file-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.file-name {
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.file-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.file-remove:hover {
  background: rgba(248, 81, 73, 0.1);
}

/* Upload progress */
.upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-primary);
  border-radius: 0 0 8px 8px;
  transition: width 0.3s ease;
}

.upload-progress.error {
  background: var(--danger);
}

.upload-progress.complete {
  background: var(--accent-secondary);
}

/* Error states */
.file-item.error {
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.05);
}

.file-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.2rem;
}

/* Attach button */
.attach-button {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.attach-button:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Enhanced chat bubble positioning */
.chat-bubble {
  position: relative;
}

/* Update existing chat container to support drag overlay */
#current-chat-container {
  position: relative;
}

/* File list enhancements */
.file-list-enhanced {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Mobile responsive updates for enhanced features */
@media (max-width: 768px) {
  .file-item {
    padding: 0.6rem;
  }
  
  .file-thumbnail {
    width: 40px;
    height: 40px;
  }
  
  .file-icon {
    font-size: 20px;
  }
  
  .copy-button {
    position: static;
    opacity: 1;
    margin-top: 0.5rem;
    align-self: flex-start;
  }
  
  .drag-overlay-content {
    font-size: 1.2rem;
  }
  
  .drag-overlay-content i {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .typing-indicator {
    padding: 8px 12px;
  }
  
  .typing-dot {
    width: 6px;
    height: 6px;
  }
  
  .file-thumbnail {
    width: 36px;
    height: 36px;
  }
  
  .file-icon {
    font-size: 18px;
  }
}