@import url("https://fonts.googleapis.com/css2?family=Ubuntu&display=swap");

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Ubuntu", sans-serif;
  -webkit-text-size-adjust: 100%;
  background: #121212;
  color: #f5f5f5;
  font-size: 18px;
  height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.layout {
  display: flex;
  height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.sidebar {
  width: 250px;
  background: #1a1a1a;
  padding: 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #333;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.sidebar button {
  background: #0077cc;
  color: white;
  border: none;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar button:hover {
  background: #005fa3;
}

#chatList {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #4a5161 #1a1a1a;
}

#chatList::-webkit-scrollbar {
  width: 10px;
}

#chatList::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-left: 1px solid #2b2b2b;
}

#chatList::-webkit-scrollbar-thumb {
  background: #4a5161;
  border-radius: 10px;
  border: 2px solid #1a1a1a;
}

#chatList::-webkit-scrollbar-thumb:hover {
  background: #5d6577;
}

#chatList div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

#chatList button {
  background: #2c2c2c;
  color: #ccc;
  border: none;
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
  text-align: left;
  margin-right: 5px;
}

#chatList button:hover {
  background: #3c3c3c;
  color: white;
}

.chat-container {
  flex: 1.6;
  display: flex;
  flex-direction: column;
  padding: 20px;
  min-width: 0;
}

header h1 {
  margin: 0 0 10px;
  font-size: 26px;
}

.chat-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 10px;
  background: #181818;
  border: 1px solid #333;
  border-radius: 6px;
  scrollbar-width: thin;
  scrollbar-color: #4a5161 #1a1a1a;
}

.chat-box::-webkit-scrollbar {
  width: 10px;
}

.chat-box::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-left: 1px solid #2b2b2b;
}

.chat-box::-webkit-scrollbar-thumb {
  background: #4a5161;
  border-radius: 10px;
  border: 2px solid #1a1a1a;
}

.chat-box::-webkit-scrollbar-thumb:hover {
  background: #5d6577;
}

.msg {
  margin-bottom: 12px;
  line-height: 1.45;
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  word-break: break-word;
}

.msg.user {
  text-align: right;
  color: #e1e8f5;
  background: #243349;
  border-color: #375271;
  width: fit-content;
  max-width: 82%;
  margin-left: auto;
}

.msg.assistant {
  text-align: left;
  color: #c3ccd9;
  background: #1d232f;
  border-color: #313b4d;
  margin-right: auto;
}

.empty-state {
  color: #9aa0a6;
  text-align: center;
  padding: 24px 8px;
  border: 1px dashed #333;
  border-radius: 8px;
}

.typing-indicator {
  font-style: italic;
  margin-bottom: 10px;
  color: #888;
}

.hidden {
  display: none;
}

.input-container {
  display: flex;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  overflow: hidden;
}

textarea {
  flex: 1;
  min-width: 0;
  height: 60px;
  padding: 12px;
  font-size: 18px;
  background: #121212;
  color: #f5f5f5;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a5161 #1a1a1a;
}

textarea::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-left: 1px solid #2b2b2b;
}

textarea::-webkit-scrollbar-thumb {
  background: #4a5161;
  border-radius: 10px;
  border: 2px solid #1a1a1a;
}

textarea::-webkit-scrollbar-thumb:hover {
  background: #5d6577;
}

textarea::placeholder {
  color: #888;
}

.input-container button {
  background: #0077cc;
  color: white;
  padding: 0 24px;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: 0.2s;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.input-container button:hover {
  background: #005fa3;
}

.input-container button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Markdown стили */

.msg pre {
  background: #1a1a1a;
  border: 1px solid #333;
  padding: 12px;
  overflow-x: auto;
  border-radius: 6px;
  font-size: 15px;
  color: #e0e0e0;
  margin-bottom: 10px;
  font-family: monospace;
}

.msg code {
  background: #222;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Markdown списки, заголовки, ссылки и пр. */
.msg h1,
.msg h2,
.msg h3,
.msg h4 {
  margin-top: 16px;
  color: #8be9fd;
}

.msg ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.msg a {
  color: #00bfff;
  text-decoration: underline;
}

.char-counter {
  font-size: 14px;
  color: #888;
  margin-top: 4px;
  text-align: right;
  padding-right: 10px;
}

.char-counter.warning {
  color: #ffcc00;
}

.char-counter.danger {
  color: #ff5555;
}

.usage-stats {
  margin-top: auto;
  font-size: 13px;
  color: #ccc;
  background: #181818;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #333;
}

.chat-list-item {
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.chat-list-item:hover {
  background-color: #1d2230;
  border-color: #343d53;
}

.chat-list-item.active {
  background-color: #22293a;
  border-color: #4f8cff;
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.35);
}

.chat-list-item > button:first-child {
  background: #242a36;
  color: #d4dae8;
  border: 1px solid #363f56;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.25;
  margin-right: 6px;
}

.chat-list-item > button:first-child:hover {
  background: #2b3446;
  color: #eef2ff;
}

.chat-list-item > div {
  display: flex;
  gap: 5px;
}

.chat-list-item > div > button {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #202735;
  color: #c9d1e0;
  border: 1px solid #353f56;
  border-radius: 7px;
}

.chat-list-item > div > button:hover {
  background: #2a3346;
  color: #eef2ff;
}

@media (max-width: 768px) {
  body {
    font-size: 16px;
    overflow: hidden;
    height: 100svh;
    min-height: 100svh;
  }

  .layout {
    display: block;
    height: 100svh;
    min-height: 100svh;
  }

  .sidebar {
    display: none;
  }

  .chat-container {
    height: 100svh;
    min-height: 100svh;
    padding: 0;
    display: flex;
    flex-direction: column;
    border: none;
  }

  header,
  .typing-indicator {
    display: none;
  }

  .chat-box {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .input-container {
    position: static;
    margin-top: auto;
    z-index: 5;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  textarea {
    height: 54px;
    font-size: 16px;
    padding: 10px;
  }

  .input-container button {
    padding: 0 16px;
    font-size: 15px;
    touch-action: manipulation;
  }

  .usage-stats,
  .char-counter {
    display: none;
  }
}
