/*
 * General components
 */

[role=button].primary-black {
  --background-color: black;
}

[role=button].primary-black:is([aria-current], :hover, :active, :focus) {
  --background-color: #0003;
}

.selectable:hover {
  background-color: var(--color-hover);
  cursor: pointer;
}

.selected {
  background-color: var(--border-color);
}

.page-content {
  min-height: calc(100vh - 5.5rem);
  border-radius: 0.5rem;
}

.page-content:has(.chat-history.not-empty) {
  background: var(--background-2);
}

.page:has(.chat-history.not-empty) .page-background * {
  display: none;
}

.page:has(.chat-history.not-empty) .page-header {
  background: var(--background-1);
}

/*
 * Home
 */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 0;
}

/*
 * Control pane
 */

.control-pane {
  display: flex;
  flex-direction: column;
  position: absolute;
  width: 100%;
  top: 50%;
  left: 0;
  margin: 0;
  transform: translate(0, -50%);
}

@media screen and (max-width:1100px) {
  .control-pane {
    margin-bottom: 0;
  }
}

.home:has(.chat-history.not-empty) .control-pane {
  position: sticky;
  top: unset;
  transform: unset;
  bottom: 1rem;
}

.page.embedded .home .control-pane {
  width: calc(100% - 1rem);
  margin: 0 0.5rem;
  bottom: 0;
}

.page.embedded .home:has(.chat-history.not-empty) .control-pane {
  width: 100%;
  margin: 0;
}

.control-pane .banner {
  font-size: 2rem;
  font-weight: 500;
  padding: 2rem;
  text-align: center;
}

.home:has(.chat-history.not-empty) .control-pane .banner {
  display: none;
}

.control-pane .controls {
  display: flex;
  flex-direction: column;
  background: rgb(from var(--background-6) r g b / 0.95);
  padding: 0;
  margin: 0;
  border-radius: 0.5rem;
}

.control-pane .controls-form {
  display: flex;
  flex-direction: column;
  font-size: 1rem;
  margin: 0.9rem 0.9rem 0 0.9rem;
  padding: 0;
}

.control-pane .question {
  color: var(--color-1);
  font-size: 0.8rem;
  /*height: 4rem;*/
  border: none;
  resize: none;
  padding: 0;
  margin: 0;
}

.control-pane .question:focus {
  --box-shadow: none;
  outline: none;
}

.control-pane .controls-bar {
  display: flex;
  flex-wrap: wrap;
  padding: 0.2rem 0.5rem 0.5rem 0.5rem;
  margin: 0;
}

.control-pane #select-agent {
  height: 1.5rem;
  margin: 0.25rem 0.125rem;
  padding: 0.25rem 0.5rem;
  color: var(--color-1);
  background: var(--background-2);
  cursor: pointer;
  border-radius: 0.25rem;
}

.control-pane #select-agent:hover {
  background: var(--color-hover);
}

.control-pane .select-chat {
  width: 8rem;
  margin: 0.25rem 0.125rem;
  height: 1.5rem;
  background-color: var(--background-2);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-pane:has(input#current-agent[value^="_/_/general"]) #select-project {
  display: none;
}

.control-pane .icon-button {
  margin: 0.25rem;
  user-select: none;
  font-size: 0.8rem;
  padding: 0.2rem 0.35rem;
}

.control-pane .icon-button.send {
  background: var(--primary);
  color: var(--color-1);
  font-size: 1rem;
  margin-left: auto;
}

.control-pane .icon-button[aria-busy=true] {
  font-size:0.8rem;
}

.control-pane .icon-button.send:hover {
  background: var(--primary) !important;
  color: var(--color) !important;
}

#home.auto-read-answer .control-pane .toggle-auto-read-answer svg[data-icon=speaker-muted],
#home:not(.auto-read-answer) .control-pane .toggle-auto-read-answer svg[data-icon=speaker] {
  display: none;
}

.control-pane .microphone {
  position: relative;
  width: fit-content;
  padding: 0;
}

.control-pane .microphone * {
  user-select: none;
}

.control-pane .microphone .message {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%,-100%);
  width: 10rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background: #633;
}

.control-pane .microphone .message:not(.shown) {
  display: none;
}

/*
 * History pane
 */

.history-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 1rem;
}

/* Chat history */

.chat-history {
  flex: 1;
  border-radius: 0.25rem;
  margin: 0;
  padding: 0.5rem 0;
}

.chat-history .icon-button {
  font-size: 0.8rem;
  border-radius: 50%;
  background: var(--background-3);
}

.chat-history .chat-message {
  padding: 0 0 2rem 0;
  max-width:100%;
  width: 100%;
  display: flex;
  font-size: var(--font-size);
}

.chat-history .chat-message.dummy {
  display: none;
}

.chat-history .chat-message-icon {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0 0 auto 0;
  padding: 0;
  border-radius: 50%;
  background: var(--background-3);
}

.chat-history .chat-message.left .chat-message-icon {
  color: var(--primary);
}

.chat-history .chat-message.right .chat-message-icon {
  color: var(--color-2);
  font-size: 0.8rem;
}

.chat-history .chat-message-controls {
  display: flex;
  flex-wrap: wrap;
}

.chat-history .chat-play {
  border-radius: 50%;
}

.chat-history .chat-play .loader-1::after {
  background: var(--background-3);
}

.chat-history .chat-play:hover .loader-1::after {
  background: var(--color-3);
}

