/* =========================================================
   EmpathEra-AI Chat — MASTER-55-PROD-SAFE
   Single Scroll Root + Stable UI
========================================================= */

/* ================= VARIABLES ================= */

:root {
  --bg-main: #050010;
  --accent: #7b2bff;
  --accent-soft: #3b0078;
  --accent-strong: #ff2b70;
  --text-main: #ffffff;
  --sidebar-w: 180px;
}

/* ================= BASE ================= */

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* SINGLE SCROLL ROOT */
}

body.chat-page {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top, #1b0040 0%, #050010 60%);
  color: var(--text-main);
}

/* ================= APP ROOT ================= */

.chat-app {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* ================= SIDEBAR ================= */

.chat-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #070015, #15002e);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

body.sidebar-collapsed .chat-sidebar {
  width: 0;
}

/* ================= SIDEBAR CONTENT ================= */

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-top {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.sidebar-bottom {
  padding: 10px;
  background: linear-gradient(180deg, #120025, #080012);
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ================= SIDEBAR BUTTONS ================= */

.sidebar-logo {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}

.sidebar-button {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
}

.sidebar-button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

.sidebar-button.danger {
  background: rgba(255,80,80,0.15);
}

/* ================= THREAD LIST ================= */

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.chat-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
}

.chat-list-item.active {
  background: rgba(123,43,255,0.35);
}

.chat-delete {
  opacity: 0.6;
  cursor: pointer;
}

.chat-delete:hover {
  opacity: 1;
  color: #ff5b5b;
}

/* ================= SIDEBAR TOGGLE ================= */

.sidebar-toggle-btn {
  position: fixed;
  left: calc(var(--sidebar-w) - 19px);
  top: 46%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle, #ff7be0, #7b2bff);
  color: #fff;
  cursor: pointer;
  z-index: 80;
  pointer-events: auto;
}

body.sidebar-collapsed .sidebar-toggle-btn {
  left: 10px;
}

/* ================= FLOATING SCROLL BUTTON ================= */

.scroll-jump-btn {
  position: fixed;
  left: calc(var(--sidebar-w) - 19px);
  top: calc(46% + 52px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle, #ffd4e5, var(--accent-strong));
  color: #fff;
  cursor: pointer;
  z-index: 80;
  pointer-events: auto;
}

body.sidebar-collapsed .scroll-jump-btn {
  left: 10px;
}

/* ================= MAIN COLUMN ================= */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

/* ================= HEADER ================= */

.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}

.mode-selector {
  appearance: none;
  background: linear-gradient(135deg, #2a0a55, #120022);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 6px;
}

.mode-selector option {
  background: #120022;
  color: #fff;
}

.voice-toggle-btn {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* ================= CHAT SCROLL ROOT ================= */
/* THIS IS THE ONLY SCROLLER */

.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 18px;
  overscroll-behavior: contain;
}

/* ================= MESSAGES ================= */

.message {
  max-width: 75%;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.message.user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

.message.ai {
  margin-right: auto;
  background: linear-gradient(135deg, #1f1537, #401f6a);
}

/* ================= INPUT BAR ================= */

.chat-input-bar {
  flex-shrink: 0;
  margin: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent-soft), #1e0035);
  z-index: 10;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  outline: none;
  resize: none;
  font-size: 14px;
  max-height: 140px;
  line-height: 1.4;
}

/* ================= BUTTONS ================= */

.square-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle, #ffe0ff, var(--accent));
  cursor: pointer;
}

.send-btn {
  background: radial-gradient(circle, #ffd4e5, var(--accent-strong));
}

/* ================= DISCLAIMER ================= */

.chat-warning {
  font-size: 11px;
  opacity: 0.7;
  text-align: center;
  margin: 4px 0 6px;
}

/* ================= MOBILE ================= */

@media (max-width: 768px) {
  .message {
    max-width: 88%;
  }

  .chat-container {
    padding: 12px 12px 16px;
  }
}

.thinking-bubble {
  display: inline-flex;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #1f1f1f;
  align-self: flex-start;
  margin: 6px 0;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #aaa;
  animation: pulse 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: 0s; }
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }
.thinking-dot:nth-child(4) { animation-delay: 0.45s; }
.thinking-dot:nth-child(5) { animation-delay: 0.6s; }
.thinking-dot:nth-child(6) { animation-delay: 0.75s; }

@keyframes pulse {
  0% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0.2; transform: scale(0.8); }
}
