.tool-accordion-content {
  overflow: auto;
  max-height: 250px;
  background: #f4f4f8;
}

.tool-accordion-content p {
  white-space: pre-wrap;
}

/* Global */
body {
  font-family: var(--font-family-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  background-color: white;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.icon-btn img {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

#app-container {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  /* Prevent scrollbars during sidebar transition */
}

/* Sidebar */
#sidebar {
  width: 256px;
  flex-shrink: 0;
  background-color: #E3EAEC;
  border-right: 1px solid #E3EAEC;
  display: flex;
  flex-direction: column;
  padding: 10px;
  box-sizing: border-box;
  transition: width 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
}

#sidebar.collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  border-right-color: transparent;
}

#app-container.sidebar-collapsed #sidebar-toggle-btn img {
  transform: rotate(180deg);
}

#sidebar-header {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ccc;
  align-items: center;
}

#search-conversations {
  flex-grow: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

#conversations-list {
  flex-grow: 1;
  overflow-y: auto;
}

.conversation-group-header {
  font-size: var(--font-size-sm);
  color: #6c757d;
  text-transform: uppercase;
  margin: 10px 4px 5px;
  padding: 0 5px;
}

#load-more-conversations {
  padding: 10px;
  border: 1px solid #ccc;
  background-color: #e9ecef;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
}

/* Expanded main panel to complement collapsed sidebar */
#main-panel.expanded {
  /* flex-grow handles expansion, this class is for JS hook */
}

/* When the sidebar is collapsed, the main panel should take up the full width. */
#app-container.sidebar-collapsed #main-panel {
  width: 100%;
}

/* Main panel */
#main-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition: width 0.3s ease;
}

#chat-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
}

#chat-messages {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

#chat-messages li {
  margin-bottom: 10px;
  padding: 0px 15px;
  border-radius: 18px;
  word-wrap: break-word;
}

.user-message {
  background-color: #F4F6F8;
  color: black;
  align-self: flex-end;
  max-width: 50%;
  padding-bottom: 1em !important;
}

.agent-message {
  color: #000;
  align-self: flex-start;
  line-height: 1.4;
  margin-left: 2rem;
  position: relative;
}

.agent-icon {
  display: block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  position: absolute;
  top: 1rem;
  /* Visually anchor icon to the top of the message */
  left: -1em;
  background-image: url(assets/images/icons/chaticon.svg);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.agent-message strong {
  color: #0056b3;
}

/* Message chunk separators inside agent messages */
.agent-message>.message-chunk+.message-chunk {
  border-top: 1px solid #ddd;
  margin-top: 8px;
  padding-top: 8px;
}

/* Form area */
#form-container {
  background: #fff;
  border-top: 1px solid #ccc;
  padding: 15px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

#prompt-form {
  display: flex;
}

#prompt-input {
  flex-grow: 1;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
  font-size: 16px;
}

#prompt-input:focus {
  border-color: #007bff;
}

#send-button,
.icon-action {
  margin-left: 10px;
  border: none;
  background-color: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 4px;
  transition: background-color 0.2s;
}

#send-button:hover,
.icon-action:hover {
  background-color: #f4f6f8;
}

#send-button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

#send-button img,
.icon-action img {
  width: 20px;
  height: 20px;
}

/* Auth styles */
#auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.auth-form {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.auth-form h2 {
  text-align: center;
  margin-bottom: 24px;
  color: #333;
}

.auth-form input {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

.auth-form button {
  width: 100%;
  margin-left: 0;
  padding: 10px 20px;
  border: none;
  background-color: #007bff;
  color: white;
  border-radius: 20px;
  cursor: pointer;
  font-size: 16px;
}

.auth-form button:hover {
  background-color: #0056b3;
}

.auth-form p {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
}

.auth-form a {
  color: #007bff;
  text-decoration: none;
  cursor: pointer;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Top bar */
#top-bar {
  background: #fff;
  padding: 10px 20px;
  border-bottom: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#logout-btn {
  padding: 8px 16px;
  font-size: 14px;
}

/* Status and selectors */
#status {
  padding: 0 15px 10px;
  color: #555;
}

#selectors-container {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

#agent-select {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

/* Tool accordion */
.tool-accordion {
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.tool-accordion-header {
  cursor: pointer;
  padding: 6px 0px;
  padding-left: 2rem;
  position: relative;
}

.tool-accordion-header::before {
  content: "";
  display: block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: absolute;
  top: 0.5rem;
  left: 0.25rem;
  background-image: url(assets/images/icons/tool.svg);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.tool-accordion-content {
  padding: 6px 8px;
  display: none;
}

.tool-accordion.open .tool-accordion-content {
  display: block;
}

.tool-accordion-output {
  border-top: 1px solid #eee;
}

.conversation-group-list {
  padding-inline-start: 0;
}

@keyframes spin360 {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Loading animation */
@keyframes pulseOpacity {
  0% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulseOpacity 1.2s linear infinite;
}

/* Agent thinking animation */
.agent-message[id^="agent-thinking-"] {
  /* This applies to the placeholder "Agent is thinking..." message */
  animation: pulseOpacity 1.2s ease-in-out infinite;
}

.agent-message[id^="agent-thinking-"] .agent-icon {
  animation: spin360 1s ease-in-out infinite;
}

/* Tool loading animation */
.tool-accordion[data-has-output="false"] .tool-accordion-header {
  animation: pulseOpacity 1.2s ease-in-out infinite;
}

/*
  .tool-accordion[data-has-output="false"] .tool-accordion-header::before {
    animation: spin360 1s ease-in-out infinite;
  }
*/

/* Conversation list items */
.conversation-item {
  cursor: pointer;
  padding: 8px 5px;
  list-style: none;
  width: calc(100% - 8px);
  margin: 4px;
  font-size: var(--font-size-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
}

button.edit-conversation-btn {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
}

.edit-conversation-btn img {
  width: 18px;
}

.edit-conversation-container {
  width: 100%;
  display: flex;
}
.edit-controls button {
    border: none;
    background: transparent;
}

.btn-save-title img {
    width: 18px;
}

.btn-cancel-title img {
    width: 18px;
    height: 18px;
}

input.edit-conversation-input {
  width: 100%;
  border: none;
  background: transparent;
}

.conversations-empty {
  padding: 10px;
  color: #666;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: end;
  align-items: center;
  padding: 0 16px;
}

header #selectors-container {
  margin-bottom: 0;
}

header #agent-select {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
}

header #agent-select option {
  background: white;
  color: black;
}