/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #212121;
  --bg-secondary: #171717;
  --bg-input: #2f2f2f;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #6b6b6b;
  --accent: #10a37f;
  --accent-hover: #0e8c6b;
  --border: #424242;
  --sidebar-width: 260px;
  --user-msg-bg: #2f2f2f;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ─── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  height: 100vh;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-header-row .btn-new-chat {
  flex: 1;
}

.sidebar-toggle-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-new-chat {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-new-chat:hover { background: var(--bg-input); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.15s;
  margin-bottom: 2px;
}
.chat-item:hover, .chat-item.active {
  background: var(--bg-input);
  color: var(--text-primary);
}

.chat-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 2px;
}
.chat-item:hover .del-btn { opacity: 1; }
.del-btn:hover { color: #ef4444; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

/* ─── Main area ───────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

/* ─── Empty state ─────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}
.empty-state h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
}
.empty-state .subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 400px;
  line-height: 1.5;
}

/* ─── Chat area ───────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
}

.message {
  max-width: 768px;
  margin: 0 auto 24px;
  width: 100%;
  display: flex;
}
.message.user { justify-content: flex-end; }
.message.user .msg-content {
  background: var(--user-msg-bg);
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  max-width: 70%;
  line-height: 1.5;
  font-size: 15px;
}
.message.assistant { justify-content: flex-start; }
.message.assistant .msg-content {
  padding: 4px 0;
  line-height: 1.6;
  font-size: 15px;
  color: var(--text-primary);
}

/* ─── Play audio button ─────────────────────────────── */
.chat-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  margin: 4px 0;
  cursor: pointer;
  display: block;
}

.play-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}
.play-btn:hover { background: rgba(16, 163, 127, 0.1); }

/* ─── Input area ──────────────────────────────────────── */
.input-area {
  padding: 0 16px 24px;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}



.input-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  transition: border-color 0.15s;
}
.input-wrapper:focus-within {
  border-color: var(--accent);
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
  font-family: inherit;
}
#user-input::placeholder { color: var(--text-muted); }

.img-btn, .mic-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.img-btn:hover, .mic-btn:hover { background: var(--border); }

.mic-btn.recording {
  color: #ef4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.send-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.5; cursor: default; }

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

/* ─── Mobile hamburger & overlay ──────────────────────── */
.menu-btn {
  display: none; /* hidden by default, shown on mobile or when sidebar hidden */
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 999;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
}
.menu-btn:hover { background: var(--border); }
.menu-btn.desktop-visible {
  display: block !important;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

/* ─── Sidebar resizer (draggable divider) ────────────── */
.sidebar-resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
}
.sidebar-resizer:hover {
  background: var(--accent);
}

/* ─── Desktop sidebar hidden state ───────────────────── */
.sidebar.desktop-hidden {
  display: none;
}
.sidebar-resizer.desktop-hidden {
  display: none;
}

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive: ≤900px ──────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    z-index: 100;
    transition: left 0.25s ease;
    height: 100vh;
    box-shadow: 2px 0 12px rgba(0,0,0,0.4);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; }
  .sidebar-resizer { display: none; }
  .sidebar-toggle-btn { display: none; }
  .menu-btn { display: block; }
  .messages { padding: 60px 12px 16px; }
  .empty-state h1 { font-size: 22px; padding: 0 16px; }
  .empty-state .subtitle { font-size: 14px; padding: 0 24px; }
  .message { margin-bottom: 16px; }
  .message.user .msg-content { max-width: 85%; font-size: 14px; }
  .message.assistant .msg-content { font-size: 14px; }
  .input-area { padding: 0 12px 16px; }
}
