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

:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --bg: #f5f5f5;
  --bg-chat: #ffffff;
  --text: #222;
  --text-light: #666;
  --border: #e0e0e0;
  --user-bubble: #1976d2;
  --user-text: #fff;
  --bot-bubble: #f0f0f0;
  --bot-text: #222;
  --header-height: 48px;
  --input-height: 56px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* Header (hidden when embedded in iframe) */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 10;
  font-weight: 600;
  font-size: 16px;
  gap: 8px;
}

.embedded .header { display: none; }
.embedded .messages { margin-top: 0; }

.header-status {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  margin-left: auto;
}

/* Login screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 24px;
  text-align: center;
}

.login-screen h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-screen p {
  color: var(--text-light);
  margin-bottom: 24px;
  max-width: 320px;
}

.login-input {
  width: 100%;
  max-width: 300px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.login-btn {
  padding: 12px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 8px;
}

/* Chat area */
.chat-container {
  display: none;
  flex-direction: column;
  height: 100vh;
}

.chat-container.active {
  display: flex;
}

/* Listing context banner */
.listing-banner {
  padding: 8px 12px;
  background: #263238;
  color: #fff;
  font-size: 12px;
  display: none;
  flex-shrink: 0;
}

.embedded .listing-banner { margin-top: 0; }

.listing-banner.active { display: block; }
.embedded .listing-banner.active { display: none; }

.listing-banner-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.listing-banner-details {
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
  font-size: 11px;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  margin-top: var(--header-height);
  -webkit-overflow-scrolling: touch;
}

.listing-banner.active + .messages {
  margin-top: 0;
}

.message {
  display: flex;
  margin-bottom: 8px;
  max-width: 95%;
}

.embedded .message { max-width: 100%; margin-bottom: 6px; }
.embedded .messages { padding: 8px; }

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

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

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

.message-bubble strong {
  font-weight: 600;
}

/* Typing indicator */
.typing-bubble .message-bubble {
  background: var(--bot-bubble);
  padding: 14px 20px;
}

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

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Input area */
.input-area {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin: 0 6px 6px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  gap: 4px;
  min-height: 36px;
}

.embedded .input-area {
  padding: 3px 6px;
  margin: 0 4px 4px 4px;
  min-height: 32px;
}

.upload-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-light);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

.upload-btn:hover { color: var(--primary); }

.upload-btn svg {
  width: 16px;
  height: 16px;
}

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 4px;
  font-size: 16px; /* 16px prevents iOS zoom on focus */
  outline: none;
  resize: none;
  max-height: 80px;
  font-family: inherit;
  line-height: 1.3;
}

.send-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-btn:hover { background: var(--primary-dark); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.send-btn svg {
  width: 14px;
  height: 14px;
}
