/* Overall container */
.chat-container {
  display: flex;
  height: 90vh;
  font-family: "Segoe UI", Roboto, sans-serif;
  background: #1e1e2e;
  color: #e5e5e5;
  margin-top: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #252537;
  border-right: 1px solid #333;
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 2001;
}

.sidebar-title {
  font-size: 1.4rem;
  margin-bottom: 12px;
  color: #fff;
}

.sidebar-subtitle {
  margin: 16px 0 8px;
  font-size: 1.1rem;
  color: #a0a0c0;
}

.new-chat-btn {
  padding: 10px;
  margin-bottom: 10px;
  background: #4a4aff;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

.new-chat-btn:hover {
  background: #3a3ad6;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  align-self: flex-end;
  cursor: pointer;
  margin-bottom: 8px;
}

#closeSidebar {
  display: none;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
}

.overlay.show {
  display: block;
}

/* Chat Area */
.chat-area {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.chat-window {
  flex: 1;
  background: #2b2b3d;
  border-radius: 10px;
  padding: 16px;
  overflow-y: auto;
  font-size: 0.95rem;
}

/* Messages */
.msg {
  margin: 8px 0;
  display: flex;
}

.msg.user {
  justify-content: flex-end;
}

.msg.assistant {
  justify-content: flex-start;
}

.msg.system {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  margin: 10px 0;
}

.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.4;
  word-wrap: break-word;
}

.bubble.user {
  background: #4a4aff;
  color: #fff;
  border-bottom-right-radius: 2px;
}

.bubble.assistant {
  background: #3a3a56;
  color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  line-height: 1.6;
}

.bubble.system {
  background: transparent;
  color: #aaa;
  font-style: italic;
  text-align: center;
  max-width: 90%;
}

.bubble.assistant h1,
.bubble.assistant h2,
.bubble.assistant h3 {
  margin: 6px 0;
  font-weight: 600;
}

.bubble.assistant ul {
  margin: 6px 0 6px 20px;
}

.bubble.assistant strong {
  color: #ffd966;
}

.bubble.assistant em {
  color: #b6b6ff;
  font-style: italic;
}



.msg.system .bubble {
  background: none;
  color: #aaa;
  font-style: italic;
}

/* Chat Form */
.chat-form {
  display: flex;
  margin-top: 12px;
}

.chat-input {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px 0 0 8px;
  outline: none;
  background: #33334d;
  color: #fff;
}

.chat-send-btn {
  padding: 12px 20px;
  background: #4a4aff;
  border: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  color: #fff;
  font-weight: bold;
  transition: 0.2s;
}

.chat-send-btn:hover {
  background: #3a3ad6;
}

/* Persona dropdown */
.persona-selector {
  position: relative;
}

.persona-btn {
  background: linear-gradient(135deg, #4a4aff, #3a3ad6);
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: 50px;
  /* fully rounded pill */
  cursor: pointer;
  font-size: 0.99rem;
  font-weight: 450;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.persona-btn:hover {
  background: #4a4a62;
}

.persona-menu {
  position: absolute;
  top: 110%;
  right: 0;
  background: #2b2b3d;
  border: 1px solid #444;
  border-radius: 6px;
  list-style: none;
  padding: 8px 0;
  margin: 0;
  width: 220px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.persona-menu li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #eee;
}

.persona-menu li:hover {
  background: #3f3f57;
}

.avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}

.hidden {
  display: none;
}

#chatHistoryDiv {
  overflow-y: auto;
  flex: 1;
}

/* Top bar */
.top-bar {
  display: flex;
  justify-content: end;
  align-items: center;
  margin-bottom: 5px;
  margin-top: 0px;
}

.hamburger {
  display: none;
  background: #3a3a4f;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  padding: 1px 15px;
  border-radius: 10px;
  cursor: pointer;
}


/* ----------- Mobile Responsive ----------- */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
    height: calc(100vh - 99px);
    /* account for navbar */
    margin-top: -8px !important;
  }

  #closeSidebar {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .hamburger {
    display: inline-block;
  }

  .chat-area {
    flex: 1;
    padding-top: 0;

    max-width: 100%;
    height: calc(100vh - 99px);
    /* leave space for navbar */
    display: flex;
    flex-direction: column;
  }

  .top-bar {
    justify-content: space-between;
    padding: 2px;
  }

  .chat-window {
    flex: 1;
    font-size: 0.9rem;
    padding: 5px;
    overflow-y: auto;
    height: auto;
    /* let flex grow naturally */
  }

  .chat-form {
    flex-shrink: 0;
    margin: 0;
    border-radius: 0;
  }
}

@media (max-width: 480px) {
  .bubble {
    max-width: 85%;
    font-size: 0.85rem;
  }

  .persona-btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .avatar {
    width: 28px;
    height: 28px;
  }


}

/* Chat history list items */
.conversation-list li {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.model-dropdown {
  background: linear-gradient(135deg, #4a4aff, #3a3ad6);
  /* closed select background */
  color: #ffffff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.85rem;
  margin-right: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.model-dropdown option {

  background-color: #2b2b3d;
  /* grey dropdown */
  color: #ffffff;
}


.model-dropdown li:hover {
  background: #2a2a2b;
}

.model-dropdown option:hover,
.model-dropdown option:checked {
  background-color: #505050;
}

.conversation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  cursor: pointer;
}

.conversation-title:hover {
  background: #3a3a56;
  transform: scale(1.1);
}

.conversation-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-trash {
  background: transparent;
  border: none;
  color: #ff6b6b;
  font-size: 15px;
  cursor: pointer;
  padding: 4px;


  /* animation base */
  transition: transform 0.15s ease, color 0.15s ease;
}

.conversation-trash:hover {
  transform: scale(1.7);
  color: #ff2e2e;
}

.modal-buttons {
  padding-bottom: 5px;

}