/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* ROOT COLORS */
:root {
  --purple: #b84bff;
  --purple-glow: rgba(184, 75, 255, 0.8);
  --purple-dark: #2a0040;
  --black: #0a0a0a;
  --black-deep: #000000;
  --white: #ffffff;
  --grey: #1f1f1f;
}

/* BODY */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: radial-gradient(circle at top, #240034 0%, #000 70%);
  color: var(--white);
}

/* HEADER */
header {
  background: linear-gradient(90deg, #230033, #1a001f);
  color: var(--purple);
  padding: 1rem;
  text-align: center;
  font-size: 1.6rem;
  font-weight: bold;
  text-shadow: 0 0 10px var(--purple-glow);
  border-bottom: 1px solid var(--purple);
  box-shadow: 0 0 25px rgba(184, 75, 255, 0.2);
}

/* MAIN LAYOUT */
#container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
#sidebar {
  width: 230px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--purple);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  box-shadow: inset -3px 0 10px rgba(184, 75, 255, 0.2);
}

#sidebar h2 {
  color: var(--purple);
  margin-bottom: 1rem;
  font-size: 1.2rem;
  text-shadow: 0 0 10px var(--purple);
}

/* CHAT LIST */
#chat-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

#chat-list li {
  padding: .6rem;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: .4rem;
  background: rgba(255,255,255,0.03);
  transition: 0.2s;
  color: #e8cfff;
}

#chat-list li:hover {
  background: rgba(184, 75, 255, 0.2);
  box-shadow: 0 0 10px var(--purple-glow);
}

#chat-list li.active {
  background: var(--purple);
  color: var(--black);
  font-weight: bold;
  box-shadow: 0 0 12px var(--purple-glow);
}

/* NEW CHAT BUTTON */
#new-chat {
  padding: .6rem;
  background: var(--purple);
  color: var(--black);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
  box-shadow: 0 0 12px var(--purple-glow);
}

#new-chat:hover {
  filter: brightness(1.2);
}

/* MAIN CHAT AREA */
#main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--black-deep);
}

/* CHAT WINDOW */
#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

/* MESSAGES */
.user-msg, .ai-msg {
  padding: .7rem 1rem;
  border-radius: 10px;
  max-width: 70%;
  word-wrap: break-word;
  font-size: .95rem;
}

/* USER MESSAGES */
.user-msg {
  background: var(--purple);
  color: var(--black);
  align-self: flex-end;
  font-weight: bold;
  box-shadow: 0 0 12px var(--purple-glow);
}

/* AI MESSAGES */
.ai-msg {
  background: #110016;
  border: 1px solid var(--purple-dark);
  color: #e8cfff;
  align-self: flex-start;
  box-shadow: 0 0 10px rgba(184, 75, 255, 0.15);
}

/* CHAT INPUT BAR */
#chat-form {
  display: flex;
  padding: .5rem;
  background: #0b0010;
  border-top: 1px solid var(--purple);
}

#chat-input {
  flex: 1;
  padding: .7rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--purple);
  background: #14001c;
  color: white;
  outline: none;
  box-shadow: 0 0 8px rgba(184, 75, 255, 0.4);
}

#send-btn {
  margin-left: .5rem;
  padding: 0 1.2rem;
  background: var(--purple);
  color: var(--black);
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 0 12px var(--purple-glow);
  transition: .2s;
}

#send-btn:hover {
  filter: brightness(1.2);
}

/* SCROLLBAR */
#chat-window::-webkit-scrollbar { width: 8px; }
#chat-window::-webkit-scrollbar-thumb {
  background: var(--purple);
  border-radius: 5px;
}

/* MOBILE */
@media (max-width: 768px) {
  #container { flex-direction: column; }
  #sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--purple);
  }
  #chat-list {
    display: flex;
    flex-direction: row;
    gap: .4rem;
  }
  #chat-list li {
    white-space: nowrap;
    padding: .5rem 1rem;
  }
}
