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

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --bot-bg: #f0f7ff;
  --user-bg: #0066cc;
  --user-text: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  padding: 20px 0;
}

header h1 {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 5px;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e;
}

.status-dot.offline {
  background: #ef4444;
}

.last-updated {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

/* Chat */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
  min-height: 400px;
  max-height: 60vh;
}

.message {
  margin-bottom: 20px;
  animation: fadeIn 0.2s ease;
}

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

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.95rem;
}

.message-content p {
  margin-bottom: 10px;
}

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

.bot-message .message-content {
  background: var(--bot-bg);
  border-bottom-left-radius: 4px;
}

.user-message {
  text-align: right;
}

.user-message .message-content {
  background: var(--user-bg);
  color: var(--user-text);
  display: inline-block;
  text-align: left;
  border-bottom-right-radius: 4px;
}

/* Sources */
.sources {
  margin-top: 10px;
  padding: 10px 15px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.85rem;
}

.sources strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text-light);
}

.sources ul {
  list-style: none;
}

.sources li {
  margin: 3px 0;
}

.sources a {
  color: var(--primary);
  text-decoration: none;
}

.sources a:hover {
  text-decoration: underline;
}

/* Typing indicator */
.typing .message-content {
  display: flex;
  gap: 4px;
  padding: 16px;
}

.typing .dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing .dot:nth-child(1) { animation-delay: -0.32s; }
.typing .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input */
.input-container {
  display: flex;
  gap: 10px;
  background: var(--surface);
  padding: 15px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#message-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 15px;
  font-size: 0.95rem;
  resize: none;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#message-input:focus {
  border-color: var(--primary);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-btn:hover {
  background: var(--primary-dark);
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px 0 10px;
  font-size: 0.8rem;
  color: var(--text-light);
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .chat-container {
    min-height: 300px;
    padding: 10px;
  }

  .message-content {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .status-bar {
    flex-wrap: wrap;
  }

  .last-updated {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    margin-top: 5px;
  }
}
