/* ================= CSS ================= */
:root {
  --bg1: #0f0c29;
  --bg2: #302b63;
  --bg3: #24243e;
  --glass: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.1);
  --text-color: #ffffff;
  --user-msg-bg: linear-gradient(45deg, #353d3d, #9575ae);
  --ai-msg-bg: var(--glass);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(-45deg, var(--bg1), var(--bg2), var(--bg3));
  background-size: 400% 400%;
  animation: gradientMove 12s ease infinite;
  color: var(--text-color);
}

@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.app {
  display: flex;
  width: 95%;
  max-width: 1400px;
  height: 95vh;
  background: var(--glass);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.3);
  flex-direction: row;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  min-width: 180px;
  overflow-y: auto;
}

.logo { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 25px; }
.new-chat {
  padding: 10px; border-radius: 12px; border: 1px solid var(--text-color);
  background: transparent; color: var(--text-color); cursor: pointer; transition: 0.3s;
}
.new-chat:hover { background: var(--glass); }

.history { flex: 1; overflow-y: auto; scroll-behavior: smooth; margin-top: 20px; }
.history-item { padding: 10px; border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: 0.3s; }
.history-item:hover, .history-item.active { background: var(--glass); }

.profile { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.avatar { width: 40px; height: 40px; background: var(--text-color); border-radius: 50%; }

/* Chat Section */
.chat-section { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-header { display: flex; align-items: center; gap: 15px; padding: 20px; border-bottom: 1px solid var(--border); }
.ai-avatar { width: 45px; height: 45px; border-radius: 50%; background: var(--text-color); }

.chat-window {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 15px;
  margin-bottom: 15px;
  animation: fadeIn 0.4s ease;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.ai { background: var(--ai-msg-bg); backdrop-filter: blur(10px); align-self: flex-start; }
.message.user { background: var(--user-msg-bg); align-self: flex-end; }

@keyframes fadeIn { from {opacity:0; transform:translateY(10px);} to {opacity:1; transform:translateY(0);} }

/* Input Area */
.input-area { display: flex; padding: 15px; border-top: 1px solid var(--border); gap: 10px; }
textarea {
  flex: 1; resize: none; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--glass); color: var(--text-color); outline: none;
  min-height: 45px; max-height: 150px; overflow-y: auto;
}
.actions button {
  padding: 10px 14px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--glass); color: var(--text-color); transition: 0.3s;
}
.actions button:hover { background: rgba(255,255,255,0.1); }

/* Responsive tweaks */
@media screen and (max-width: 1024px) {
  .app { flex-direction: column; height: 95vh; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  .chat-section { width: 100%; flex: 1; }
}

@media screen and (max-width: 768px) {
  .sidebar { width: 200px; padding: 10px; }
  .chat-header, .chat-window, .input-area { padding: 12px; }
  .message { max-width: 85%; }
}

@media screen and (max-width: 480px) {
  .message { max-width: 95%; font-size: 14px; }
  textarea { font-size: 14px; }
}

.chat-window::-webkit-scrollbar, .history::-webkit-scrollbar { width: 8px; }
.chat-window::-webkit-scrollbar-thumb, .history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
