/* Chat Page Styles */

.chat-main {
  min-height: calc(100vh - var(--header-height, 80px) - 200px);
  padding: calc(var(--header-height, 80px) + 40px) 0 40px;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .chat-header {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-avatar {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--color-primary);
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid var(--color-bg-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.chat-header-info h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text-primary);
}

.chat-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 4px 0 0;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(241, 245, 249, 0.7);
  backdrop-filter: blur(10px);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.btn-icon:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.1);
}

/* Suggested Questions */
.suggested-questions {
  margin-bottom: 24px;
  padding: 24px;
  background: rgba(248, 250, 252, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .suggested-questions {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.suggested-questions h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--color-text-primary);
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.suggestion-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

body.dark-mode .suggestion-btn {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.suggestion-btn:hover {
  background: var(--gradient-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.suggestion-btn i {
  font-size: 1rem;
  opacity: 0.7;
}

/* Chat Container */
.chat-container {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  flex-direction: column;
  height: 600px;
}

body.dark-mode .chat-container {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(248, 250, 252, 0.5);
  backdrop-filter: blur(10px);
}

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

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

/* Message Styles */
.message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-message .message-avatar {
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 70%;
}

.user-message .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
}

.bot-message .message-bubble {
  background: rgba(248, 250, 252, 0.7);
  backdrop-filter: blur(10px);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

body.dark-mode .bot-message .message-bubble {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.user-message .message-bubble {
  background: var(--gradient-primary);
  color: white !important;
}

.user-message .message-bubble * {
  color: white !important;
}

.message-bubble p {
  margin: 0;
  line-height: 1.5;
  font-size: 0.9375rem;
}

.message-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

/* Markdown formatting styles */
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  font-weight: 700;
  color: inherit;
  margin: 12px 0 8px;
  line-height: 1.3;
}

.message-bubble h2 {
  font-size: 1.25em;
}

.message-bubble h3 {
  font-size: 1.1em;
}

.message-bubble h4 {
  font-size: 1em;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 12px 0;
}

.user-message .message-bubble hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

.message-bubble strong {
  font-weight: 700;
  color: inherit;
}

.message-bubble em {
  font-style: italic;
}

.message-bubble code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: 0.875em;
}

.user-message .message-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.message-bubble ol,
.message-bubble ul {
  margin: 8px 0;
  padding-left: 24px;
}

.message-bubble ol {
  list-style-type: decimal;
}

.message-bubble ul {
  list-style-type: disc;
}

.message-bubble li {
  margin: 4px 0;
  line-height: 1.6;
}

.message-bubble br {
  display: block;
  content: "";
  margin: 4px 0;
}

.message-time {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 24px;
  animation: messageSlideIn 0.3s ease;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(248, 250, 252, 0.7);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

body.dark-mode .typing-dots {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Chat Input */
.chat-input-container {
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(248, 250, 252, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px 24px;
}

body.dark-mode .chat-input-container {
  background: rgba(30, 41, 59, 0.8);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  resize: none;
  max-height: 120px;
  transition: all 0.3s ease;
}

body.dark-mode .chat-input {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-input::placeholder {
  color: var(--color-text-tertiary);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

.char-count {
  font-weight: 500;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Error Message */
.error-message {
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg);
  color: #ef4444;
  font-size: 0.875rem;
  margin: 12px 24px;
  animation: messageSlideIn 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-main {
    padding: calc(var(--header-height, 80px) + 20px) 0 20px;
  }

  .chat-header {
    padding: 16px;
    flex-direction: column;
    gap: 16px;
  }

  .chat-header-content {
    width: 100%;
  }

  .chat-avatar {
    width: 50px;
    height: 50px;
  }

  .chat-header-info h1 {
    font-size: 1.25rem;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .chat-container {
    height: 500px;
  }

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

  .chat-messages {
    padding: 16px;
  }

  .chat-input-container {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .chat-container {
    height: 450px;
    border-radius: var(--radius-lg);
  }

  .message-content {
    max-width: 90%;
  }

  .suggestion-btn {
    font-size: 0.8125rem;
    padding: 10px 14px;
  }
}
