.main {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: calc(100vh - 56px);
  overflow: hidden;
  background: hsl(var(--background-container));
}

.conversation-name {
  color: hsl(var(--text));
  font-weight: bold !important;
  word-wrap: anywhere;
}

.web {
  color: hsl(var(--input-unread));
  transition: .25s linear;

  &.enable {
    color: hsl(var(--text));
  }
}

.sidebar {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  width: 0;
  height: 100%;
  padding: 0;
  margin: 0;
  background: var(--background-sidebar);
  transition: 0.2s ease-in-out;
  transition-property: width, background, box-shadow;
  border-right: 0;

  &.open {
    width: 260px;
    border-right: 1px solid hsl(var(--border));
  }

  .sidebar-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 4px;
  }

  &.open .conversation-list {
    opacity: 1;
  }

  .sidebar-menu {
    height: max-content;
    width: 100%;

    .sidebar-wrapper {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      height: max-content;
      width: calc(100% - 0.5rem);
      margin: 0.25rem;

      img {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0.2rem;
        border-radius: .5rem;
        transform: translateY(0.05rem);
        flex-shrink: 0;
      }

      .username {
        margin: 0 auto 0 8px;
        color: hsl(var(--text));
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
        font-family: var(--font-family-normal);
      }

      svg {
        color: hsl(var(--text-secondary));
      }
    }
  }

  .conversation-list {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    width: 100%;
    height: 100%;
    padding: 6px 0;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    user-select: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    transition: 0.2s ease-in-out;

    .empty {
      color: hsl(var(--text-secondary));
      font-size: 14px;
      margin: auto;
      user-select: none;
    }

    .conversation {
      display: flex;
      flex-direction: row;
      vertical-align: center;
      align-items: center;
      width: calc(100% - 12px);
      height: max-content;
      cursor: pointer;
      margin: 0 6px;
      padding: 10px 12px;
      border-radius: var(--radius);
      border: 1px solid var(--conversation-card-border);
      transition: 0.2s ease-in-out;
      background: var(--conversation-card);

      .more {
        color: hsl(var(--text-secondary));
        display: none;
        transition: 0.2s;
        opacity: 0;
        border: 1px solid var(--border);
        outline: 0;

        &:hover {
          color: hsl(var(--text));
        }
      }

      &:hover {
        background: var(--conversation-card-hover);

        .id {
          display: none;
        }

        .more {
          display: block;
          opacity: 1;
        }
      }

      &.active {
        background: var(--conversation-card-active);
      }
    }

    svg {
      flex-shrink: 0;
    }

    .title {
      flex-grow: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 16px;
      user-select: none;
      margin: 0 4px;
      color: hsl(var(--text));
    }

    .id {
      flex-shrink: 0;
      color: hsl(var(--text-secondary));
      font-size: 14px;
      user-select: none;

      &:before {
        content: "#";
        font-size: 12px;
        margin-right: 1px;
      }
    }

    &::-webkit-scrollbar {
      width: 6px;
    }
  }

  .sidebar-action {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 0 6px;
    margin-bottom: 2px;

    .refresh-action {
      &.active {
        svg {
          animation: RotateAnimation 0.5s linear infinite;

          @keyframes RotateAnimation {
            from {
              transform: rotate(0deg);
            }
            to {
              transform: rotate(360deg);
            }
          }
        }
      }
    }
  }

  .login-action {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    margin: auto;
    width: max-content;

    svg {
      transform: translateY(1px);
    }
  }

  @media (max-width: 768px) {
    &.open {
      width: max(30vw, 180px);
    }
  }

  @media (max-width: 468px) {
    // sidebar collapsed
    &.open {
      width: 100% !important;
    }
    &.open ~ .chat-container {
      width: 0;
    }
  }
}

.chat-container {
  flex-grow: 1;
  height: 100%;
  background: hsl(var(--background-container));
  transition: width 0.2s ease-in-out;

  .chat-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 12px;
  }

  .tooltip {
    user-select: none;

    strong {
      font-weight: 600 !important;
    }
  }

  .chat-product {
    position: relative;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    overflow: hidden;
    justify-content: center;
    align-items: center;

    button {
      margin: 0.5rem 0;
    }

    .space-footer {
      position: absolute;
      display: flex;
      flex-direction: column;
      align-items: center;
      bottom: 6px;
      user-select: none;
      font-size: 14px;
      color: hsl(var(--text-secondary));

      p {
        display: flex;
        flex-direction: row;
        align-items: center;
        white-space: nowrap;

        &:first-child {
          margin-bottom: 4px;
        }
      }

      a {
        color: hsl(var(--text));
        text-decoration: none;
        transition: 0.25s;
        cursor: pointer;
      }
    }
  }

  .chat-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    padding: 18px;
    scrollbar-width: thin;

    // using margin instead of gap to avoid browser compatibility issues
    & > * {
      margin-bottom: 8px;

      &:last-child {
        margin-bottom: 0;
      }
    }

    &::-webkit-scrollbar {
      width: 6px;
    }
  }

  .chat-input {
    flex-shrink: 0;
    height: max-content;
    width: 100%;
    overflow: hidden;
    padding: 6px 24px;

    .input-wrapper {
      position: relative;
      display: flex;
      flex-direction: row;
      align-items: center;
      flex-wrap: nowrap;
      width: 100%;
      height: min-content;

      .chat-box {
        position: relative;
        flex-grow: 1;
        margin: 0 4px;
      }

      .input-box {
        width: 100%;
        color: hsl(var(--text));
        white-space: pre-wrap;
        padding: 0 2.5rem;

        &.align {
          text-align: center;
        }

        &::placeholder {
          color: hsl(var(--text-secondary));
          opacity: 1;
          transition: opacity 0.3s ease, visibility 0.3s ease;
        }

        &:active::placeholder,
        &:focus::placeholder {
          opacity: 0;
          visibility: hidden;
        }

        @-moz-document url-prefix() {
          &::-moz-placeholder {
            opacity: 1;
            transition: opacity 0.3s ease, visibility 0.3s ease;
            visibility: visible;
          }

          &:active::-moz-placeholder,
          &:focus::-moz-placeholder {
            opacity: 0;
            visibility: hidden;
          }
        }
      }

      .send-button {
        padding: 0 6px;

        svg {
          fill: hsl(var(--text));
        }
      }
    }

    .input-options {
      margin: 6px auto -6px;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      gap: 4px;
      height: min-content;
    }
  }
}

.share-wrapper {
  display: flex;
  flex-direction: row;
  gap: 6px;
  width: 100%;

  input {
    text-align: center;
    font-size: 16px;
    cursor: pointer;
    flex-grow: 1;
  }

  button {
    flex-shrink: 0;
  }
}

.contact-image {
  margin-top: 0.75rem;
  max-width: min(60vw, 420px);
  max-height: 50vh;
  border-radius: var(--radius);
}

.version {
  display: flex;
  flex-direction: row;
  align-items: center;
  user-select: none;
  font-size: 14px;
  color: hsl(var(--text-secondary));
  transform: translateY(4px);
  width: max-content;
  margin: 0 auto;

  svg {
    margin-right: 2px;
    padding: 2px;
    width: 24px;
    height: 24px;
    color: hsl(var(--text-secondary));
    cursor: pointer;
    transition: 0.25s;
    transform: translateY(1px);

    &:hover {
      color: hsl(var(--text));
    }
  }
}
