* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

main {
  width: 100%;
  height: 440px;
  display: flex;
  flex-direction: column;
  color: #2e2e2e;
  background-color: #f1f1f1;
  padding: 0;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Refresh button */
.refresh-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: color 0.2s;
}
.refresh-button:hover:not(:disabled) { color: #333; }

/* Messages */
.messages-wrapper {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 8px 0 0 0;
  scroll-behavior: smooth;
}
.messages-wrapper::-webkit-scrollbar { width: 8px; }
.messages-wrapper::-webkit-scrollbar-track { background: #f1f1f1; }
.messages-wrapper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.messages-wrapper::-webkit-scrollbar-thumb:hover { background: #999; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: flex;
  max-width: 98%;
  margin: 0 4px;
}

.message-content {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
}

.user-message { align-self: flex-end; }
.user-message .message-content {
  background-color: #ff6600;
  color: white;
  border-bottom-right-radius: 4px;
}

.bot-message { align-self: flex-start; }
.bot-message .message-content {
  background-color: white;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-content p {
  margin: 0 0 8px 0;
  white-space: pre-line;
}
.message-content p:last-child { margin-bottom: 0; }

.message-link {
  font-size: 12px;
  color: #666;
}

/* Typing dots */
.typing {
  min-width: 60px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.dot {
  width: 6px;
  height: 6px;
  background: #666;
  border-radius: 50%;
  animation: bounce 1.3s linear infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Error */
.error {
  margin-bottom: 8px;
  padding: 4px;
  background-color: #fff1f0;
  border: 1px solid #ffccc7;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.error p { margin: 0; color: #cf1322; font-size: 14px; }
.retry-button {
  padding: 4px 8px;
  font-size: 12px;
  background-color: #ff4d4f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.retry-button:hover { background-color: #ff7875; }

/* Footer / input */
.chat-footer {
  padding: 4px;
  background-color: transparent;
}

.chat-form {
  display: flex;
  gap: 4px;
  align-items: flex-start;
}

textarea {
  flex-grow: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 20px;
  resize: none;
  height: 36px;
  line-height: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus {
  outline: none;
  border-color: #ff6600;
  box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.1);
}

.send-button {
  padding: 8px;
  width: 36px;
  height: 36px;
  background-color: #ff6600;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s;
}
.send-button:hover:not(:disabled) { background-color: #e65c00; }
.send-button:disabled { background-color: #ffaa80; }

a {
  color: #ff6600;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: #e65c00; text-decoration: underline; }