.chat-history .chat-play.playing svg[data-icon=play],
.chat-history .chat-play:not(.playing) svg[data-icon=pause],
.chat-history .chat-play:not(.playing) .loader-1 {
  display: none;
}

.chat-history .chat-play[aria-busy=true] {
  padding: 0.2rem 0.35rem;
}

.chat-history .chat-play[aria-busy=true] svg {
  display: none;
}

.chat-history .chat-message-body {
  font-size: 0.8rem;
  padding: 0 0.5rem;
}

.chat-history .chat-message-body .context-source {
  font-size: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-2);
}

#home:not(.show-message-time) .chat-history .chat-message-body {
  padding-top: 0.2rem;
}

.chat-history .chat-message-body pre {
  font-family: Roboto, sans-serif;
  margin: 0;
  color: var(--color);
  font-style: normal;
  font-weight: var(--font-weight);
  font-size: 0.8rem;
  line-height: unset;
  background: unset;
  white-space: pre-wrap;    /* Allows wrapping */
  overflow-wrap: break-word;  /* Break long words */
}

.chat-history .markdown-content p {
  color: var(--color-1);
}

.chat-history .chat-message-time {
  padding-left: 0.5rem;
  font-size: 0.5em;
  color: var(--color-2);
}

#home:not(.show-message-time) .chat-history .chat-message-time {
  display: none;
}

.chat-history .chat-message.right {
  margin: 0 0 0 auto;
}

.chat-history .chat-message.right .chat-message-body {
  margin: 0 0 0 auto;
}

.chat-history .chat-message.left {
  margin: 0 auto 0 0;

}

.chat-history .chat-message.left .chat-message-body {
  margin: 0 auto 0 0;
}

.chat-history .chat-message.left .chat-message-time {
  text-align: left;
}

.chat-history .chat-message.center {
  margin: 0 auto;
}

.chat-history .chat-message.center .chat-message-body {
  background: #2a2f33;
  margin: 0 auto;
}

.chat-history .chat-message.center .chat-message-time {
  text-align: center;
}

/* Attachments */

.chat-history .attachments {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.7rem;
  margin-top: 0.5rem;
}

.chat-history .attachment-item {
  display: inline-block;
  background: var(--background-3);
  border-radius: 0.24rem;
  padding: 0;
  margin: 0.1rem 0.25rem;
}

.chat-history .attachment-item .link {
  padding: 0 0.5rem;
  color: var(--color-2);
}

.chat-history .attachment-item .icon-button {
  width: 1.25rem;
  height: 1.25rem;
  background: var(--background-3);
  font-size: 0.8rem;
  padding: 0;
  margin: 0;
}

/* Checklist progress */

.chat-history .agent-checklist {
  font-size: 0.5rem;
}

.chat-history .agent-checklist:has(.progress-bar.complete) {
  display: none;
}

.chat-history .agent-checklist > * {
  margin-top: 0.25rem;
}

.chat-history .agent-checklist .overall {
  display: flex;
  flex-wrap: wrap;
}

.chat-history .agent-checklist .info {
  margin-left: 1rem;
}

.chat-history .agent-checklist .info:first-child {
  margin-left: auto;
}

.chat-history .agent-checklist .overall .info .label {
  padding: 0 0.2rem 0 0;
}

.chat-history .agent-checklist .overall .info .label::after {
  content: ":"
}

.chat-history .agent-checklist .overall .info .value {
  padding: 0;
  color: var(--color-green);
}

.chat-history .agent-checklist .progress-bar {
  position: relative;
  height: 1rem;
  margin: 0.5rem 0;
  background: var(--background-color-2);
  border-radius: var(--border-radius);
}

.chat-history .agent-checklist .progress-bar.complete {
  background: var(--color-green);
  opacity: 40%;
}

.chat-history .agent-checklist .progress-bar .bar {
  position: absolute;
  left: 0;
  background: var(--color-orange);
  height: 100%;
  min-width: 0.25rem;
  border-radius: inherit;
}

.chat-history .agent-checklist .task {
  display: flex;
  padding: 0.25rem 0.5rem;
  margin-top: 0.25rem;
  background: var(--background-color-6);
}

.chat-history .agent-checklist .task .status {
  margin: 0;
  width: 1rem;
  height: 1rem;
}

.chat-history .agent-checklist .task .title {
  flex: 1;
  margin-left: 0.5rem;
  line-height: 1rem;
}

.chat-history .agent-checklist .task .time {
  color: var(--color);
  opacity: 40%;
}



/*
 * Dialogs
 */


dialog article footer {
  position: sticky;
  bottom: calc(-1 * var(--block-spacing-vertical));
}

dialog article select,
dialog article input:not([type=checkbox],[type=radio]),
dialog article textarea {
  margin-bottom: 0.25rem;
  margin-right: 0.25rem;
}



.file-list {
  padding: 0.5rem;
  margin-bottom: 0;
}

.file-list .file {
  display: flex;
  justify-content: space-between;
}

.file-list .remove {
  color: var(--asv-color-red);
  cursor: pointer;
  padding: 0 0.25rem;
  margin-left: 0.5rem;
  border-radius: 0.2rem;
  line-height: 1rem;
  font-weight: 700;
}

.file-list .remove:hover {
  background: var(--asv-color-red);
  color: white;
}

#attachments-dialog label[role=button] {
  margin: 0.25rem;
}


/**** Loading response ***/

.reveal-animation {
  animation-duration: 0.8s;
  animation-name: reveal-animation-fade;
  animation-delay: 0.1s;
  animation-fill-mode: backwards;
}

@keyframes reveal-animation-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
