/* --------------------------------------------------------------
   GLOBAL RESET & DARK THEME
   -------------------------------------------------------------- */
* { box-sizing: border-box; margin:0; padding:0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #111113;
  color: #e0e0e0;
}

/* --------------------------------------------------------------
   LAYOUT
   -------------------------------------------------------------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --------------------------------------------------------------
   SIDEBAR – COLLAPSIBLE
   -------------------------------------------------------------- */
.sidebar {
  width: 260px;
  background: #1e1e1f;
  border-right: 1px solid #343536;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease-in-out;
  position: relative;
  z-index: 10;
}
.sidebar.collapsed {
  transform: translateX(-260px);
}

/* Toggle button (appears when collapsed) */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -36px;
  width: 36px;
  height: 36px;
  background: #2a2a2b;
  border: none;
  border-radius: 0 8px 8px 0;
  color: #bbb;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 8px rgba(0,0,0,.3);
}
.sidebar.collapsed .sidebar-toggle { right: 0; }

/* New chat button */
.new-chat-btn {
  margin: 1rem;
  padding: .6rem 1rem;
  background: #2a2a2b;
  border: 1px solid #404040;
  color: #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  transition: background .2s;
}
.new-chat-btn:hover { background: #343536; }

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 .5rem;
}
.chat-item {
  display: flex;
  align-items: center;
  padding: .6rem .8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  word-break: break-word;
  margin: .2rem 0;
  transition: background .2s;
}
.chat-item:hover { background: #2a2a2b; }
.chat-item.active { background: #343536; font-weight: 500; }
.chat-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item .delete {
  margin-left: .5rem;
  opacity: 0;
  transition: opacity .2s;
  background: none;
  border: none;
  color: #ff5f5f;
  cursor: pointer;
  font-size: 1.2rem;
}
.chat-item:hover .delete { opacity: 1; }

/* --------------------------------------------------------------
   MAIN CHAT AREA – DARK + CURVED
   -------------------------------------------------------------- */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #111113;
  border-radius: 12px;
  margin: .5rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.messages {
  flex: 1;
  padding: 1.2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Message bubbles */
.message {
  max-width: 78%;
  padding: .8rem 1.2rem;
  border-radius: 18px;
  line-height: 1.5;
  word-wrap: break-word;
}
.message.user {
  align-self: flex-end;
  background: #007bff;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant {
  align-self: flex-start;
  background: #2a2a2b;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

/* Input area */
.input-area {
  display: flex;
  border-top: 1px solid #343536;
  padding: .6rem;
  background: #1e1e1f;
}
.input-area input {
  flex: 1;
  padding: .7rem 1rem;
  background: #2a2a2b;
  border: 1px solid #404040;
  border-radius: 12px 0 0 12px;
  color: #e0e0e0;
  font-size: 1rem;
}
.input-area input::placeholder { color: #777; }
.input-area button {
  padding: 0 1.4rem;
  background: #007bff;
  color: #fff;
  border: none;
  border-radius: 0 12px 12px 0;
  cursor: pointer;
  font-size: 1rem;
}
.input-area button:hover { background: #0056b3; }

.loading { color: #777; font-style: italic; }

.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -36px;
  width: 36px;
  height: 36px;
  background: #2a2a2b;
  border: none;
  border-radius: 0 8px 8px 0;
  color: #bbb;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 8px rgba(0,0,0,.3);
  font-weight: bold;
}
.sidebar.collapsed .sidebar-toggle { right: 0; }

/* --------------------------------------------------------------
   SCROLLBARS (optional – nice dark look)
   -------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #404040; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }