/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
  --accent: #50C6D8;
  --accent-dark: #38afc2;
  --accent-light: #e8f9fb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1a202c;
  --text-secondary: #718096;
  --bot-bubble: #ffffff;
  --user-bubble: #50C6D8;
  --user-text: #ffffff;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--text-primary);
}

/* ============================================================
   Chat Container
   ============================================================ */
.chat-wrapper {
  width: 100%;
  max-width: 680px;
  height: 90vh;
  max-height: 780px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ============================================================
   Header
   ============================================================ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.reset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ============================================================
   Messages Area
   ============================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ============================================================
   Message Bubbles
   ============================================================ */
.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 4px;
}

.bot-message {
  align-self: flex-start;
}

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.bot-message .message-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.user-message .message-bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message-bubble p + p {
  margin-top: 6px;
}

.secondary-text {
  color: var(--text-secondary);
  font-size: 13px;
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 4px;
}

/* Typing indicator */
.typing-indicator .message-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s 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); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Error message */
.error-message .message-bubble {
  background: #fff5f5;
  border-color: #fed7d7;
  color: #c53030;
}

/* ============================================================
   Input Area
   ============================================================ */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}

.input-row:focus-within {
  border-color: var(--accent);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  font-family: inherit;
  padding: 4px 0;
}

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

.send-btn {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

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

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: flex-end;
  }

  .chat-wrapper {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

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