/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Chat container */
.chat-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

/* Chat messages */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #fafafa;
}

.message {
  margin-bottom: 20px;
  animation: messageSlideIn 0.3s ease-out;
}

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

.message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: inline-block;
}

.user-message {
  text-align: right;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.user-message .message-content {
  background: #007bff;
  color: white;
  border-bottom-right-radius: 6px;
  max-width: 75%;
}

.bot-message {
  text-align: left;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 16px;
  align-items: flex-start;
}

.bot-message .message-content {
  background: white;
  border: 1px solid #e1e8ed;
  color: #333;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin: 0;
  display: inline-block;
  max-width: 80%;
  text-align: left;
}

/* 첫 번째 환영 메시지 스타일 개선 */
.welcome-message .message-content {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 2px solid #2196f3;
  color: #0d47a1;
  max-width: 85%;
  padding: 18px 22px;
  line-height: 1.5;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  margin: 0;
  box-shadow: 0 3px 10px rgba(33, 150, 243, 0.15);
  font-weight: 500;
  text-align: left;
}

.welcome-message {
  margin-bottom: 28px;
}

/* Chat form */
.chat-form {
  background: white;
  padding: 20px;
  border-top: 1px solid #e1e8ed;
}

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

#user-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 48px;
  max-height: 120px;
  transition: border-color 0.2s ease;
}

#user-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#user-input::placeholder {
  color: #999;
}

#send-button {
  background: #007bff;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

#send-button:hover:not(:disabled) {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

#send-button:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Loading animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e1e8ed;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  max-width: 80px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingDot 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 typingDot {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Code blocks in messages */
.message-content pre {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
}

.message-content code {
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  header h1 {
    font-size: 2rem;
  }
  
  header p {
    font-size: 1rem;
  }
  
  .message-content {
    max-width: 90%;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  #send-button {
    align-self: flex-end;
    min-width: 100px;
  }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

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

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

.search-results {
  margin: 10px 0;
  padding: 10px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.search-results h4 {
  margin: 0 0 10px 0;
  color: #495057;
  font-size: 0.9em;
}

.search-result {
  margin: 8px 0;
  padding: 8px;
  background-color: white;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.result-title {
  font-weight: bold;
  color: #212529;
  margin-bottom: 4px;
}

.result-text {
  color: #495057;
  font-size: 0.9em;
  margin-bottom: 4px;
  white-space: pre-wrap;
}

.result-score {
  color: #6c757d;
  font-size: 0.8em;
  text-align: right;
}
