* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body > section#chat-container {
  display: flex;
  width: 100%;
  height: calc(100vh - 70px);
}

body > section#chat-container > section#conversations-sidebar {
  width: 300px;
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  div#sidebar-header {
    padding: 20px 30px;
    font-weight: 500;
    font-size: 22px;
  }
  section#conversations-list {
    flex: 1;
    overflow-y: auto;

    section.conversation-item {
      border-radius: 30px;
      margin: 10px 10px;
      padding: 15px 15px;
      cursor: pointer;
      transition: background-color 0.3s;
      display: flex;
      flex-direction: row;
      /* justify-content: center; */
      align-items: center;
      &:hover {
        background-color: #f0f0f0;
      }

      div.conversation-item-left {
        flex-grow: 0;
        flex-basis: 50px;
        /* border: 1px solid #cf3333; */

        div.avatar {
          img {
            width: 50px;
            height: 50px;
            object-fit: cover;
            border-radius: 50%;
            background-color: #ececec;
            padding: 4px;
          }
        }
      }
      div.conversation-item-middle {
        flex-grow: 1;
        flex-basis: 150px;
        /* border: 1px solid #cf3333; */

        margin: 0px 10px;
        display: flex;
        flex-direction: column;

        div.conversation-info {
          display: flex;
          flex-direction: row;
          align-items: center;
          div.conversation-title {
            font-size: 16px;
          }
          div.role-subtitle {
            margin-left: 10px;
            font-size: 12px;
            color: lightgray;
          }
        }
        div.conversation-meta {
          margin-top: 5px;
          display: flex;
          flex-direction: row;
          align-items: center;
          justify-content: space-between;

          font-size: 13px;
          color: #909090;

          div.last-message {
            overflow-y: hidden;
          }
          div.timestamp {
            font-size: 12px;
            margin-left: 5px;
          }
        }
      }
      div.conversation-item-right {
        flex-grow: 0;
        flex-basis: 20px;
        /* border: 1px solid #cf3333; */
        div.unread-badge {
          width: 20px;
          height: 20px;
          border-radius: 50%;
          background-color: rgb(195, 183, 183);
          font-size: 12px;
          color: white;
          text-align: center;
          line-height: 20px;
        }
      }
    }
  }
}

body > section#chat-container > section#chat-main {
  height: calc(100vh - 70px);
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  section#chat-header {
    flex-basis: 75px;
    flex-grow: 0;
    /* height: 75px; */
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    div#chat-header-left {
      display: flex;
      flex-direction: row;
      align-items: center;
      img {
        padding: 4px;
        width: 45px;
        height: 45px;
        object-fit: cover;
        border-radius: 50%;
        background-color: #ececec;
      }
      div#header-other-username {
        margin-left: 10px;
        font-size: 20px;
        font-weight: 500;
      }
    }
  }

  section#messages-default {
    position: absolute;
    height: calc(100vh - 70px);
    width: calc(100vw - 300px);
    background-color: #f1f1f1;
    display: flex;
    /* display: none; */
    justify-content: center;
    align-items: center;
    z-index: 2;
    div {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      i {
        margin-bottom: 20px;
        align-self: center;
        font-size: 70px;
      }
      p {
        font-size: 24px;
      }
    }
  }

  section#messages-container {
    flex-basis: 700px;
    flex-grow: 1;

    overflow-y: auto;
    background: #fafafa;

    display: flex;
    flex-direction: column;

    div#messages-content {
      flex: 1 1 auto;
      padding: 10px 20px;

      display: flex;
      flex-direction: column;

      section.message {
        display: flex;
        margin: 10px 0;

        div.message-content {
          display: flex;
          flex-direction: column;
          align-items: flex-end;
          max-width: 70%;
          div.message-text {
            padding: 10px 15px;
            border-radius: 15px;
            background-color: #e0e0e0;
          }
          div.message-time {
            color: #5b5b5b;
            font-size: 12px;
            margin-bottom: 4px;
          }
        }
      }
      .message.other-message {
        justify-content: flex-start;
        div.message-content {
          align-items: flex-start;
          div.message-text {
            border-bottom-left-radius: 0px;
          }
          div.message-time {
            margin-left: 10px;
          }
        }
      }
      .message.my-message {
        justify-content: flex-end;
        div.message-content {
          align-items: flex-end;
          div.message-text {
            background-color: #4d4d4d;
            color: white;
            border-bottom-right-radius: 0px;
          }
          div.message-time {
            margin-right: 10px;
          }
        }
      }
    }
    div#typing-indicator-wrap {
      flex: 0 0 auto;
      padding: 0px 20px;
      /* display: flex; */
      display: none;
      margin-bottom: 10px;
      div#typing-indicator {
        padding: 10px 15px;
        justify-content: flex-start;
        height: 40px;
        display: flex;
        flex-direction: row;
        align-items: center;

        border-radius: 15px;
        border-bottom-left-radius: 0px;

        background-color: #e0e0e0;
        div.dot {
          flex-grow: 0;
          margin-right: 3px;
          height: 7px;
          width: 7px;

          border-radius: 50%;
          background-color: #919191;
          animation: dot-flashing 2.4s infinite linear;
        }
        div.dot:nth-child(2) {
          animation-delay: 0.5s;
        }

        div.dot:nth-child(3) {
          animation-delay: 1s;
        }
      }
    }
  }

  section#message-input-container {
    flex-basis: 150px;
    flex-grow: 0;
    padding: 20px 20px;
    background: #fafafa;
    #message-input-form {
      display: flex;
      flex-direction: row;
      position: relative;
      textarea#message-input {
        flex: 1;
        padding: 20px;
        border: 1px solid #ddd;
        border-radius: 20px;
        outline: none;
        font-size: 14px;
        resize: none;
        height: 120px;

        &:focus {
          border-color: #000000;
        }
      }

      #send-button {
        padding: 10px 20px;
        background: #000000;
        color: white;
        border: none;
        border-radius: 20px;
        cursor: pointer;
        font-size: 14px;
        transition: background-color 0.2s;
        position: absolute;
        bottom: 20px;
        right: 20px;
        &:hover {
          background-color: #4d4d4d;
        }
        &:disabled {
          background: #ccc;
          cursor: not-allowed;
        }
      }
    }
  }
}

@keyframes dot-flashing {
  0% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}
