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

html,
body {
  height: 100dvh;
  font-family: sans-serif;
  font-size: 16px;
  overflow-x: hidden;
}

/* ========== TYPOGRAFIA ========== */
textarea,
input,
button {
  font-size: 1rem;
  -webkit-text-size-adjust: 100%;
}

/* ========== KOLORY ========== */
:root {
  --bg-main: #343541;
  --bg-sidebar: #202123;
  --msg-user: #444654;
  --msg-assistant: #3a3b41;
  --msg-text: #ffffff;
}

/* ========== LAYOUT ZEWNĘTRZNY ========== */
body {
  display: flex;
  flex-direction: row;
  height: 100%;
  background: var(--bg-main);
  color: var(--msg-text);
}

/* ========== COMPONENT: SIDEBAR ========== */
.sidebar {
  flex: 0 0 250px;
  background: var(--bg-sidebar);
  color: #eeeeee;
  padding: 1rem;
}

.sidebar.hidden {
  display: none;
}

.sidebar #toggleBtn {
  background: none;
  color: #eee;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  margin-bottom: 1rem;
}

/* ========== COMPONENT: MAIN ========== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ========== SIDEBAR TOGGLE BUTTONS ========== */
#openSidebarBtn,
#closeSidebarBtn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #ffffff;
  cursor: pointer;
}

#openSidebarBtn {
  margin: 0.5rem 1rem;
  align-self: flex-start;
}

#closeSidebarBtn {
  margin-bottom: 1rem;
}

/* ========== LISTA WIADOMOŚCI ========== */
.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
  min-height: 0;
}

.message {
  width: 100%;
  line-height: 1.5;
  padding-bottom: 2.5rem;
  position: relative;
}

.msg-text {
  background: var(--msg-user);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--msg-text);
}

.message.assistant .msg-text {
  background: var(--msg-assistant);
}

/* Przyciski wiadomości */
.msg-actions {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.message:hover .msg-actions,
.msg-actions:hover {
  opacity: 1;
  pointer-events: auto;
}

.msg-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #ccc;
}

.msg-btn:hover {
  color: #fff;
}

/* ========== TRYB EDYCJI ========== */
.edit-textarea {
  background: var(--msg-user);
  border: 1px solid #555;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--msg-text);
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 0.5rem;
}

.message.assistant .edit-textarea {
  background: var(--msg-assistant);
}

.edit-controls {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 0 1rem;
}

.edit-btn {
  background: none;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 0.3rem 1rem;
  color: #ddd;
  cursor: pointer;
}

.edit-btn:hover {
  background: #2a2b2e;
}

/* ========== INPUT-CONTAINER ========== */
.input-container {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid #555555;
  background: var(--bg-main);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.input-container textarea {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #777777;
  border-radius: 6px;
  background: #2b2b2e;
  color: #ffffff;
  resize: none;
  min-height: 2.5rem;
  max-height: 10rem;
  overflow-y: auto;
  line-height: 1.4;
}

.input-container button {
  padding: 0 1rem;
  background: #10a37f;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* ========== MOBILE: NAKŁADANIE SIDEBARU ========== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 80vw;
    height: 100dvh;
    z-index: 100;
  }

  .main {
    width: 100%;
  }
}

/* ========== THREAD BUTTONS (WĄTKI) ========== */
.thread-btn {
  display: block;
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  text-align: left;
  background: none;
  border: 1px solid #444;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
}

.thread-btn:hover {
  background: #2a2b2e;
}
