/* Body and the two main containers*/
#polaris_ai_body {
  padding: 15px;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 5px;

  .polaris_ai_container {
    border: 1px solid var(--polaris_blue);
    border-radius: 4px;
    margin:0;
    padding:0;

    .container_header {
      text-align: center;
      color:white;
      background-color: var(--polaris_blue);
      height: 40px;
      padding: 10px;
    }
  }
  .polaris_ai_container[name='chat_history'] {
    width: 20%;
  }
  .polaris_ai_container[name='chat_session'] {
    width: 80%;
  }
  /* MIG-271 File Manager page*/
  .polaris_ai_container[name='assistants'] {
    flex: 0 0 20%;
  }
  .polaris_ai_container[name='files'] {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* Chat history container / File manager container (left side)*/
#chat_select, #assistant_select {
  height: calc(100% - 40px - 28px); /* container height minus header height, minus OpenAI badge height*/
  padding: 5px;
  overflow-y: auto;

  /* Create New Chat button*/
  #create_new_chat {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    font-weight: bold;
  }
  /* Chat history / assistants selection list*/
  #chat_history, #assistants_list {
    width: 100%;
    list-style-type: none;
    margin: 0;
    padding: 0;

    li {
      width: 100%;
      margin-top: 5px;
      padding: 4px;
      border: 1px solid lightgrey;
      border-radius: 4px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      cursor: pointer;
      gap: 3px;

      span {
        white-space: nowrap;
      }
      span:first-child, .chat_title {
        text-overflow: ellipsis;
        overflow: hidden;
      }
      .chat_timestamp {
        color: gray;
      }
      .rename_chat {
        color: var(--polaris_blue);
      }
      .delete_chat {
        color: #d50000;
      }
      i:hover {
        filter: brightness(0.5);
      }
      img {
        height: 1em;
      }
    }
    li:hover, li.selected {
      background-color: #c0dcf4;
      border-color: #c0dcf4;
    }
  }
}

/* Chat session container (right side)*/
.chat_session {
  height: 100%;
  padding:8px 0 8px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap:10px;

  /* Message history*/
  .messages {
    height: calc(100% - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: start;
    gap: 10px;

    .message_icon {
      width: 40px;
      height: 40px;
      padding: 8px;
      border: 1px solid black;
      border-radius: 40px;
      text-align: center;
      font-size: 16px;
      font-weight: bold;
      flex: 0 0 auto;
    }
    .message_body {
      flex-grow: 1;
      padding-right: 10px;
      .message_header {
        width:100%;
        display: flex;
        justify-content: space-between;
        .message_author {
          font-weight: bold;
        }
        .message_timestamp {
          color: gray;
        }
      }
      /* Assistant replies come in HTML format, so we need some CSS overrides to prevent the site's styling from messing with it*/
      .message_content {
        width: 100%;
        a {
          text-decoration: underline;
          color: blue;
        }
        a:visited {
          color: purple;
        }
        h4 {
          text-align: initial;
        }
      }
    }

    /* all messages*/
    .chat_message {
      display: flex;
      flex-direction: row;
      gap: 10px;
      border-radius: 5px;
      padding: 8px;
      margin-right: 8px;
    }
    /* user submitted messages*/
    .user_message {
      background-color: #eeeeee;
      .message_icon {
        background-color: white;
        color: black;
      }
    }
    /* AI generated messages*/
    .assistant_message {
      background-color: #c0dcf4;
      .message_icon {
        background-color: var(--polaris_blue);
        padding: 6px; /* MIG-273 - Slightly less padding to make the icon a little bigger*/
        img {
          filter: brightness(0) invert(1);
        }
      }
    }
    /* System messages, usually errors (should be rare)*/
    .system_message {
      background-color: #ffcbd3;
      .message_icon {
        background-color: tomato;
        color: black;
      }
    }
    /* Warning messages, usually usage limit warnings (MIG-277)*/
    .notice_message {
      background-color: #fff7b3;
      .message_icon {
        background-color: gold;
        color: black;
      }
    }

    /* file attachments*/
    .message_file_attachment {
      display: block;
      border: 1px solid lightgray;
      border-radius: 4px;
      padding: 6px;
      margin: 3px 0 3px 0;
      text-align: center;
      width: fit-content;
      background-color: white;
    }
  }

  /* User inputs (bottom)*/
  .inputs {
    height: 40px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 5px;
    margin-right: 8px;
    position: relative;

    /* textbox*/
    .chat_text_input {
      flex: 1 1 auto;
      height: 100%;
      padding: 6px;
      border-radius: 4px;
      border: 1px solid lightgray;
    }
    /* buttons*/
    button {
      width: 60px;
    }
    button:disabled {
      color:gray;
    }
    /* hidden file upload input form*/
    .chat_file_input {
      display: none;
    }
    /* file upload indicator*/
    .chat_file_indicator {
      border: 1px solid lightgray;
      border-radius: 4px;
      padding: 4px;
      max-width: 200px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 5px;
      /* filename span*/
      span {
        display: inline-block;
        text-align: center;
        min-width: 60px;
        max-width: 160px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        line-height: 30px; /* vertically centered in a 40px height element*/
      }
      /* remove button*/
      i.fa-times {
        cursor: pointer;
        color: red;
      }
    }
    /* assistant selector window*/
    .chat_assistant_select_input {
      position: absolute;
      background-color: gainsboro;
      border: 1px solid darkgray;
      border-radius: 4px;
      padding: 6px;
      bottom: 45px; /* right above the input bar (which has 40px fixed height)*/
      h4 {
        margin-bottom: 5px;
      }
      .chat_assistant_option {
        width: 100%;
      }
    }
    /* POL-12540 Notification popup that appears (then fades out) when you try to send messages too quickly*/
    .message_in_progress_popup {
      opacity: 0;
      position: absolute;
      bottom: 55px;
      right: 0;
      width: 200px;
      height: 52px;
      background: #ffdb99;
      padding: 6px;
      border: 1px solid darkgray;
      border-radius: 5px;
      z-index: 100;
    }
    .message_in_progress_popup:after {
      content: "";
      position: absolute;
      top: calc(100% - 8px);
      right: 18px;
      width: 16px;
      transform: rotate(45deg);
      border-bottom: inherit;
      border-right: inherit;
      box-shadow: inherit;
      background: #ffdb99;
      height: 16px;
      z-index: -1;
    }
    .fadeOut {
      opacity: 1;
      animation: fadeOut 3s forwards 3s;
    }
    @keyframes fadeOut {
      from {opacity :1;}
      to {opacity :0;}
    }
  }

}


/* Message that appears if you have no existing chats*/
#no_chat_history_message {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 15%;
  img {
    padding: 8px;
    filter: invert(27%) sepia(78%) saturate(573%) hue-rotate(167deg) brightness(40%) contrast(83%);
  }
}


