:root {
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Nanum Gothic', 'Noto Sans KR', sans-serif;
  background-color: #121212;  /* 다크 모드 배경 */
  color: #e0e0e0;
  overflow: hidden;
  display: flex;
}

/* ================== Sidebar ================== */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background-color: #1e1e1e;
  border-right: 1px solid #333;
  padding: 24px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  flex-shrink: 0;
  user-select: none;
  box-shadow: 3px 0 15px rgba(0,0,0,0.3);
}

#sidebar h2 {
  color: #ff5252;  /* Red 강조 */
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
  white-space: nowrap;
}

#room-list {
  flex: 1;
  overflow-y: auto;
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #333;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: #ff5252 transparent;
  margin-bottom: 16px;
}

#room-list ul { list-style: none; }

#room-list li {
  padding: 12px 24px;
  cursor: pointer;
  color: #aaa;
  transition: background-color 0.25s ease, color 0.25s ease, border-left-color 0.25s ease;
  border-left: 4px solid transparent;
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}

#room-list li:hover {
  background-color: #2a2a2a;
  color: #ff5252;
}

#room-list li.active {
  background-color: #3a3a3a;
  color: #ff5252;
  border-left-color: #ff5252;
}

#new-room-btn {
  background-color: #ff5252;
  color: #121212;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255,82,82,0.4);
  user-select: none;
  transition: background-color 0.3s ease, transform 0.1s ease;
  width: 100%;
  margin-top: auto;
}

#new-room-btn:hover { background-color: #e04848; }
#new-room-btn:active { transform: translateY(2px); }

/* ================== Main Chat ================== */
#main-area {
  flex-grow: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #121212;
  overflow: hidden;
  position: relative;
}

#chat-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px 24px 90px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: #ff5252 transparent;
  background-color: #121212;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.message {
  max-width: 75%;
  padding: 18px 26px;
  border-radius: 26px;
  font-size: 17px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0;
  animation: fadeSlideUp 0.4s forwards;
  position: relative;
  user-select: text;
  transition: background-color 0.25s ease;
}

.message.user {
  background: linear-gradient(135deg, #9e9e9e, #ff5252);
  color: #121212;
  align-self: flex-end;
  border-bottom-right-radius: 8px;
  box-shadow: 0 6px 20px rgba(255,82,82,0.3);
}

.message.bot {
  background-color: #1e1e1e;
  color: #e0e0e0;
  align-self: flex-start;
  border-bottom-left-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

pre {
  background-color: #1e1e1e;
  border-radius: 16px;
  padding: 20px 28px;
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid #333;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: #e0e0e0;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  position: relative;
  user-select: text;
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background-color: #ff5252;
  color: #121212;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
  user-select: none;
}

pre:hover .copy-btn { opacity: 1; }

/* ================== Input ================== */
#input-area {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 60px;
  background-color: #1e1e1e;
  border-top: 1px solid #333;
  box-shadow: 0 -1px 15px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 9999;
}

#input-text {
  flex: 1;
  font-size: 17px;
  border: 1.8px solid #333;
  border-radius: 30px;
  padding: 14px 24px;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  font-family: 'Nanum Gothic', monospace;
  background-color: #121212;
  color: #e0e0e0;
  outline-offset: 4px;
  box-shadow: inset 0 0 8px #333;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#input-text:focus {
  border-color: #ff5252;
  box-shadow: 0 0 0 6px rgba(255,82,82,0.2);
}

#send-btn {
  background-color: #ff5252;
  color: #121212;
  border: none;
  font-weight: 700;
  padding: 0 30px;
  margin-left: 18px;
  border-radius: 34px;
  cursor: pointer;
  font-size: 17px;
  box-shadow: 0 6px 18px rgba(255,82,82,0.4);
  user-select: none;
  transition: background-color 0.3s ease, transform 0.12s ease;
  height: 40px;
  align-self: center;
}

#send-btn:hover { background-color: #e04848; }
#send-btn:active { transform: translateY(2px); }
#send-btn:disabled { background-color: #333; cursor: not-allowed; box-shadow: none; transform: none; }

/* ================== Scrollbar ================== */
#room-list::-webkit-scrollbar,
#chat-container::-webkit-scrollbar { width: 8px; }
#room-list::-webkit-scrollbar-track,
#chat-container::-webkit-scrollbar-track { background: transparent; }
#room-list::-webkit-scrollbar-thumb,
#chat-container::-webkit-scrollbar-thumb {
  background-color: #ff5252;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ================== Responsive ================== */
@media (max-width: 900px) {
  #sidebar { width: 220px; padding: 20px 16px; font-size: 14px; }
  #chat-container { padding: 20px 16px 90px 16px; }
  .message { max-width: 85%; font-size: 16px; padding: 16px 20px; }
  #input-text { font-size: 16px; padding: 14px 20px; }
  #send-btn { padding: 0 24px; font-size: 16px; margin-left: 14px; }
  #input-area { left: 220px; }
}

@media (max-width: 600px) {
  #sidebar { display: none; }
  #main-area { height: 100vh; }
  #input-text { font-size: 15px; padding: 12px 16px; }
  #send-btn { padding: 0 20px; font-size: 15px; margin-left: 10px; }
  .message { max-width: 90%; font-size: 15px; padding: 14px 18px; }
  #input-area { left: 0; }
}
