
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f13;
  --surface:   #17171f;
  --surface2:  #1e1e28;
  --border:    #2a2a38;
  --accent:    #7C3AED;
  --accent-dim:#5b21b6;
  --text:      #e8e8f0;
  --text-dim:  #8888aa;
  --bot-bg:    #1a1a2e;
  --user-bg:   #2d1f6b;
  --danger:    #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { display: none; height: 100vh; }
.screen.active { display: flex; }
.hidden { display: none !important; }

#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #2d1f6b44 0%, transparent 70%), var(--bg);
}
.login-box {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 32px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }

input[type=text], input[type=password] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

.err {
  color: var(--danger); font-size: 13px; margin-bottom: 12px;
  padding: 8px 12px; background: #ef444415; border-radius: 8px;
}

button[type=submit], .primary-btn {
  width: 100%; background: var(--accent); color: white;
  border: none; border-radius: 8px; padding: 11px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.15s; margin-top: 4px;
}
button[type=submit]:hover, .primary-btn:hover { background: var(--accent-dim); }

.icon-btn {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: flex; align-items: center; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

.ghost-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; padding: 5px 12px;
  border-radius: 20px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

#app-screen { flex-direction: row; }

#sidebar {
  width: 260px; min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 14px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.rooms-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); padding: 16px 16px 6px;
}
#room-list { flex: 1; overflow-y: auto; padding: 4px 8px; }

.room-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  transition: background 0.12s;
}
.room-item:hover, .room-item.active { background: var(--surface2); }

.room-avi, .avi {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: white;
}
.room-item-info { flex: 1; overflow: hidden; }
.room-item-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item-last { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.sidebar-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-top: 1px solid var(--border);
}
#user-pill { display: flex; align-items: center; gap: 9px; overflow: hidden; }
#user-avi {
  width: 30px; height: 30px; min-width: 30px; border-radius: 8px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
#user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; color: var(--text-dim); padding: 40px; text-align: center;
}
#empty-state svg { opacity: 0.3; }
#empty-state h2 { font-size: 22px; color: var(--text); }
#empty-state p { font-size: 14px; max-width: 380px; line-height: 1.6; }
#empty-state .primary-btn { width: auto; padding: 10px 28px; margin-top: 8px; }

#chat-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-head-left { display: flex; align-items: center; gap: 12px; }
#chat-avi {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.chat-title { font-size: 15px; font-weight: 600; }
.chat-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

#messages {
  flex: 1; overflow-y: auto; padding: 24px 20px 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}

.msg { display: flex; flex-direction: column; max-width: 72%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; }
.msg-sender { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 4px; padding: 0 4px; }
.msg.user .msg-sender { text-align: right; }
.msg-bubble {
  padding: 11px 15px; border-radius: 14px;
  font-size: 14px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.msg.bot .msg-bubble { background: var(--bot-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.user .msg-bubble { background: var(--user-bg); border-bottom-right-radius: 4px; }
.msg-time { font-size: 11px; color: var(--text-dim); margin-top: 3px; padding: 0 4px; }
.msg.user .msg-time { text-align: right; }

.typing {
  display: flex; gap: 5px; align-items: center;
  padding: 12px 16px; background: var(--bot-bg);
  border: 1px solid var(--border); border-radius: 14px;
  border-bottom-left-radius: 4px; width: fit-content;
}
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim); animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

#chips { display: flex; gap: 8px; padding: 10px 20px 6px; flex-wrap: wrap; }
.chip {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; padding: 5px 12px;
  border-radius: 20px; cursor: pointer; transition: all 0.12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--surface2); }

#msg-form {
  display: flex; gap: 10px; padding: 12px 20px 16px;
  background: var(--surface); border-top: 1px solid var(--border);
}
#msg-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; color: var(--text);
  font-size: 14px; outline: none; transition: border-color 0.15s;
}
#msg-input:focus { border-color: var(--accent); }
#send-btn {
  background: var(--accent); border: none; border-radius: 10px;
  width: 42px; height: 42px; cursor: pointer; color: white;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
}
#send-btn:hover { background: var(--accent-dim); }

#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; width: 360px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h3 { font-size: 17px; font-weight: 600; }
.modal .field { margin-bottom: 20px; }
.modal .primary-btn { margin-top: 0; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