/* MIG-271 File Management Tables*/
.assistant_file_list {
  width: 100%;
  height: 100%;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 5px;

  .file_limit_header {
    margin: 0;
    padding: 8px;
    border: 1px solid gainsboro;
    background-color: gainsboro;
    border-radius: 5px;
    text-align: center;
  }
  .info_header {
    background-color: #c0dcf4;
    padding: 6px;
    border-radius: 5px;
  }
  .dataTables_scroll {
    overflow-x: hidden!important; /* this is the only way to prevent the useless horizontal scrollbar from appearing, for some reason*/
    .dataTables_scrollHeadInner {
      background: silver;
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
    }
  }
  table.dataTable {
    table-layout: fixed;
    margin: 0;
    tbody {
      td {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
      .actions {
        display: flex;
        flex-direction: row;
        justify-content: space-evenly;
        text-align: center;
      }
    }

  }
}


/* MIG-268 - Disclaimer modal*/
#disclaimer {
  button {
    border: none;
    border-radius: 5px;
    padding: 8px;
    margin-right: 12px;
    width: 150px;
  }
  #disclaimer_disagree {
    background-color: gainsboro;
    color: gray;
  }
  #disclaimer_disagree:hover {
    background-color: lightgrey;
  }
  #disclaimer_agree {
    background-color: #609028;
    color:white;
  }
  #disclaimer_agree:hover {
    background-color: #4D711B;
  }
}
/* MIG-268 AI Model Attribution Badge*/
.attribution {
  padding: 0;
  height: 28px;
  width: 100%;
}

/* MIG-274 Report Centre "Summarize report" button*/
/* and POL-12901 Explain Choices button*/
.summarize_report_button, #polaris_ai_explain_choices_button {
  height: 40px;
  color: white;
  background-color: #609028;
  border-radius: 4px;
  border: 1px solid grey;
}
.summarize_report_button:hover, #polaris_ai_explain_choices_button:hover {
  background-color: #4D711B;
}

/* POL-12901 Recommend Variables button*/
#polaris_ai_recommend_variables_container {
  display: flex;
  gap: 8px;
  button {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    align-items: center;
    height: 30px;
    padding: 0 8px;
  }
  #polaris_ai_recommend_variables_button {
    border-radius: 5px;
    border: 1px solid darkgray;
    img {
      color: #f37321;
      height: 25px;
      width: 25px;
    }
  }
  #polaris_ai_recommend_variables_button:hover {
    img {
      filter: drop-shadow(0 0 2px);
    }
  }
}

/* Chat window preview modals*/
#chat_window_preview {
  .modal-header {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .chat_session {
    .chat_message {
      margin-right: 0; /* no scrollbar margin*/
    }
  }

  .redirect_to_polaris_ai {
    text-decoration: underline;
    color: blue;
  }
}