@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #000000;
  --bg-sidebar: #16181c;
  --bg-input: #202327;
  --text-main: #e7e9ea;
  --text-muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --border-color: #2f3336;
  --bot-msg-bg: transparent;
  --user-msg-bg: #202327;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-grow: 1;
}

.nav-item {
  color: var(--text-main);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color 0.2s;
}

.nav-item:hover {
  background-color: rgba(255,255,255,0.1);
}
.nav-item.active {
  font-weight: 700;
}

.settings-panel {
  background: var(--bg-input);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}
.settings-panel h3 {
  font-size: 0.9rem;
  margin-bottom: 15px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 5px;
  color: var(--text-muted);
}
.field input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
}

/* ── Main Chat ── */
.chat-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-header {
  height: 60px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title h2 {
  font-size: 1.2rem;
  font-weight: 700;
}
.status-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-history {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px 20px 120px 20px; /* padding bottom for input */
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* ── Messages ── */
.message {
  display: flex;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.message .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.bot-message .avatar {
  background: #fff;
  color: #000;
}

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

.user-message .avatar {
  background: var(--accent);
  color: #fff;
}

.content {
  background: var(--bot-msg-bg);
  padding: 12px 0;
  line-height: 1.6;
  font-size: 1rem;
  width: 100%;
}

.user-message .content {
  background: var(--user-msg-bg);
  padding: 12px 18px;
  border-radius: 16px 4px 16px 16px;
  width: auto;
  max-width: 80%;
}

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

/* Image generation result */
.gen-image-container {
  margin-top: 15px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  max-width: 512px;
}
.gen-image-container img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.gen-image-loading {
  width: 100%;
  height: 300px;
  background: linear-gradient(90deg, #16181c 25%, #202327 50%, #16181c 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Input Area ── */
.chat-input-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(0deg, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.input-wrapper {
  max-width: 800px;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  display: flex;
  align-items: flex-end;
  padding: 10px 16px;
  gap: 10px;
}
.input-wrapper:focus-within {
  border-color: var(--accent);
}

#chatInput {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1rem;
  resize: none;
  outline: none;
  max-height: 200px;
  padding: 8px 0;
  font-family: inherit;
  line-height: 1.5;
}
#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--text-main);
  color: var(--bg-dark);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 4px;
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 20px;
}
.typing-indicator .avatar {
  background: #fff;
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
}
.dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
