:root {
  --bg: #050507;
  --surface: rgba(18,18,30,0.75);
  --glass: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.08);

  --text: #e5e7eb;
  --muted: #9ca3af;

  --accent: #6a6dfd;
  --accent2: #8b5cf6;

  --radius: 18px;
  --blur: blur(20px);
  --shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* RESET */
*{margin:0;padding:0;box-sizing:border-box;}

body{
  font-family:system-ui;
  background: radial-gradient(circle at top, #0f0f17, #050507);
  color:var(--text);
  height:100vh;
  overflow:hidden;
}

/* LAYOUT */
.app-container{
  display:flex;
  height:100vh;
  overflow:hidden;
}

/* SIDEBAR */
.sidebar{
  width:280px;
  background:var(--surface);
  backdrop-filter:var(--blur);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding:1.5rem;
  gap:1rem;
  z-index:1000;
  transition:transform .3s ease;
}

.sidebar-header,
.sidebar-search,
.sidebar-actions,
.sidebar-footer{
  flex-shrink:0;
}

/* LOGO */
.logo{
  font-size:1.6rem;
  font-weight:800;
  text-align:center;
  background:linear-gradient(90deg,var(--accent),var(--accent2));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
}

/* SEARCH */
#chat-search{
  width:100%;
  padding:0.8rem;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--glass);
  color:var(--text);
}

/* BUTTON */
.new-chat{
  width:100%;
  padding:0.9rem;
  border:none;
  border-radius:14px;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:white;
  font-weight:600;
  cursor:pointer;
  transition:0.2s;
}

.new-chat:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 25px rgba(106,109,253,0.4);
}

/* CHAT LIST */
.chat-list{
  flex:1;
  overflow-y:auto;
  padding-right:4px;
}

.chat-item{
  padding:0.8rem;
  border-radius:12px;
  color:var(--muted);
  cursor:pointer;
  transition:0.2s;
}

.chat-item:hover{
  background:var(--glass);
  color:var(--text);
}

/* MAIN */
.main-content{
  flex:1;
  display:flex;
  flex-direction:column;
  height:100vh;
  overflow:hidden;
  position:relative;
}

/* HEADER */
.chat-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:1rem;
  border-bottom:1px solid var(--border);
  backdrop-filter:var(--blur);
}

.header-center{
  display:flex;
  align-items:center;
  gap:10px;
  margin:auto;
}

.header-avatar{
  width:36px;
  height:36px;
  border-radius:50%;
  border:2px solid var(--accent);
}

/* CHAT */
.chat-container{
  flex:1;
  overflow-y:auto;
  padding:2rem;
  padding-bottom:150px;
  display:flex;
  flex-direction:column;
  gap:0.4rem;
}

/* GROUPING MAGIC */
.message{
  display:flex;
  gap:10px;
  max-width:75%;
  animation:fadeIn .25s ease;
}

/* REDUCE SPACE BETWEEN SAME SENDER */
.message + .message.user{
  margin-top:-8px;
}
.message + .message.bot{
  margin-top:-8px;
}

/* ALIGN */
.message.user{
  align-self:flex-end;
  flex-direction:row-reverse;
}

/* AVATAR */
.avatar{
  width:38px;
  height:38px;
  border-radius:50%;
  flex-shrink:0;
  border:2px solid rgba(255,255,255,0.12);
  opacity:0.9;
}

/* HIDE DUPLICATE AVATARS */
.message + .message .avatar{
  opacity:0;
}

/* BUBBLE */
.bubble{
  padding:0.9rem 1.2rem;
  border-radius:16px;
  backdrop-filter:var(--blur);
  box-shadow:var(--shadow);
  line-height:1.5;
  word-wrap:break-word;
  font-size:0.95rem;
}

/* BOT */
.bot .bubble{
  background:var(--surface);
  border:1px solid var(--border);
}

/* USER */
.user .bubble{
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:white;
}

/* CODE BLOCK SUPPORT */
.bubble pre{
  background:#0d0d12;
  padding:1rem;
  border-radius:12px;
  overflow:auto;
  margin-top:8px;
  font-size:0.85rem;
}

.bubble code{
  color:#8b5cf6;
}

/* INPUT */
.input-area{
  position:absolute;
  bottom:0;
  left:0;
  right:0;
  padding:1rem;
  border-top:1px solid var(--border);
  background:linear-gradient(to top, rgba(5,5,7,0.95), transparent);
  backdrop-filter:var(--blur);
  z-index:500;
}

/* INPUT FORM */
.input-form{
  display:flex;
  align-items:center;
  gap:10px;
  background:var(--glass);
  border-radius:999px;
  padding:8px;
  max-width:900px;
  margin:auto;
  border:1px solid var(--border);
  transition:0.2s;
}

/* INPUT FOCUS GLOW */
.input-form:focus-within{
  border:1px solid var(--accent);
  box-shadow:0 0 0 2px rgba(106,109,253,0.2);
}

/* INPUT */
#user-input{
  flex:1;
  border:none;
  outline:none;
  background:none;
  color:var(--text);
  padding:0.8rem;
}

/* TOOLS */
.input-tools{
  display:flex;
  gap:5px;
}

/* BUTTONS */
.tool-btn{
  border:none;
  background:none;
  color:var(--muted);
  padding:0.6rem;
  border-radius:50%;
  cursor:pointer;
  transition:0.2s;
}

.tool-btn:hover{
  background:var(--glass);
  color:var(--text);
}

/* SEND */
.send-btn{
  width:48px;
  height:48px;
  border-radius:50%;
  border:none;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:white;
  cursor:pointer;
  transition:0.2s;
}

.send-btn:hover{
  transform:scale(1.08);
}

/* MODAL */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.6);
  z-index:3000;
}

.modal-content{
  background:var(--surface);
  backdrop-filter:var(--blur);
  padding:2rem;
  border-radius:18px;
  width:90%;
  max-width:480px;
}

/* ANIMATION */
@keyframes fadeIn{
  from{opacity:0;transform:translateY(6px);}
  to{opacity:1;}
}

/* MOBILE */
@media(max-width:768px){

  .sidebar{
    position:fixed;
    top:0;
    left:0;
    height:100%;
    transform:translateX(-100%);
    z-index:2000;
  }

  .sidebar.open{
    transform:translateX(0);
  }

  .chat-container{
    padding:1.2rem;
    padding-bottom:150px;
  }

  .message{
    max-width:90%;
  }
}