/* Inline AI Chat Section */
#aiChatSection {
  margin-top: 40px;
  margin-bottom: 40px;
}

#aiChatSection h3 {
  color: #667eea;
  margin-bottom: 30px;
  font-size: 28px; /* Tăng từ 22px lên 28px */
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-container {
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
  border: 2px solid #e3e8ff;
  border-radius: 16px; /* Tăng border radius */
  padding: 40px; /* Tăng từ 25px lên 40px */
  max-width: 100%;
  width: 100%;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15); /* Thêm shadow đẹp hơn */
}

.chat-header-inline {
  margin-bottom: 30px;
}

.chat-intro {
  color: #4f46e5;
  font-size: 16px; /* Tăng từ 15px lên 16px */
  line-height: 1.7;
  margin: 0;
  background: white;
  padding: 20px 25px; /* Tăng padding */
  border-radius: 12px;
  border-left: 6px solid #667eea; /* Tăng độ dày border */
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.chat-messages-inline {
  max-height: 800px; /* Tăng gấp đôi từ 400px lên 800px */
  min-height: 600px; /* Tăng từ 400px lên 600px */
  overflow-y: auto;
  background: white;
  border-radius: 16px; /* Tăng border radius */
  padding: 30px; /* Tăng từ 20px lên 30px */
  margin-bottom: 30px;
  border: 2px solid #e5e7eb; /* Tăng độ dày border */
  display: flex;
  flex-direction: column;
  gap: 20px; /* Tăng gap giữa các tin nhắn */
  box-shadow: 0 4px 16px rgba(0,0,0,0.08); /* Shadow đẹp hơn */
}

.chat-messages-inline .message {
  max-width: 85%;
  animation: messageSlide 0.4s ease; /* Tăng thời gian animation */
}

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

.chat-messages-inline .user-message {
  align-self: flex-end;
}

.chat-messages-inline .ai-message {
  align-self: flex-start;
}

.chat-messages-inline .message-content {
  padding: 20px 25px; /* Tăng gấp đôi padding tin nhắn */
  border-radius: 20px; /* Tăng border radius */
  font-size: 16px; /* Tăng từ 15px lên 16px */
  line-height: 1.8; /* Tăng line height */
  white-space: pre-line;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); /* Thêm shadow cho tin nhắn */
}

/* CSS để xử lý markdown **text** thành bold */
.chat-messages-inline .ai-message .message-content {
  background: #f8f9fa;
  color: #333;
  border: 2px solid #e9ecef; /* Tăng độ dày border */
}

/* Style cho text in đậm trong tin nhắn AI */
.chat-messages-inline .ai-message .message-content strong,
.chat-messages-inline .ai-message .message-content b {
  font-weight: 700;
  color: #2c3e50;
}

.chat-messages-inline .user-message .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-messages-inline .ai-message .message-content {
  background: #f8f9fa;
  color: #333;
  border: 2px solid #e9ecef; /* Tăng độ dày border */
}

.chat-input-inline {
  display: flex;
  gap: 16px; /* Tăng gap */
  align-items: center;
  padding: 20px; /* Thêm padding cho vùng input */
  background: rgba(255,255,255,0.8);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.chat-input-field {
  flex: 1;
  border: 3px solid #e5e7eb; /* Tăng độ dày border */
  border-radius: 30px; /* Tăng border radius */
  padding: 20px 30px; /* Tăng gấp đôi padding */
  font-size: 16px; /* Giữ font size */
  outline: none;
  transition: all 0.3s ease;
  background: white;
  min-height: 60px; /* Tăng chiều cao tối thiểu */
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chat-input-field:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.15); /* Tăng shadow focus */
  transform: translateY(-2px);
}

.chat-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px; /* Tăng từ 50px lên 60px */
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05); /* Thêm hiệu ứng scale */
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
}

.chat-send-btn svg {
  width: 24px; /* Tăng kích thước icon */
  height: 24px;
}

/* Typing indicator */
.chat-messages-inline .typing .message-content {
  padding: 25px; /* Tăng padding */
}

.chat-messages-inline .typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-messages-inline .typing-dots span {
  width: 10px; /* Tăng kích thước dots */
  height: 10px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Mobile responsive */
@media (max-width: 768px) {
  .ai-chat-container {
    padding: 25px; /* Giảm padding trên mobile */
  }
  
  .chat-input-inline {
    gap: 12px;
    padding: 15px;
  }
  
  .chat-input-field {
    padding: 15px 20px;
    font-size: 16px;
    min-height: 50px;
    border-width: 2px;
  }
  
  .chat-send-btn {
    width: 50px;
    height: 50px;
  }
  
  .chat-send-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .chat-messages-inline {
    max-height: 600px; /* Tăng cho mobile */
    min-height: 400px;
    padding: 20px;
  }
  
  .chat-messages-inline .message-content {
    font-size: 15px;
    padding: 15px 18px;
  }
  
  #aiChatSection h3 {
    font-size: 24px;
  }
}

/* Responsive cho phần summary kết quả phân tích */
@media (max-width: 768px) {
  #summary.summary-grid {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: stretch;
    margin-bottom: 18px;
  }
  #summary .item {
    min-width: 140px;
    max-width: 48vw;
    flex: 1 1 140px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px 8px;
    margin: 0 2px 8px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 15px;
  }
  #summary .item .k {
    font-weight: 600;
    color: #4f46e5;
    margin-bottom: 4px;
    font-size: 14px;
  }
  #summary .item .v {
    font-weight: 500;
    color: #222;
    font-size: 15px;
    word-break: break-word;
  }
}

/* Desktop: Kết quả phân tích chia 2 hàng 6 mục đều nhau */
@media (min-width: 769px) {
  #summary.summary-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 24px;
    margin-bottom: 32px;
    align-items: stretch;
    justify-items: stretch;
  }
  #summary .item {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 18px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.09);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 18px;
    min-width: 0;
    min-height: 80px;
    justify-content: center;
  }
  #summary .item .k {
    font-weight: 700;
    color: #4f46e5;
    margin-bottom: 8px;
    font-size: 16px;
  }
  #summary .item .v {
    font-weight: 500;
    color: #222;
    font-size: 18px;
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  .ai-chat-container {
    padding: 20px;
  }
  
  .chat-messages-inline {
    max-height: 500px;
    min-height: 350px;
    padding: 15px;
  }
  
  .chat-messages-inline .message-content {
    padding: 12px 16px;
  }
  
  #aiChatSection h3 {
    font-size: 22px;
  }
}
