* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --panel-2: #181c25;
  --border: #272d38;
  --text: #f5f7fb;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent-hover: #6948f5;
  --user: #29223f;
  --assistant: #151922;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  display: flex;
  width: 100%;
  height: 100%;
}

/* SIDEBAR */

#sidebar {
  width: 270px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 25px;
}

.sidebar-header span {
  color: var(--accent);
  font-size: 13px;
  font-weight: bold;
}

#newChatBtn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  background: var(--panel-2);
  color: var(--text);
  transition: 0.2s;
}

#newChatBtn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

#chatHistory {
  flex: 1;
  overflow-y: auto;
  margin-top: 18px;
}

.history-item {
  padding: 11px 12px;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background: var(--panel-2);
  color: var(--text);
}

.history-item.active {
  background: var(--panel-2);
  color: var(--text);
}

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

.sidebar-bottom button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px;
  text-align: left;
  border-radius: 8px;
  margin-top: 3px;
}

.sidebar-bottom button:hover {
  background: var(--panel-2);
  color: var(--text);
}

/* MAIN */

#main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* TOP BAR */

#topbar {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.92);
}

#menuBtn,
#clearBtn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 19px;
  padding: 8px;
  border-radius: 8px;
}

#menuBtn:hover,
#clearBtn:hover {
  background: var(--panel-2);
  color: var(--text);
}

#menuBtn {
  display: none;
}

.title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.title strong {
  font-size: 18px;
}

.title span {
  color: var(--accent);
  font-size: 12px;
  font-weight: bold;
}

/* CHAT */

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 30px 20px 120px;
}

#welcome {
  max-width: 700px;
  margin: 70px auto;
  text-align: center;
}

.logo {
  width: 70px;
  height: 70px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--accent);
  font-size: 25px;
  font-weight: bold;
  box-shadow: 0 10px 35px rgba(124, 92, 255, 0.25);
}

#welcome h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

#welcome p {
  margin: 0;
  color: var(--muted);
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 28px;
}

.suggestion {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 11px;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

/* MESSAGES */

.message-row {
  display: flex;
  width: 100%;
  margin: 14px 0;
}

.message-row.user {
  justify-content: flex-end;
}

.message {
  max-width: min(760px, 85%);
  padding: 13px 16px;
  border-radius: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  background: var(--user);
  border-bottom-right-radius: 5px;
}

.message.assistant {
  background: var(--assistant);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

/* TYPING */

#typing {
  position: absolute;
  left: 24px;
  bottom: 90px;
  display: flex;
  gap: 5px;
}

#typing span {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1s infinite;
}

#typing span:nth-child(2) {
  animation-delay: 0.15s;
}

#typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.hidden {
  display: none !important;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-5px);
  }
}

/* INPUT */

#inputArea {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(850px, calc(100% - 40px));
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
}

#messageInput {
  flex: 1;
  resize: none;
  max-height: 160px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  line-height: 1.4;
}

#messageInput::placeholder {
  color: #697384;
}

#sendBtn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-size: 19px;
}

#sendBtn:hover {
  background: var(--accent-hover);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

footer {
  position: absolute;
  bottom: 5px;
  width: 100%;
  text-align: center;
  color: #626b79;
  font-size: 10px;
  pointer-events: none;
}

/* MODAL */

#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

#modalBox {
  width: min(600px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 25px;
}

#closeModal {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 18px;
}

#closeModal:hover {
  color: var(--text);
}

/* MOBILE */

@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    left: -285px;
    top: 0;
    transition: left 0.25s ease;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.4);
  }

  #sidebar.open {
    left: 0;
  }

  #menuBtn {
    display: block;
  }

  #overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
  }

  #overlay.show {
    display: block;
  }

  #chat {
    padding-left: 12px;
    padding-right: 12px;
  }

  #welcome {
    margin: 45px auto;
  }

  #welcome h2 {
    font-size: 23px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 90%;
  }

  #inputArea {
    width: calc(100% - 20px);
    bottom: 22px;
  }

  footer {
    display: none;
  }
}

/* TJ Purple Spider Logo */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  margin: 0 auto 20px;
}

.logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.logo-circle {
  fill: #171020;
  stroke: #a855f7;
  stroke-width: 4;
}

.spider {
  fill: #a855f7;
}

.eye {
  fill: #ffffff;
}

.leg {
  fill: none;
  stroke: #a855f7;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

