/* Modern Chat Styles */

/* Container - works with dashboard layout */
.modern-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px); /* Account for main header */
  background: #ffffff;
  margin: 0;
  position: relative;
  overflow: hidden;
}

/* Ensure chat works properly within dashboard main-content */
.main-content .modern-chat-container {
  height: calc(100vh - 80px);
  margin: 0;
}

.dashboard-container .main-content {
  padding: 0; /* Remove default padding for chat pages */
}

/* Chat Header */
.modern-chat-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.chat-title-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-button {
  display: flex;
  align-items: center;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  text-decoration: none;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 1px solid #e5e7eb;
}

.back-link:hover {
  background: #f9fafb;
  color: #374151;
  text-decoration: none;
  transform: translateX(-2px);
}

.back-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-title {
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.template-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}

.template-badge svg {
  width: 16px;
  height: 16px;
}

/* Messages Area */
.modern-chat-content {
  flex: 1;
  overflow: hidden;
  background: #f8fafc;
}

.messages-area {
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Welcome State */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #6b7280;
  animation: fadeIn 0.5s ease-in;
}

.welcome-icon {
  margin-bottom: 20px;
  color: #9ca3af;
}

.welcome-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 8px 0;
}

.welcome-state p {
  font-size: 16px;
  color: #6b7280;
  margin: 0;
}

/* Message Wrappers */
.message-wrapper {
  display: flex;
  margin-bottom: 24px;
  align-items: flex-start;
  gap: 12px;
  opacity: 0;
  animation: slideIn 0.3s ease-out forwards;
}

.message-wrapper.assistant-message {
  justify-content: flex-start;
}

.message-wrapper.user-message {
  justify-content: flex-end !important;
  flex-direction: row-reverse !important;
  margin-left: auto;
  margin-right: 0;
}

/* Message Avatars */
.message-avatar {
  flex-shrink: 0;
}

.avatar-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.avatar-icon.assistant {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
  border: 2px solid #bfdbfe;
}

.avatar-icon.user {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: 2px solid #60a5fa;
}

/* Message Bubbles */
.message-bubble {
  max-width: 70%;
  word-wrap: break-word;
  position: relative;
  transition: all 0.2s ease;
}

/* Ensure user messages align with input box */
.message-wrapper.user-message .message-bubble {
  margin-right: 0;
}

.assistant-bubble {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.assistant-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-bubble {
  background: #f1f5f9 !important;
  color: #1e293b !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 18px 18px 4px 18px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.user-bubble:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message-content {
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.user-bubble .message-content {
  color: #1e293b !important;
}

.user-bubble .message-content p {
  color: #1e293b !important;
}

/* Message Meta */
.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.7;
}

.user-bubble .message-meta {
  color: #64748b !important;
}

.message-time {
  font-weight: 500;
}

.style-tag {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.user-bubble .style-tag {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

/* Input Section */
.modern-chat-input {
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding: 20px 24px;
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f8fafc;
  border: 2px solid #e5e7eb;
  border-radius: 24px;
  padding: 4px 4px 4px 20px;
  transition: all 0.2s ease;
}

.input-container:focus-within {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  padding: 12px 0;
  max-height: 120px;
  min-height: 24px;
  color: #111827;
  transition: all 0.2s ease;
}

.chat-textarea::placeholder {
  color: #9ca3af;
}

.chat-textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.send-btn {
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.05);
}

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

.send-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

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

.input-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}

.char-count {
  font-weight: 500;
  transition: color 0.2s ease;
}

.template-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  color: #1d4ed8;
}

/* Generated Image/Video Container */
.generated-image-container,
.generated-video-container {
  margin: 16px 0;
}

.generated-image,
.generated-video {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.generated-image:hover {
  transform: scale(1.02);
}

/* Job Status Indicators */
.job-status {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease-in;
}

.job-status.processing {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.job-status.error {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.processing-indicator,
.error-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.processing-indicator svg {
  animation: spin 1s linear infinite;
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Scrollbar Styling */
.messages-area::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

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

.messages-area::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Loading States */
.send-btn.loading {
  pointer-events: none;
}

.send-btn.loading svg {
  animation: spin 1s linear infinite;
}

/* Generation Loading Indicator */
.generation-loading {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  padding: 16px 0;
  animation: fadeIn 0.3s ease-in;
  border-top: 1px solid #e2e8f0;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
}

.assistant-bubble.generating {
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%) !important;
  border-color: #bfdbfe !important;
}

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

.thinking-dot {
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  animation: thinkingPulse 1.5s ease-in-out infinite;
}

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

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

@keyframes thinkingPulse {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .modern-chat-header {
    padding: 16px;
  }
  
  .chat-title-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .chat-title {
    font-size: 18px;
  }
  
  .messages-area {
    padding: 16px;
    max-width: 100%;
  }
  
  .message-bubble {
    max-width: 85%;
  }
  
  .modern-chat-input {
    padding: 16px;
  }
  
  .input-container {
    padding: 4px 4px 4px 16px;
  }
  
  .chat-textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

@media (max-width: 480px) {
  .modern-chat-container {
    height: calc(100vh - 60px);
  }
  
  .main-content .modern-chat-container {
    height: calc(100vh - 60px);
  }
  
  .chat-title {
    font-size: 16px;
  }
  
  .template-badge {
    font-size: 11px;
    padding: 4px 8px;
  }
  
  .message-bubble {
    max-width: 90%;
  }
  
  .assistant-bubble,
  .user-bubble {
    padding: 12px 16px;
  }
  
  .message-content {
    font-size: 14px;
  }
  
  .avatar-icon {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  
  .send-btn {
    width: 40px;
    height: 40px;
  }
  
  .input-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
} 